From 98744bc178be83410e643a20bc5b394dff1d9078 Mon Sep 17 00:00:00 2001 From: Max Kurapov Date: Fri, 25 Oct 2024 17:45:06 +0200 Subject: [PATCH 1/2] 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..f209ef380 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 : '') } }) From 1a2ec98ca4e6363f714443ecd37404c0b2c9aa55 Mon Sep 17 00:00:00 2001 From: Tymmmy <117268143+Tymmmy@users.noreply.github.com> Date: Tue, 5 Nov 2024 11:52:52 +0200 Subject: [PATCH 2/2] Update send.tsx --- packages/wallet/frontend/src/pages/send.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/wallet/frontend/src/pages/send.tsx b/packages/wallet/frontend/src/pages/send.tsx index f209ef380..ebebd4ec8 100644 --- a/packages/wallet/frontend/src/pages/send.tsx +++ b/packages/wallet/frontend/src/pages/send.tsx @@ -52,7 +52,9 @@ const SendPage: NextPageWithLayout = ({ accounts }) => { null ) const router = useRouter() - const receiverFromQueryParams = router.query?.receiver ? decodeURIComponent(router.query.receiver as string) : null; + const receiverFromQueryParams = router.query?.receiver + ? decodeURIComponent(router.query.receiver as string) + : null const [receiverPublicName, setReceiverPublicName] = useState('Recepient') const [currentExchangeRates, setCurrentExchangeRates] = @@ -84,7 +86,9 @@ const SendPage: NextPageWithLayout = ({ accounts }) => { schema: sendSchema, defaultValues: { paymentType: PAYMENT_SEND, - receiver: receiverFromQueryParams ?? (isUserFirstTime ? INTERLEDGER_WALLET_ADDRESS : '') + receiver: + receiverFromQueryParams ?? + (isUserFirstTime ? INTERLEDGER_WALLET_ADDRESS : '') } })