From fe6e9be70225cf2953822ff64b9e90066cab97ea Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 28 Oct 2022 13:39:06 -0300 Subject: manage account instead of add account --- .../src/wallet/AddAccount/views.tsx | 249 --------------------- 1 file changed, 249 deletions(-) delete mode 100644 packages/taler-wallet-webextension/src/wallet/AddAccount/views.tsx (limited to 'packages/taler-wallet-webextension/src/wallet/AddAccount/views.tsx') diff --git a/packages/taler-wallet-webextension/src/wallet/AddAccount/views.tsx b/packages/taler-wallet-webextension/src/wallet/AddAccount/views.tsx deleted file mode 100644 index d6ab7e967..000000000 --- a/packages/taler-wallet-webextension/src/wallet/AddAccount/views.tsx +++ /dev/null @@ -1,249 +0,0 @@ -/* - 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 { parsePaytoUri } from "@gnu-taler/taler-util"; -import { Fragment, h, VNode } from "preact"; -import { useState } from "preact/hooks"; -import { ErrorMessage } from "../../components/ErrorMessage.js"; -import { LoadingError } from "../../components/LoadingError.js"; -import { SelectList } from "../../components/SelectList.js"; -import { Input, LightText, SubTitle } from "../../components/styled/index.js"; -import { useTranslationContext } from "../../context/translation.js"; -import { Button } from "../../mui/Button.js"; -import { TextFieldHandler } from "../../mui/handlers.js"; -import { TextField } from "../../mui/TextField.js"; -import { State } from "./index.js"; - -export function LoadingUriView({ error }: State.LoadingUriError): VNode { - const { i18n } = useTranslationContext(); - - return ( - Could not load} - error={error} - /> - ); -} - -export function ReadyView({ - currency, - error, - accountType, - alias, - onAccountAdded, - onCancel, - uri, -}: State.Ready): VNode { - const { i18n } = useTranslationContext(); - - return ( - -
- - Add bank account for {currency} - - - - Enter the URL of an exchange you trust. - - - - {error && ( - Unable add this account} - description={error} - /> - )} -

- - Select account type} - list={accountType.list} - name="accountType" - value={accountType.value} - onChange={accountType.onChange} - /> - -

- {accountType.value === "" ? undefined : ( - -

- -

-

- -

-
- )} -
-
- - -
-
- ); -} - -function BitcoinAddressAccount({ field }: { field: TextFieldHandler }): VNode { - const { i18n } = useTranslationContext(); - const [value, setValue] = useState(undefined); - const errors = undefinedIfEmpty({ - value: !value ? i18n.str`Can't be empty` : undefined, - }); - return ( - - { - setValue(v); - if (!errors) { - field.onInput(`payto://bitcoin/${value}`); - } - }} - /> - {value !== undefined && errors?.value && ( - {errors?.value}} /> - )} - - ); -} - -function undefinedIfEmpty(obj: T): T | undefined { - return Object.keys(obj).some((k) => (obj as any)[k] !== undefined) - ? obj - : undefined; -} - -function TalerBankAddressAccount({ - field, -}: { - field: TextFieldHandler; -}): VNode { - const { i18n } = useTranslationContext(); - const [host, setHost] = useState(undefined); - const [account, setAccount] = useState(undefined); - const errors = undefinedIfEmpty({ - host: !host ? i18n.str`Can't be empty` : undefined, - account: !account ? i18n.str`Can't be empty` : undefined, - }); - return ( - - { - setHost(v); - if (!errors) { - field.onInput(`payto://x-taler-bank/${host}/${account}`); - } - }} - />{" "} - {host !== undefined && errors?.host && ( - {errors?.host}} /> - )} - { - setAccount(v || ""); - if (!errors) { - field.onInput(`payto://x-taler-bank/${host}/${account}`); - } - }} - />{" "} - {account !== undefined && errors?.account && ( - {errors?.account}} /> - )} - - ); -} - -function IbanAddressAccount({ field }: { field: TextFieldHandler }): VNode { - const { i18n } = useTranslationContext(); - const [value, setValue] = useState(undefined); - const errors = undefinedIfEmpty({ - value: !value ? i18n.str`Can't be empty` : undefined, - }); - return ( - - { - setValue(v); - if (!errors) { - field.onInput(`payto://iba/${value}`); - } - }} - /> - {value !== undefined && errors?.value && ( - {errors?.value}} /> - )} - - ); -} - -function CustomFieldByAccountType({ - type, - field, -}: { - type: string; - field: TextFieldHandler; -}): VNode { - if (type === "bitcoin") { - return ; - } - if (type === "x-taler-bank") { - return ; - } - if (type === "iban") { - return ; - } - return ; -} -- cgit v1.2.3