/* This file is part of GNU Taler (C) 2022 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Taler; see the file COPYING. If not, see */ import { useTranslationContext } from "@gnu-taler/web-util/browser"; import { Fragment, h, VNode } from "preact"; import { ErrorMessage } from "../../components/ErrorMessage.js"; import { Input, LightText, SubTitle, Title, WarningBox } from "../../components/styled/index.js"; import { TermsOfService } from "../../components/TermsOfService/index.js"; import { Button } from "../../mui/Button.js"; import { State } from "./index.js"; import { assertUnreachable } from "@gnu-taler/taler-util"; export function VerifyView({ expectedCurrency, onCancel, onAccept, result, loading, knownExchanges, url, }: State.Verify): VNode { const { i18n } = useTranslationContext(); return (
{!expectedCurrency ? ( <i18n.Translate>Add new exchange</i18n.Translate> ) : ( Add exchange for {expectedCurrency} )} {!result && ( Enter the URL of an exchange you trust. )} {(() => { if (!result) return; if (result.type == "ok") { return An exchange has been found! Review the information and click next } switch (result.case) { case "already-active": { return This exchange is already in your list. } case "invalid-protocol": { return Only exchange accessible through "http" and "https" are allowed. } case "invalid-version": { return This exchange protocol version is not supported: "{result.body}". } case "invalid-currency": { return This exchange currency "{result.body}" doesn't match the expected currency {expectedCurrency}. } default: { assertUnreachable(result.case) } } })()}

{ if (url.onInput) { url.onInput(e.currentTarget.value) } }} /> {loading && (

loading...
)} {result && result.type === "ok" && ( )}

{url.value && url.error && ( )}
); } export function ConfirmView({ url, onCancel, onConfirm, }: State.Confirm): VNode { const { i18n } = useTranslationContext(); return (
<i18n.Translate>Review terms of service</i18n.Translate>
Exchange URL: {url}
); }