From 88618df7b870732f4f29a80686dd4f4cf20887f8 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 22 Nov 2022 15:43:39 -0300 Subject: amount field --- .../src/wallet/ManualWithdrawPage.tsx | 141 --------------------- 1 file changed, 141 deletions(-) delete mode 100644 packages/taler-wallet-webextension/src/wallet/ManualWithdrawPage.tsx (limited to 'packages/taler-wallet-webextension/src/wallet/ManualWithdrawPage.tsx') diff --git a/packages/taler-wallet-webextension/src/wallet/ManualWithdrawPage.tsx b/packages/taler-wallet-webextension/src/wallet/ManualWithdrawPage.tsx deleted file mode 100644 index e2284a466..000000000 --- a/packages/taler-wallet-webextension/src/wallet/ManualWithdrawPage.tsx +++ /dev/null @@ -1,141 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2022 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see - */ - -import { - AcceptManualWithdrawalResult, - AmountJson, - Amounts, - NotificationType, - parsePaytoUri, - PaytoUri, -} from "@gnu-taler/taler-util"; -import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; -import { h, VNode } from "preact"; -import { useEffect, useState } from "preact/hooks"; -import { Loading } from "../components/Loading.js"; -import { LoadingError } from "../components/LoadingError.js"; -import { useTranslationContext } from "../context/translation.js"; -import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; -import { wxApi } from "../wxApi.js"; -import { CreateManualWithdraw } from "./CreateManualWithdraw.js"; -import { ReserveCreated } from "./ReserveCreated.js"; - -interface Props { - amount?: string; - onCancel: () => Promise; -} - -export function ManualWithdrawPage({ amount, onCancel }: Props): VNode { - const [success, setSuccess] = useState< - | { - response: AcceptManualWithdrawalResult; - exchangeBaseUrl: string; - amount: AmountJson; - paytoURI: PaytoUri | undefined; - payto: string; - } - | undefined - >(undefined); - const [error, setError] = useState(undefined); - - const state = useAsyncAsHook(() => - wxApi.wallet.call(WalletApiOperation.ListExchanges, {}), - ); - useEffect(() => { - return wxApi.listener.onUpdateNotification( - [NotificationType.ExchangeAdded], - state?.retry, - ); - }); - const { i18n } = useTranslationContext(); - - async function doCreate( - exchangeBaseUrl: string, - amount: AmountJson, - ): Promise { - try { - const response = await wxApi.wallet.call( - WalletApiOperation.AcceptManualWithdrawal, - { - exchangeBaseUrl: exchangeBaseUrl, - amount: Amounts.stringify(amount), - }, - ); - const payto = response.exchangePaytoUris[0]; - const paytoURI = parsePaytoUri(payto); - setSuccess({ exchangeBaseUrl, response, amount, paytoURI, payto }); - } catch (e) { - if (e instanceof Error) { - setError(e.message); - } else { - setError("unexpected error"); - } - setSuccess(undefined); - } - } - - if (success) { - return ( - - ); - } - - if (!state) { - return ; - } - if (state.hasError) { - return ( - - Could not load the list of known exchanges - - } - error={state} - /> - ); - } - - const exchangeList = state.response.exchanges.reduce( - (p, c) => ({ - ...p, - [c.exchangeBaseUrl]: c.currency || "??", - }), - {} as Record, - ); - - const parsedAmount = !amount ? undefined : Amounts.parse(amount); - const currency = parsedAmount?.currency; - const amountValue = !parsedAmount - ? undefined - : Amounts.stringifyValue(parsedAmount); - return ( - - ); -} -- cgit v1.2.3