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();
|
||||
|
||||
return React.useMemo(() => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return new URLSearchParams(location.search) as any;
|
||||
const searchParams = new URLSearchParams(location.search);
|
||||
// @ts-ignore searchParams doesnt have symbol.iterator
|
||||
return Object.fromEntries(searchParams);
|
||||
}, [location]);
|
||||
}
|
||||
|
@ -30,7 +30,9 @@ export const AssociatePage = ({
|
||||
const [amount, setAmount] = React.useState<string>('');
|
||||
|
||||
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
|
||||
React.useEffect(() => {
|
||||
@ -71,7 +73,7 @@ export const AssociatePage = ({
|
||||
} else if (!zeroVega && zeroVesting) {
|
||||
setSelectedStakingMethod(StakingMethod.Wallet);
|
||||
} else {
|
||||
setSelectedStakingMethod(params.method);
|
||||
setSelectedStakingMethod(params.method as StakingMethod);
|
||||
}
|
||||
}, [params.method, zeroVega, zeroVesting]);
|
||||
|
||||
|
@ -14,7 +14,9 @@ export const DisassociatePageNoVega = () => {
|
||||
const params = useSearchParams();
|
||||
const [amount, setAmount] = React.useState<string>('');
|
||||
const [selectedStakingMethod, setSelectedStakingMethod] =
|
||||
React.useState<StakingMethod | null>(params.method || null);
|
||||
React.useState<StakingMethod | null>(
|
||||
(params.method as StakingMethod) || null
|
||||
);
|
||||
|
||||
return (
|
||||
<section className="disassociate-page" data-testid="disassociate-page">
|
||||
|
@ -26,7 +26,9 @@ export const DisassociatePage = ({
|
||||
const params = useSearchParams();
|
||||
const [amount, setAmount] = React.useState<string>('');
|
||||
const [selectedStakingMethod, setSelectedStakingMethod] =
|
||||
React.useState<StakingMethod | null>(params.method || null);
|
||||
React.useState<StakingMethod | null>(
|
||||
(params.method as StakingMethod) || null
|
||||
);
|
||||
const refreshBalances = useRefreshAssociatedBalances();
|
||||
|
||||
// Clear the amount when the staking method changes
|
||||
|
@ -91,7 +91,9 @@ export const StakingForm = ({
|
||||
const { sendTx } = useVegaWallet();
|
||||
const [formState, setFormState] = React.useState(FormState.Default);
|
||||
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 [removeType, setRemoveType] = React.useState<RemoveType>(
|
||||
RemoveType.EndOfEpoch
|
||||
|
Loading…
Reference in New Issue
Block a user