From f185f8b24d30ab04e2c94c5cbefdc50ab39309d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Wed, 19 Jun 2024 11:36:44 +0200 Subject: [PATCH] fix navigation --- .../frontend/src/components/molecules/WalletInfoCard.tsx | 2 +- govtool/frontend/src/components/molecules/WalletOption.tsx | 7 +++++-- .../organisms/GovernanceActionDetailsCardData.tsx | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/govtool/frontend/src/components/molecules/WalletInfoCard.tsx b/govtool/frontend/src/components/molecules/WalletInfoCard.tsx index 054067c3d..475828f64 100644 --- a/govtool/frontend/src/components/molecules/WalletInfoCard.tsx +++ b/govtool/frontend/src/components/molecules/WalletInfoCard.tsx @@ -16,7 +16,7 @@ export const WalletInfoCard = () => { await disconnectWallet(); navigate( pathname.includes("/connected") - ? `${pathname.replace("/connected", "")}${hash}` + ? `${pathname.replace("/connected", "")}${hash ?? ""}` : PATHS.home, ); window.location.reload(); diff --git a/govtool/frontend/src/components/molecules/WalletOption.tsx b/govtool/frontend/src/components/molecules/WalletOption.tsx index f33b599aa..381fa2ee5 100644 --- a/govtool/frontend/src/components/molecules/WalletOption.tsx +++ b/govtool/frontend/src/components/molecules/WalletOption.tsx @@ -35,9 +35,12 @@ export const WalletOptionButton: FC = ({ const result = await enable(name); if (result?.stakeKey) { navigate( - pathToNavigate ?? pathname === "/" + // eslint-disable-next-line no-unneeded-ternary + pathToNavigate + ? pathToNavigate + : pathname === "/" ? "/dashboard" - : `connected${pathname}${hash}`, + : `connected${pathname}${hash ?? ""}`, { state }, ); return; diff --git a/govtool/frontend/src/components/organisms/GovernanceActionDetailsCardData.tsx b/govtool/frontend/src/components/organisms/GovernanceActionDetailsCardData.tsx index 2350bb0a5..d1be2a797 100644 --- a/govtool/frontend/src/components/organisms/GovernanceActionDetailsCardData.tsx +++ b/govtool/frontend/src/components/organisms/GovernanceActionDetailsCardData.tsx @@ -64,7 +64,9 @@ export const GovernanceActionDetailsCardData = ({ const govActionLinkToShare = `${window.location.protocol}//${ window.location.hostname - }${window.location.port ? `:${window.location.port}` : ""}${pathname}${hash}`; + }${window.location.port ? `:${window.location.port}` : ""}${pathname}${ + hash ?? "" + }`; return (