diff --git a/packages/taler-wallet-webextension/src/components/ErrorMessage.tsx b/packages/taler-wallet-webextension/src/components/ErrorMessage.tsx index eaf015224..6bbdd26dc 100644 --- a/packages/taler-wallet-webextension/src/components/ErrorMessage.tsx +++ b/packages/taler-wallet-webextension/src/components/ErrorMessage.tsx @@ -1,8 +1,9 @@ +import { VNode } from "preact"; import { useState } from "preact/hooks"; import arrowDown from '../../static/img/chevron-down.svg'; import { ErrorBox } from "./styled"; -export function ErrorMessage({ title, description }: { title?: string; description?: string; }) { +export function ErrorMessage({ title, description }: { title?: string|VNode; description?: string; }) { const [showErrorDetail, setShowErrorDetail] = useState(false); if (!title) return null; diff --git a/packages/taler-wallet-webextension/src/popup/ProviderDetailPage.tsx b/packages/taler-wallet-webextension/src/popup/ProviderDetailPage.tsx index 2482dee18..12567c2c7 100644 --- a/packages/taler-wallet-webextension/src/popup/ProviderDetailPage.tsx +++ b/packages/taler-wallet-webextension/src/popup/ProviderDetailPage.tsx @@ -54,69 +54,6 @@ export interface ViewProps { } export function ProviderView({ info, onDelete, onSync, onBack, onExtend }: ViewProps): VNode { - function Error() { - if (info?.lastError) { - return - //
- //
last time tried {!info.lastAttemptedBackupTimestamp || info.lastAttemptedBackupTimestamp.t_ms === 'never' ? 'never' : format(new Date(info.lastAttemptedBackupTimestamp.t_ms), 'dd/MM/yyyy HH:mm:ss')}
- //

{info.lastError.hint}

- //
- // - } - if (info?.backupProblem) { - switch (info.backupProblem.type) { - case "backup-conflicting-device": - return
-

There is conflict with another backup from {info.backupProblem.otherDeviceId}

-
- case "backup-unreadable": - return
-

Backup is not readable

-
- default: - return
-

Unknown backup problem: {JSON.stringify(info.backupProblem)}

-
- } - } - return null - } - - function colorByStatus(status: ProviderPaymentType) { - switch (status) { - case ProviderPaymentType.InsufficientBalance: - return 'rgb(223, 117, 20)' - case ProviderPaymentType.Unpaid: - return 'rgb(202, 60, 60)' - case ProviderPaymentType.Paid: - return 'rgb(28, 184, 65)' - case ProviderPaymentType.Pending: - return 'gray' - case ProviderPaymentType.InsufficientBalance: - return 'rgb(202, 60, 60)' - case ProviderPaymentType.TermsChanged: - return 'rgb(202, 60, 60)' - } - } - - function descriptionByStatus(status: ProviderPaymentStatus) { - switch (status.type) { - case ProviderPaymentType.InsufficientBalance: - return 'no enough balance to make the payment' - case ProviderPaymentType.Unpaid: - return 'not pay yet' - case ProviderPaymentType.Paid: - case ProviderPaymentType.TermsChanged: - if (status.paidUntil.t_ms === 'never') { - return 'service paid.' - } else { - return `service paid until ${format(status.paidUntil.t_ms, 'yyyy/MM/dd HH:mm:ss')}` - } - case ProviderPaymentType.Pending: - return '' - } - } - return (
@@ -125,7 +62,7 @@ export function ProviderView({ info, onDelete, onSync, onBack, onExtend }: ViewP {info.terms &&
{info.terms.annualFee} / year
}
- +

{info.syncProviderBaseUrl}

{daysSince(info?.lastSuccessfulBackupTimestamp)}

{descriptionByStatus(info.paymentStatus)}

@@ -193,3 +130,59 @@ function daysSince(d?: Timestamp) { }) return `synced ${str} ago` } + +function Error({ info }: { info: ProviderInfo }) { + if (info.lastError) { + return + } + if (info.backupProblem) { + switch (info.backupProblem.type) { + case "backup-conflicting-device": + return + There is conflict with another backup from {info.backupProblem.otherDeviceId} + } /> + case "backup-unreadable": + return + default: + return + Unknown backup problem: {JSON.stringify(info.backupProblem)} + } /> + } + } + return null +} + +function colorByStatus(status: ProviderPaymentType) { + switch (status) { + case ProviderPaymentType.InsufficientBalance: + return 'rgb(223, 117, 20)' + case ProviderPaymentType.Unpaid: + return 'rgb(202, 60, 60)' + case ProviderPaymentType.Paid: + return 'rgb(28, 184, 65)' + case ProviderPaymentType.Pending: + return 'gray' + case ProviderPaymentType.InsufficientBalance: + return 'rgb(202, 60, 60)' + case ProviderPaymentType.TermsChanged: + return 'rgb(202, 60, 60)' + } +} + +function descriptionByStatus(status: ProviderPaymentStatus) { + switch (status.type) { + case ProviderPaymentType.InsufficientBalance: + return 'no enough balance to make the payment' + case ProviderPaymentType.Unpaid: + return 'not pay yet' + case ProviderPaymentType.Paid: + case ProviderPaymentType.TermsChanged: + if (status.paidUntil.t_ms === 'never') { + return 'service paid.' + } else { + return `service paid until ${format(status.paidUntil.t_ms, 'yyyy/MM/dd HH:mm:ss')}` + } + case ProviderPaymentType.Pending: + return '' + } +}