From a0bcf08a4fee8cfed152b1f1259204f9a6ecab33 Mon Sep 17 00:00:00 2001 From: VPcodebase Date: Thu, 15 Jul 2021 19:35:46 +0300 Subject: [PATCH] fix: routing fix --- src/Routes.tsx | 2 +- src/pages/AddressPage/index.tsx | 31 +++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/Routes.tsx b/src/Routes.tsx index 86be969..88422d9 100644 --- a/src/Routes.tsx +++ b/src/Routes.tsx @@ -55,7 +55,7 @@ export function Routes() { - + diff --git a/src/pages/AddressPage/index.tsx b/src/pages/AddressPage/index.tsx index 9afdfde..24f33f2 100644 --- a/src/pages/AddressPage/index.tsx +++ b/src/pages/AddressPage/index.tsx @@ -31,11 +31,38 @@ import { useCurrency } from "src/hooks/ONE-ETH-SwitcherHook"; export function AddressPage() { const history = useHistory(); const tabParamName = "activeTab="; + const oldTabParamName = "txType="; let activeTab = 0; try { - activeTab = +history.location.search.slice( + const newValue = +history.location.search.slice( history.location.search.indexOf("activeTab=") + tabParamName.length ); + + const oldTxType = history.location.search.slice( + history.location.search.indexOf(oldTabParamName) + oldTabParamName.length + ); + + activeTab = isNaN(newValue) ? 0 : newValue; + + switch (oldTxType) { + case "regular": { + activeTab = 0; + break; + } + + case "staking": { + activeTab = 1; + break; + } + + case "hrc20": { + activeTab = 3; + break; + } + + default: { + } + } } catch { activeTab = 0; } @@ -54,7 +81,7 @@ export function AddressPage() { //TODO remove hardcode // @ts-ignore let { id } = useParams(); - id = `${id}`.toLowerCase() + id = `${id}`.toLowerCase(); id = id.slice(0, 3) === "one" ? getAddress(id).basicHex : id; const erc20Token = erc20Map[id] || null;