diff options
Diffstat (limited to 'packages/demobank-ui/src/pages/PaytoWireTransferForm.tsx')
-rw-r--r-- | packages/demobank-ui/src/pages/PaytoWireTransferForm.tsx | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/packages/demobank-ui/src/pages/PaytoWireTransferForm.tsx b/packages/demobank-ui/src/pages/PaytoWireTransferForm.tsx index 9fe3453a5..00b6767ac 100644 --- a/packages/demobank-ui/src/pages/PaytoWireTransferForm.tsx +++ b/packages/demobank-ui/src/pages/PaytoWireTransferForm.tsx @@ -45,35 +45,47 @@ import { mutate } from "swr"; import { useBankCoreApiContext } from "../context/config.js"; import { useBackendState } from "../hooks/backend.js"; import { useBankState } from "../hooks/bank-state.js"; -import { RouteDefinition } from "../route.js"; +import { EmptyObject, RouteDefinition } from "../route.js"; import { undefinedIfEmpty, validateIBAN, validateTalerBank } from "../utils.js"; +interface Props { + title: TranslatedString; + focus?: boolean; + withAccount?: string; + withSubject?: string; + withAmount?: string; + onSuccess: () => void; + onAuthorizationRequired: () => void; + routeCancel?: RouteDefinition; + routeHere: RouteDefinition<{ + account?: string, + subject?: string, + amount?: string, + }>; + limit: AmountJson; +} + export function PaytoWireTransferForm({ focus, title, - toAccount, + withAccount, + withSubject, + withAmount, onSuccess, routeCancel, + routeHere, onAuthorizationRequired, limit, -}: { - title: TranslatedString; - focus?: boolean; - toAccount?: string; - onSuccess: () => void; - onAuthorizationRequired: () => void; - routeCancel?: RouteDefinition<Record<string, never>>; - limit: AmountJson; -}): VNode { +}: Props): VNode { const [isRawPayto, setIsRawPayto] = useState(false); const { state: credentials } = useBackendState(); const { api, config, url } = useBankCoreApiContext(); - const sendingToFixedAccount = toAccount !== undefined; + const sendingToFixedAccount = withAccount !== undefined; - const [account, setAccount] = useState<string | undefined>(toAccount); - const [subject, setSubject] = useState<string | undefined>(); - const [amount, setAmount] = useState<string | undefined>(); + const [account, setAccount] = useState<string | undefined>(withAccount); + const [subject, setSubject] = useState<string | undefined>(withSubject); + const [amount, setAmount] = useState<string | undefined>(withAmount); const [, updateBankState] = useBankState(); const [rawPaytoInput, rawPaytoInputSetter] = useState<string | undefined>( @@ -200,6 +212,7 @@ export function PaytoWireTransferForm({ updateBankState("currentChallenge", { operation: "create-transaction", id: String(resp.body.challenge_id), + location: routeHere.url({ account: account ?? "", amount, subject }), sent: AbsoluteTime.never(), request, }); |