From 2a417881bb5c67cf889d54932025badf5a85a9e0 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 20 Jan 2022 13:13:53 -0300 Subject: fix permission api, grouping all cta into same path --- .../src/wallet/BackupPage.tsx | 69 ++++++++++++++++++++-- 1 file changed, 63 insertions(+), 6 deletions(-) (limited to 'packages/taler-wallet-webextension/src/wallet/BackupPage.tsx') diff --git a/packages/taler-wallet-webextension/src/wallet/BackupPage.tsx b/packages/taler-wallet-webextension/src/wallet/BackupPage.tsx index 0b0af25ab..daea9e3bd 100644 --- a/packages/taler-wallet-webextension/src/wallet/BackupPage.tsx +++ b/packages/taler-wallet-webextension/src/wallet/BackupPage.tsx @@ -17,7 +17,9 @@ import { i18n, Timestamp } from "@gnu-taler/taler-util"; import { ProviderInfo, + ProviderPaymentPaid, ProviderPaymentStatus, + ProviderPaymentType, } from "@gnu-taler/taler-wallet-core"; import { differenceInMonths, @@ -25,6 +27,8 @@ import { intervalToDuration, } from "date-fns"; import { Fragment, h, VNode } from "preact"; +import { Loading } from "../components/Loading"; +import { LoadingError } from "../components/LoadingError"; import { BoldLight, ButtonPrimary, @@ -36,23 +40,58 @@ import { SmallLightText, SmallText, } from "../components/styled"; -import { useBackupStatus } from "../hooks/useBackupStatus"; +import { useAsyncAsHook } from "../hooks/useAsyncAsHook"; import { Pages } from "../NavigationBar"; +import * as wxApi from "../wxApi"; interface Props { onAddProvider: () => void; } +// interface BackupStatus { +// deviceName: string; +// providers: ProviderInfo[]; +// } + +// async function getBackupInfoOrdered(): BackupStatus { +// //create a first list of backup info by currency +// const status = await wxApi.getBackupInfo(); + +// return { deviceName: status.deviceId, providers }; +// } + +// async function sync() { +// await wxApi.syncAllProviders(); +// } + export function BackupPage({ onAddProvider }: Props): VNode { - const status = useBackupStatus(); + const status = useAsyncAsHook(wxApi.getBackupInfo); if (!status) { - return
Loading...
; + return ; + } + if (status.hasError) { + return ( + + ); } + + const providers = status.response.providers.sort((a, b) => { + if ( + a.paymentStatus.type === ProviderPaymentType.Paid && + b.paymentStatus.type === ProviderPaymentType.Paid + ) { + return getStatusPaidOrder(a.paymentStatus, b.paymentStatus); + } + return ( + getStatusTypeOrder(a.paymentStatus) - getStatusTypeOrder(b.paymentStatus) + ); + }); + return ( ); } @@ -128,7 +167,7 @@ function BackupLayout(props: TransactionLayoutProps): VNode {