fix: token app useSearchParams (#1014)
* fix: token app useSearchParams * chore: typecast url params to enums for token app
This commit is contained in:
parent
9e89b98bd0
commit
44c628332d
@ -5,7 +5,8 @@ export function useSearchParams() {
|
|||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
return React.useMemo(() => {
|
return React.useMemo(() => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
const searchParams = new URLSearchParams(location.search);
|
||||||
return new URLSearchParams(location.search) as any;
|
// @ts-ignore searchParams doesnt have symbol.iterator
|
||||||
|
return Object.fromEntries(searchParams);
|
||||||
}, [location]);
|
}, [location]);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,9 @@ export const AssociatePage = ({
|
|||||||
const [amount, setAmount] = React.useState<string>('');
|
const [amount, setAmount] = React.useState<string>('');
|
||||||
|
|
||||||
const [selectedStakingMethod, setSelectedStakingMethod] =
|
const [selectedStakingMethod, setSelectedStakingMethod] =
|
||||||
React.useState<StakingMethod | null>(params.method || null);
|
React.useState<StakingMethod | null>(
|
||||||
|
(params.method as StakingMethod) || null
|
||||||
|
);
|
||||||
|
|
||||||
// Clear the amount when the staking method changes
|
// Clear the amount when the staking method changes
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
@ -71,7 +73,7 @@ export const AssociatePage = ({
|
|||||||
} else if (!zeroVega && zeroVesting) {
|
} else if (!zeroVega && zeroVesting) {
|
||||||
setSelectedStakingMethod(StakingMethod.Wallet);
|
setSelectedStakingMethod(StakingMethod.Wallet);
|
||||||
} else {
|
} else {
|
||||||
setSelectedStakingMethod(params.method);
|
setSelectedStakingMethod(params.method as StakingMethod);
|
||||||
}
|
}
|
||||||
}, [params.method, zeroVega, zeroVesting]);
|
}, [params.method, zeroVega, zeroVesting]);
|
||||||
|
|
||||||
|
@ -14,7 +14,9 @@ export const DisassociatePageNoVega = () => {
|
|||||||
const params = useSearchParams();
|
const params = useSearchParams();
|
||||||
const [amount, setAmount] = React.useState<string>('');
|
const [amount, setAmount] = React.useState<string>('');
|
||||||
const [selectedStakingMethod, setSelectedStakingMethod] =
|
const [selectedStakingMethod, setSelectedStakingMethod] =
|
||||||
React.useState<StakingMethod | null>(params.method || null);
|
React.useState<StakingMethod | null>(
|
||||||
|
(params.method as StakingMethod) || null
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="disassociate-page" data-testid="disassociate-page">
|
<section className="disassociate-page" data-testid="disassociate-page">
|
||||||
|
@ -26,7 +26,9 @@ export const DisassociatePage = ({
|
|||||||
const params = useSearchParams();
|
const params = useSearchParams();
|
||||||
const [amount, setAmount] = React.useState<string>('');
|
const [amount, setAmount] = React.useState<string>('');
|
||||||
const [selectedStakingMethod, setSelectedStakingMethod] =
|
const [selectedStakingMethod, setSelectedStakingMethod] =
|
||||||
React.useState<StakingMethod | null>(params.method || null);
|
React.useState<StakingMethod | null>(
|
||||||
|
(params.method as StakingMethod) || null
|
||||||
|
);
|
||||||
const refreshBalances = useRefreshAssociatedBalances();
|
const refreshBalances = useRefreshAssociatedBalances();
|
||||||
|
|
||||||
// Clear the amount when the staking method changes
|
// Clear the amount when the staking method changes
|
||||||
|
@ -91,7 +91,9 @@ export const StakingForm = ({
|
|||||||
const { sendTx } = useVegaWallet();
|
const { sendTx } = useVegaWallet();
|
||||||
const [formState, setFormState] = React.useState(FormState.Default);
|
const [formState, setFormState] = React.useState(FormState.Default);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [action, setAction] = React.useState<StakeAction>(params.action);
|
const [action, setAction] = React.useState<StakeAction>(
|
||||||
|
params.action as StakeAction
|
||||||
|
);
|
||||||
const [amount, setAmount] = React.useState('');
|
const [amount, setAmount] = React.useState('');
|
||||||
const [removeType, setRemoveType] = React.useState<RemoveType>(
|
const [removeType, setRemoveType] = React.useState<RemoveType>(
|
||||||
RemoveType.EndOfEpoch
|
RemoveType.EndOfEpoch
|
||||||
|
Loading…
Reference in New Issue
Block a user