From e05ba843a061c8050648ce922f36ed3d8e1cf24a Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 24 Nov 2022 23:16:01 -0300 Subject: fix 7465 --- .../src/wallet/ProviderDetailPage.tsx | 81 +++++++++++++++------- 1 file changed, 56 insertions(+), 25 deletions(-) (limited to 'packages/taler-wallet-webextension/src/wallet/ProviderDetailPage.tsx') diff --git a/packages/taler-wallet-webextension/src/wallet/ProviderDetailPage.tsx b/packages/taler-wallet-webextension/src/wallet/ProviderDetailPage.tsx index d9dd1d746..6dde30b39 100644 --- a/packages/taler-wallet-webextension/src/wallet/ProviderDetailPage.tsx +++ b/packages/taler-wallet-webextension/src/wallet/ProviderDetailPage.tsx @@ -36,9 +36,16 @@ import { wxApi } from "../wxApi.js"; interface Props { pid: string; onBack: () => Promise; + onPayProvider: (uri: string) => Promise; + onWithdraw: (amount: string) => Promise; } -export function ProviderDetailPage({ pid: providerURL, onBack }: Props): VNode { +export function ProviderDetailPage({ + pid: providerURL, + onBack, + onPayProvider, + onWithdraw, +}: Props): VNode { const { i18n } = useTranslationContext(); async function getProviderInfo(): Promise { //create a first list of backup info by currency @@ -71,11 +78,30 @@ export function ProviderDetailPage({ pid: providerURL, onBack }: Props): VNode { /> ); } + const info = state.response; + if (info === null) { + return ( + +
+

+ + There is not known provider with url "{providerURL}". + +

+
+
+ +
+
+
+ ); + } return ( wxApi.wallet .call(WalletApiOperation.RunBackupCycle, { @@ -83,6 +109,16 @@ export function ProviderDetailPage({ pid: providerURL, onBack }: Props): VNode { }) .then() } + onPayProvider={async () => { + if (info.paymentStatus.type !== ProviderPaymentType.Pending) return; + if (!info.paymentStatus.talerUri) return; + onPayProvider(info.paymentStatus.talerUri); + }} + onWithdraw={async () => { + if (info.paymentStatus.type !== ProviderPaymentType.InsufficientBalance) + return; + onWithdraw(info.paymentStatus.amount); + }} onDelete={() => wxApi.wallet .call(WalletApiOperation.RemoveBackupProvider, { @@ -99,42 +135,25 @@ export function ProviderDetailPage({ pid: providerURL, onBack }: Props): VNode { } export interface ViewProps { - url: string; - info: ProviderInfo | null; + info: ProviderInfo; onDelete: () => Promise; onSync: () => Promise; onBack: () => Promise; onExtend: () => Promise; + onPayProvider: () => Promise; + onWithdraw: () => Promise; } export function ProviderView({ info, - url, onDelete, + onPayProvider, + onWithdraw, onSync, onBack, onExtend, }: ViewProps): VNode { const { i18n } = useTranslationContext(); - if (info === null) { - return ( - -
-

- - There is not known provider with url "{url}". - -

-
-
- -
-
-
- ); - } const lb = info.lastSuccessfulBackupTimestamp ? AbsoluteTime.fromTimestamp(info.lastSuccessfulBackupTimestamp) : undefined; @@ -230,6 +249,18 @@ export function ProviderView({ + {info.paymentStatus.type === ProviderPaymentType.Pending && + info.paymentStatus.talerUri ? ( + + ) : undefined} + {info.paymentStatus.type === + ProviderPaymentType.InsufficientBalance ? ( + + ) : undefined} -- cgit v1.2.3