From 550905f0e7eed38fa1ef598b4015faf10648cf1b Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 1 Jul 2021 15:42:32 -0300 Subject: add provider examples --- .../src/popup/ProviderAddPage.tsx | 107 +++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 packages/taler-wallet-webextension/src/popup/ProviderAddPage.tsx (limited to 'packages/taler-wallet-webextension/src/popup/ProviderAddPage.tsx') diff --git a/packages/taler-wallet-webextension/src/popup/ProviderAddPage.tsx b/packages/taler-wallet-webextension/src/popup/ProviderAddPage.tsx new file mode 100644 index 000000000..7b8712eca --- /dev/null +++ b/packages/taler-wallet-webextension/src/popup/ProviderAddPage.tsx @@ -0,0 +1,107 @@ +import { Amounts, BackupBackupProviderTerms, i18n } from "@gnu-taler/taler-util"; +import { privateDecrypt } from "crypto"; +import { add, addYears } from "date-fns"; +import { VNode } from "preact"; +import { useState } from "preact/hooks"; +import * as wxApi from "../wxApi"; +import ProviderAddConfirmProviderStories from "./ProviderAddConfirmProvider.stories"; + +interface Props { + currency: string; +} + +export function ProviderAddPage({ currency }: Props): VNode { + const [verifying, setVerifying] = useState<{ url: string, provider: BackupBackupProviderTerms } | undefined>(undefined) + if (!verifying) { + return { + setVerifying(undefined); + }} + onVerify={(url) => { + return fetch(url).then(r => r.json()) + .then((provider) => setVerifying({ url, provider })) + .catch((e) => e.message) + }} + /> + } + return { + setVerifying(undefined); + }} + onConfirm={() => { + wxApi.addBackupProvider(verifying.url).then(_ => history.go(-1)) + }} + + /> +} + +export interface SetUrlViewProps { + currency: string, + onCancel: () => void; + onVerify: (s: string) => Promise; +} + +export function SetUrlView({ currency, onCancel, onVerify }: SetUrlViewProps) { + const [value, setValue] = useState("") + const [error, setError] = useState(undefined) + return
+
+
+ Add backup provider for storing {currency} +
+ {error &&
+

{error}

+
} +

Backup provider URL

+ setValue(e.currentTarget.value)} /> +

+ Backup providers may charge for their service +

+
+
+ +
+ +
+
+
+} + +export interface ConfirmProviderViewProps { + provider: BackupBackupProviderTerms, + currency: string, + url: string, + onCancel: () => void; + onConfirm: () => void +} +export function ConfirmProviderView({ url, provider, currency, onCancel, onConfirm }: ConfirmProviderViewProps) { + return
+ +
+
+ Verify provider service terms for storing {currency} +
+

{url}

+

+ {Amounts.isZero(provider.annual_fee) ? 'free of charge' : provider.annual_fee} for a year of backup service +

+

+ {provider.storage_limit_in_megabytes} megabytes of storage +

+
+ +
+} -- cgit v1.2.3