From 78120e92ccfaf6434c7b3a0c52b988bd6a33ae84 Mon Sep 17 00:00:00 2001 From: Max Kurapov Date: Fri, 25 Oct 2024 17:45:06 +0200 Subject: [PATCH] feat(wallet-frontend): allow receiver in query params --- packages/wallet/frontend/src/pages/send.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/wallet/frontend/src/pages/send.tsx b/packages/wallet/frontend/src/pages/send.tsx index 45863692c..c5fb11e84 100644 --- a/packages/wallet/frontend/src/pages/send.tsx +++ b/packages/wallet/frontend/src/pages/send.tsx @@ -37,6 +37,7 @@ import { ExchangeRate } from '@/components/ExchangeRate' import { useSnapshot } from 'valtio' import { balanceState } from '@/lib/balance' import { AssetOP } from '@wallet/shared' +import { useRouter } from 'next/router' type SendProps = InferGetServerSidePropsType @@ -50,6 +51,9 @@ const SendPage: NextPageWithLayout = ({ accounts }) => { const [receiverAssetCode, setReceiverAssetCode] = useState( null ) + const router = useRouter() + const receiverFromQueryParams = router.query?.receiver ? decodeURIComponent(router.query?.receiver as string) : null; + const [receiverPublicName, setReceiverPublicName] = useState('Recepient') const [currentExchangeRates, setCurrentExchangeRates] = useState() @@ -80,7 +84,7 @@ const SendPage: NextPageWithLayout = ({ accounts }) => { schema: sendSchema, defaultValues: { paymentType: PAYMENT_SEND, - receiver: isUserFirstTime ? INTERLEDGER_WALLET_ADDRESS : '' + receiver: receiverFromQueryParams ?? (isUserFirstTime ? INTERLEDGER_WALLET_ADDRESS : '') } })