fix: routing fix

pull/38/head
VPcodebase 3 years ago
parent 785b2b2ff3
commit a0bcf08a4f
  1. 2
      src/Routes.tsx
  2. 31
      src/pages/AddressPage/index.tsx

@ -55,7 +55,7 @@ export function Routes() {
<StakingTransactionPage /> <StakingTransactionPage />
</Route> </Route>
<Route path="/address/:id"> <Route exact path="/address/:id">
<AddressPage /> <AddressPage />
</Route> </Route>

@ -31,11 +31,38 @@ import { useCurrency } from "src/hooks/ONE-ETH-SwitcherHook";
export function AddressPage() { export function AddressPage() {
const history = useHistory(); const history = useHistory();
const tabParamName = "activeTab="; const tabParamName = "activeTab=";
const oldTabParamName = "txType=";
let activeTab = 0; let activeTab = 0;
try { try {
activeTab = +history.location.search.slice( const newValue = +history.location.search.slice(
history.location.search.indexOf("activeTab=") + tabParamName.length 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 { } catch {
activeTab = 0; activeTab = 0;
} }
@ -54,7 +81,7 @@ export function AddressPage() {
//TODO remove hardcode //TODO remove hardcode
// @ts-ignore // @ts-ignore
let { id } = useParams(); let { id } = useParams();
id = `${id}`.toLowerCase() id = `${id}`.toLowerCase();
id = id.slice(0, 3) === "one" ? getAddress(id).basicHex : id; id = id.slice(0, 3) === "one" ? getAddress(id).basicHex : id;
const erc20Token = erc20Map[id] || null; const erc20Token = erc20Map[id] || null;

Loading…
Cancel
Save