From a994009d2f094c4d9c12da68dac3abb28bdef4b3 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 16 Nov 2021 13:59:53 -0300 Subject: reserveCreated new design --- .../src/wallet/ReserveCreated.tsx | 183 +++++++++++++++------ 1 file changed, 136 insertions(+), 47 deletions(-) (limited to 'packages/taler-wallet-webextension/src/wallet/ReserveCreated.tsx') diff --git a/packages/taler-wallet-webextension/src/wallet/ReserveCreated.tsx b/packages/taler-wallet-webextension/src/wallet/ReserveCreated.tsx index 9008e9751..a72026ab8 100644 --- a/packages/taler-wallet-webextension/src/wallet/ReserveCreated.tsx +++ b/packages/taler-wallet-webextension/src/wallet/ReserveCreated.tsx @@ -1,66 +1,155 @@ -import { h, Fragment, VNode } from "preact"; -import { useState } from "preact/hooks"; +import { + AmountJson, + Amounts, + parsePaytoUri, + PaytoUri, +} from "@gnu-taler/taler-util"; +import { Fragment, h, VNode } from "preact"; +import { useEffect, useState } from "preact/hooks"; import { QR } from "../components/QR"; -import { ButtonBox, FontIcon, WalletBox } from "../components/styled"; +import { + ButtonDestructive, + ButtonPrimary, + WalletBox, + WarningBox, +} from "../components/styled"; export interface Props { reservePub: string; - paytos: string[]; + payto: string; + exchangeBaseUrl: string; + amount: AmountJson; onBack: () => void; } -export function ReserveCreated({ reservePub, paytos, onBack }: Props): VNode { - const [opened, setOpened] = useState(-1); +interface BankDetailsProps { + payto: PaytoUri; + exchangeBaseUrl: string; + subject: string; + amount: string; +} + +function Row({ + name, + value, + literal, +}: { + name: string; + value: string; + literal?: boolean; +}): VNode { + const [copied, setCopied] = useState(false); + function copyText(): void { + navigator.clipboard.writeText(value); + setCopied(true); + } + useEffect(() => { + setTimeout(() => { + setCopied(false); + }, 1000); + }, [copied]); + return ( + + + {!copied ? ( + +   Copy   + + ) : ( + + Copied + + )} + + + {name} + + {literal ? ( + +
+            {value}
+          
+ + ) : ( + {value} + )} + + ); +} + +function BankDetailsByPaytoType({ + payto, + subject, + exchangeBaseUrl, + amount, +}: BankDetailsProps): VNode { + const firstPart = !payto.isKnown ? ( + + + + + ) : payto.targetType === "x-taler-bank" ? ( + + + + + + ) : payto.targetType === "iban" ? ( + + + + + ) : undefined; + return ( + + {firstPart} + + +
+ ); +} +export function ReserveCreated({ + reservePub, + payto, + onBack, + exchangeBaseUrl, + amount, +}: Props): VNode { + const paytoURI = parsePaytoUri(payto); + // const url = new URL(paytoURI?.targetPath); + if (!paytoURI) { + return
could not parse payto uri from exchange {payto}
; + } return (
-

Reserve created!

-

- Now you need to send money to the exchange to one of the following - accounts -

+

Bank transfer details

- To complete the setup of the reserve, you must now initiate a wire - transfer using the given wire transfer subject and crediting the - specified amount to the indicated account of the exchange. + Please wire {Amounts.stringify(amount)} to:

+
- +

+ + Make sure to use the correct subject, otherwise the money will not + arrive in this wallet. + +

+

+ Alternative, you can also scan this QR code or open{" "} + this link if you have a banking app installed that + supports RFC 8905 +

+
); -- cgit v1.2.3