diff options
author | Sebastian <sebasjm@gmail.com> | 2021-05-07 18:10:27 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2021-05-07 18:16:30 -0300 |
commit | 4ed4535bc090acf3e5a3b7781ba458d077aac751 (patch) | |
tree | e1c6af8a7e4c17b67992c824fb172b1bcd61601e /packages/taler-wallet-webextension/src/pages/withdraw.tsx | |
parent | 30f86f8748a0d9c23538e972d30270a4f1e83941 (diff) | |
download | wallet-core-4ed4535bc090acf3e5a3b7781ba458d077aac751.tar.xz |
preact routing on the wallet
Diffstat (limited to 'packages/taler-wallet-webextension/src/pages/withdraw.tsx')
-rw-r--r-- | packages/taler-wallet-webextension/src/pages/withdraw.tsx | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/packages/taler-wallet-webextension/src/pages/withdraw.tsx b/packages/taler-wallet-webextension/src/pages/withdraw.tsx index 1d628be22..d99bcf9c0 100644 --- a/packages/taler-wallet-webextension/src/pages/withdraw.tsx +++ b/packages/taler-wallet-webextension/src/pages/withdraw.tsx @@ -34,12 +34,14 @@ import { import { WithdrawUriInfoResponse } from "@gnu-taler/taler-util"; import { JSX } from "preact/jsx-runtime"; -function WithdrawalDialog(props: { talerWithdrawUri: string }): JSX.Element { +interface Props { + talerWithdrawUri?: string; +} +export function WithdrawalDialog({ talerWithdrawUri }: Props): JSX.Element { const [details, setDetails] = useState<WithdrawUriInfoResponse | undefined>(undefined); const [selectedExchange, setSelectedExchange] = useState< string | undefined >(undefined); - const talerWithdrawUri = props.talerWithdrawUri; const [cancelled, setCancelled] = useState(false); const [selecting, setSelecting] = useState(false); const [errMsg, setErrMsg] = useState<string | undefined>(""); @@ -52,10 +54,9 @@ function WithdrawalDialog(props: { talerWithdrawUri: string }): JSX.Element { }, []); useEffect(() => { + if (!talerWithdrawUri) return const fetchData = async (): Promise<void> => { - const res = await getWithdrawalDetailsForUri({ - talerWithdrawUri: props.talerWithdrawUri, - }); + const res = await getWithdrawalDetailsForUri({ talerWithdrawUri }); setDetails(res); if (res.defaultExchangeBaseUrl) { setSelectedExchange(res.defaultExchangeBaseUrl); @@ -64,6 +65,10 @@ function WithdrawalDialog(props: { talerWithdrawUri: string }): JSX.Element { fetchData(); }, [selectedExchange, errMsg, selecting, talerWithdrawUri, updateCounter]); + if (!talerWithdrawUri) { + return <span>missing withdraw uri</span>; + } + if (!details) { return <span>Loading...</span>; } |