From 75ff04672c011cf4c47b8f07d327adbf59323396 Mon Sep 17 00:00:00 2001 From: Nic Eigel Date: Mon, 24 Jun 2024 09:16:33 +0200 Subject: fixing merge-error --- .../instance/accounts/create/Create.stories.tsx | 28 - .../paths/instance/accounts/create/CreatePage.tsx | 173 ----- .../src/paths/instance/accounts/create/index.tsx | 65 -- .../paths/instance/accounts/list/List.stories.tsx | 28 - .../src/paths/instance/accounts/list/ListPage.tsx | 64 -- .../src/paths/instance/accounts/list/Table.tsx | 385 ----------- .../src/paths/instance/accounts/list/index.tsx | 107 --- .../instance/accounts/update/Update.stories.tsx | 32 - .../paths/instance/accounts/update/UpdatePage.tsx | 195 ------ .../src/paths/instance/accounts/update/index.tsx | 96 --- .../create/Create.stories.tsx | 43 -- .../deposit_confirmations/create/CreatePage.tsx | 80 --- .../create/CreatedSuccessfully.tsx | 69 -- .../deposit_confirmations/create/index.tsx | 46 -- .../deposit_confirmations/list/List.stories.tsx | 43 -- .../instance/deposit_confirmations/list/Table.tsx | 249 ------- .../update/Update.stories.tsx | 73 -- .../deposit_confirmations/update/UpdatePage.tsx | 99 --- .../src/paths/instance/details/DetailPage.tsx | 83 --- .../src/paths/instance/details/index.tsx | 87 --- .../src/paths/instance/details/stories.tsx | 68 -- .../src/paths/instance/index.stories.ts | 19 - .../paths/instance/kyc/list/ListPage.stories.tsx | 58 -- .../src/paths/instance/kyc/list/ListPage.tsx | 208 ------ .../src/paths/instance/kyc/list/index.tsx | 63 -- .../instance/orders/create/Create.stories.tsx | 71 -- .../paths/instance/orders/create/CreatePage.tsx | 705 ------------------- .../orders/create/OrderCreatedSuccessfully.tsx | 114 --- .../src/paths/instance/orders/create/index.tsx | 114 --- .../instance/orders/details/Detail.stories.tsx | 135 ---- .../paths/instance/orders/details/DetailPage.tsx | 770 --------------------- .../src/paths/instance/orders/details/Timeline.tsx | 129 ---- .../src/paths/instance/orders/details/index.tsx | 95 --- .../paths/instance/orders/list/List.stories.tsx | 107 --- .../src/paths/instance/orders/list/ListPage.tsx | 226 ------ .../src/paths/instance/orders/list/Table.tsx | 417 ----------- .../src/paths/instance/orders/list/index.tsx | 231 ------- .../instance/otp_devices/create/Create.stories.tsx | 28 - .../instance/otp_devices/create/CreatePage.tsx | 179 ----- .../otp_devices/create/CreatedSuccessfully.tsx | 104 --- .../paths/instance/otp_devices/create/index.tsx | 70 -- .../instance/otp_devices/list/List.stories.tsx | 28 - .../paths/instance/otp_devices/list/ListPage.tsx | 64 -- .../src/paths/instance/otp_devices/list/Table.tsx | 211 ------ .../src/paths/instance/otp_devices/list/index.tsx | 106 --- .../instance/otp_devices/update/Update.stories.tsx | 32 - .../instance/otp_devices/update/UpdatePage.tsx | 186 ----- .../paths/instance/otp_devices/update/index.tsx | 102 --- .../instance/products/create/Create.stories.tsx | 43 -- .../paths/instance/products/create/CreatePage.tsx | 80 --- .../products/create/CreatedSuccessfully.tsx | 72 -- .../src/paths/instance/products/create/index.tsx | 47 -- .../paths/instance/products/list/List.stories.tsx | 61 -- .../src/paths/instance/products/list/Table.tsx | 496 ------------- .../src/paths/instance/products/list/index.tsx | 150 ---- .../instance/products/update/Update.stories.tsx | 73 -- .../paths/instance/products/update/UpdatePage.tsx | 99 --- .../instance/reserves/create/Create.stories.tsx | 43 -- .../paths/instance/reserves/create/CreatePage.tsx | 277 -------- .../create/CreatedSuccessfully.stories.tsx | 120 ---- .../reserves/create/CreatedSuccessfully.tsx | 190 ----- .../src/paths/instance/reserves/create/index.tsx | 71 -- .../paths/instance/reserves/details/DetailPage.tsx | 266 ------- .../instance/reserves/details/Details.stories.tsx | 126 ---- .../paths/instance/reserves/details/RewardInfo.tsx | 94 --- .../src/paths/instance/reserves/details/index.tsx | 68 -- .../instance/reserves/list/AutorizeRewardModal.tsx | 124 ---- .../instance/reserves/list/CreatedSuccessfully.tsx | 102 --- .../paths/instance/reserves/list/List.stories.tsx | 96 --- .../src/paths/instance/reserves/list/Table.tsx | 320 --------- .../src/paths/instance/reserves/list/index.tsx | 171 ----- .../instance/templates/create/Create.stories.tsx | 28 - .../paths/instance/templates/create/CreatePage.tsx | 270 -------- .../src/paths/instance/templates/create/index.tsx | 61 -- .../paths/instance/templates/list/List.stories.tsx | 28 - .../src/paths/instance/templates/list/ListPage.tsx | 68 -- .../src/paths/instance/templates/list/Table.tsx | 235 ------- .../src/paths/instance/templates/list/index.tsx | 152 ---- .../src/paths/instance/templates/qr/Qr.stories.tsx | 27 - .../src/paths/instance/templates/qr/QrPage.tsx | 172 ----- .../instance/templates/update/Update.stories.tsx | 32 - .../paths/instance/templates/update/UpdatePage.tsx | 269 ------- .../src/paths/instance/templates/update/index.tsx | 99 --- .../paths/instance/templates/use/Use.stories.tsx | 27 - .../src/paths/instance/templates/use/UsePage.tsx | 143 ---- .../src/paths/instance/templates/use/index.tsx | 101 --- .../src/paths/instance/token/DetailPage.tsx | 183 ----- .../src/paths/instance/token/index.tsx | 106 --- .../src/paths/instance/token/stories.tsx | 28 - .../instance/transfers/create/Create.stories.tsx | 45 -- .../paths/instance/transfers/create/CreatePage.tsx | 146 ---- .../src/paths/instance/transfers/create/index.tsx | 68 -- .../paths/instance/transfers/list/List.stories.tsx | 93 --- .../src/paths/instance/transfers/list/ListPage.tsx | 134 ---- .../src/paths/instance/transfers/list/Table.tsx | 229 ------ .../src/paths/instance/transfers/list/index.tsx | 118 ---- .../src/paths/instance/update/Update.stories.tsx | 59 -- .../src/paths/instance/update/UpdatePage.tsx | 176 ----- .../src/paths/instance/update/index.tsx | 118 ---- .../instance/webhooks/create/Create.stories.tsx | 28 - .../paths/instance/webhooks/create/CreatePage.tsx | 183 ----- .../src/paths/instance/webhooks/create/index.tsx | 61 -- .../paths/instance/webhooks/list/List.stories.tsx | 28 - .../src/paths/instance/webhooks/list/ListPage.tsx | 64 -- .../src/paths/instance/webhooks/list/Table.tsx | 218 ------ .../src/paths/instance/webhooks/list/index.tsx | 109 --- .../instance/webhooks/update/Update.stories.tsx | 32 - .../paths/instance/webhooks/update/UpdatePage.tsx | 146 ---- .../src/paths/instance/webhooks/update/index.tsx | 99 --- 109 files changed, 14057 deletions(-) delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/accounts/create/Create.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/accounts/create/CreatePage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/accounts/create/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/accounts/list/List.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/accounts/list/ListPage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/accounts/list/Table.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/accounts/list/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/accounts/update/Update.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/accounts/update/UpdatePage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/accounts/update/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/Create.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/CreatePage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/CreatedSuccessfully.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/List.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/Table.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/update/Update.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/update/UpdatePage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/details/DetailPage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/details/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/details/stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/index.stories.ts delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/kyc/list/ListPage.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/kyc/list/ListPage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/kyc/list/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/orders/create/Create.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/orders/create/OrderCreatedSuccessfully.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/orders/create/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/orders/details/Detail.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/orders/details/DetailPage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/orders/details/Timeline.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/orders/details/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/orders/list/List.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/orders/list/ListPage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/orders/list/Table.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/orders/list/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/otp_devices/create/Create.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/otp_devices/create/CreatePage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/otp_devices/create/CreatedSuccessfully.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/otp_devices/create/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/otp_devices/list/List.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/otp_devices/list/ListPage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/otp_devices/list/Table.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/otp_devices/list/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/otp_devices/update/Update.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/otp_devices/update/UpdatePage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/otp_devices/update/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/products/create/Create.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/products/create/CreatePage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/products/create/CreatedSuccessfully.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/products/create/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/products/list/List.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/products/list/Table.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/products/list/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/products/update/Update.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/products/update/UpdatePage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/reserves/create/Create.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/reserves/create/CreatePage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/reserves/create/CreatedSuccessfully.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/reserves/create/CreatedSuccessfully.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/reserves/create/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/reserves/details/DetailPage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/reserves/details/Details.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/reserves/details/RewardInfo.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/reserves/details/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/reserves/list/AutorizeRewardModal.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/reserves/list/CreatedSuccessfully.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/reserves/list/List.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/reserves/list/Table.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/reserves/list/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/templates/create/Create.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/templates/create/CreatePage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/templates/create/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/templates/list/List.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/templates/list/ListPage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/templates/list/Table.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/templates/list/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/templates/qr/Qr.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/templates/qr/QrPage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/templates/update/Update.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/templates/update/UpdatePage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/templates/update/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/templates/use/Use.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/templates/use/UsePage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/templates/use/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/token/DetailPage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/token/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/token/stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/transfers/create/Create.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/transfers/create/CreatePage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/transfers/create/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/transfers/list/List.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/transfers/list/ListPage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/transfers/list/Table.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/transfers/list/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/update/Update.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/update/UpdatePage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/update/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/webhooks/create/Create.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/webhooks/create/CreatePage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/webhooks/create/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/webhooks/list/List.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/webhooks/list/ListPage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/webhooks/list/Table.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/webhooks/list/index.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/webhooks/update/Update.stories.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/webhooks/update/UpdatePage.tsx delete mode 100644 packages/auditor-backoffice-ui/src/paths/instance/webhooks/update/index.tsx (limited to 'packages/auditor-backoffice-ui/src/paths/instance') diff --git a/packages/auditor-backoffice-ui/src/paths/instance/accounts/create/Create.stories.tsx b/packages/auditor-backoffice-ui/src/paths/instance/accounts/create/Create.stories.tsx deleted file mode 100644 index 50cd801d8..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/accounts/create/Create.stories.tsx +++ /dev/null @@ -1,28 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { h, VNode, FunctionalComponent } from "preact"; -import { CreatePage as TestedComponent } from "./CreatePage.js"; - -export default { - title: "Pages/Accounts/Create", - component: TestedComponent, -}; diff --git a/packages/auditor-backoffice-ui/src/paths/instance/accounts/create/CreatePage.tsx b/packages/auditor-backoffice-ui/src/paths/instance/accounts/create/CreatePage.tsx deleted file mode 100644 index 09b1d38ec..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/accounts/create/CreatePage.tsx +++ /dev/null @@ -1,173 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { useTranslationContext } from "@gnu-taler/web-util/browser"; -import { Fragment, h, VNode } from "preact"; -import { useState } from "preact/hooks"; -import { AsyncButton } from "../../../../components/exception/AsyncButton.js"; -import { - FormErrors, - FormProvider, -} from "../../../../components/form/FormProvider.js"; -import { Input } from "../../../../components/form/Input.js"; -import { InputPaytoForm } from "../../../../components/form/InputPaytoForm.js"; -import { InputSelector } from "../../../../components/form/InputSelector.js"; -import { MerchantBackend } from "../../../../declaration.js"; -import { undefinedIfEmpty } from "../../../../utils/table.js"; - -type Entity = MerchantBackend.BankAccounts.AccountAddDetails & { repeatPassword: string }; - -interface Props { - onCreate: (d: Entity) => Promise; - onBack?: () => void; -} - -const accountAuthType = ["none", "basic"]; - -function isValidURL(s: string): boolean { - try { - const u = new URL(s) - return true; - } catch (e) { - return false; - } -} - -export function CreatePage({ onCreate, onBack }: Props): VNode { - const { i18n } = useTranslationContext(); - - const [state, setState] = useState>({}); - const errors: FormErrors = { - payto_uri: !state.payto_uri ? i18n.str`required` : undefined, - - credit_facade_credentials: !state.credit_facade_credentials - ? undefined - : undefinedIfEmpty({ - username: - state.credit_facade_credentials.type === "basic" && !state.credit_facade_credentials.username - ? i18n.str`required` - : undefined, - password: - state.credit_facade_credentials.type === "basic" && !state.credit_facade_credentials.password - ? i18n.str`required` - : undefined, - }), - credit_facade_url: !state.credit_facade_url - ? undefined - : !isValidURL(state.credit_facade_url) ? i18n.str`not valid url` - : undefined, - repeatPassword: - !state.credit_facade_credentials - ? undefined - : state.credit_facade_credentials.type === "basic" && (!state.credit_facade_credentials.password || state.credit_facade_credentials.password !== state.repeatPassword) - ? i18n.str`is not the same` - : undefined, - }; - - const hasErrors = Object.keys(errors).some( - (k) => (errors as any)[k] !== undefined, - ); - - const submitForm = () => { - if (hasErrors) return Promise.reject(); - delete state.repeatPassword - return onCreate(state as any); - }; - - return ( -
-
-
-
-
- - - name="payto_uri" - label={i18n.str`Account`} - /> - - name="credit_facade_url" - label={i18n.str`Account info URL`} - help="https://bank.com" - expand - tooltip={i18n.str`From where the merchant can download information about incoming wire transfers to this account`} - /> - { - if (str === "none") return "Without authentication"; - return "Username and password"; - }} - /> - {state.credit_facade_credentials?.type === "basic" ? ( - - - - - - ) : undefined} - - -
- {onBack && ( - - )} - - Confirm - -
-
-
-
-
-
- ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/accounts/create/index.tsx b/packages/auditor-backoffice-ui/src/paths/instance/accounts/create/index.tsx deleted file mode 100644 index ad5d025d6..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/accounts/create/index.tsx +++ /dev/null @@ -1,65 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { useTranslationContext } from "@gnu-taler/web-util/browser"; -import { Fragment, h, VNode } from "preact"; -import { useState } from "preact/hooks"; -import { NotificationCard } from "../../../../components/menu/index.js"; -import { MerchantBackend } from "../../../../declaration.js"; -import { useWebhookAPI } from "../../../../hooks/webhooks.js"; -import { Notification } from "../../../../utils/types.js"; -import { CreatePage } from "./CreatePage.js"; -import { useOtpDeviceAPI } from "../../../../hooks/otp.js"; -import { useBankAccountAPI } from "../../../../hooks/bank.js"; - -export type Entity = MerchantBackend.BankAccounts.AccountAddDetails; -interface Props { - onBack?: () => void; - onConfirm: () => void; -} - -export default function CreateValidator({ onConfirm, onBack }: Props): VNode { - const { createBankAccount } = useBankAccountAPI(); - const [notif, setNotif] = useState(undefined); - const { i18n } = useTranslationContext(); - - return ( - <> - - { - return createBankAccount(request) - .then((d) => { - onConfirm() - }) - .catch((error) => { - setNotif({ - message: i18n.str`could not create device`, - type: "ERROR", - description: error.message, - }); - }); - }} - /> - - ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/accounts/list/List.stories.tsx b/packages/auditor-backoffice-ui/src/paths/instance/accounts/list/List.stories.tsx deleted file mode 100644 index 18e762642..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/accounts/list/List.stories.tsx +++ /dev/null @@ -1,28 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { FunctionalComponent, h } from "preact"; -import { ListPage as TestedComponent } from "./ListPage.js"; - -export default { - title: "Pages/Accounts/List", - component: TestedComponent, -}; diff --git a/packages/auditor-backoffice-ui/src/paths/instance/accounts/list/ListPage.tsx b/packages/auditor-backoffice-ui/src/paths/instance/accounts/list/ListPage.tsx deleted file mode 100644 index 3359d1a95..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/accounts/list/ListPage.tsx +++ /dev/null @@ -1,64 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { h, VNode } from "preact"; -import { MerchantBackend } from "../../../../declaration.js"; -import { useTranslationContext } from "@gnu-taler/web-util/browser"; -import { CardTable } from "./Table.js"; - -export interface Props { - devices: MerchantBackend.BankAccounts.BankAccountEntry[]; - onLoadMoreBefore?: () => void; - onLoadMoreAfter?: () => void; - onCreate: () => void; - onDelete: (e: MerchantBackend.BankAccounts.BankAccountEntry) => void; - onSelect: (e: MerchantBackend.BankAccounts.BankAccountEntry) => void; -} - -export function ListPage({ - devices, - onCreate, - onDelete, - onSelect, - onLoadMoreBefore, - onLoadMoreAfter, -}: Props): VNode { - const form = { payto_uri: "" }; - - const { i18n } = useTranslationContext(); - return ( -
- ({ - ...o, - id: String(o.h_wire), - }))} - onCreate={onCreate} - onDelete={onDelete} - onSelect={onSelect} - onLoadMoreBefore={onLoadMoreBefore} - hasMoreBefore={!onLoadMoreBefore} - onLoadMoreAfter={onLoadMoreAfter} - hasMoreAfter={!onLoadMoreAfter} - /> -
- ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/accounts/list/Table.tsx b/packages/auditor-backoffice-ui/src/paths/instance/accounts/list/Table.tsx deleted file mode 100644 index 77e820e04..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/accounts/list/Table.tsx +++ /dev/null @@ -1,385 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { useTranslationContext } from "@gnu-taler/web-util/browser"; -import { Fragment, h, VNode } from "preact"; -import { StateUpdater, useState } from "preact/hooks"; -import { MerchantBackend } from "../../../../declaration.js"; -import { parsePaytoUri, PaytoType, PaytoUri, PaytoUriBitcoin, PaytoUriIBAN, PaytoUriTalerBank, PaytoUriUnknown } from "@gnu-taler/taler-util"; - -type Entity = MerchantBackend.BankAccounts.BankAccountEntry; - -interface Props { - accounts: Entity[]; - onDelete: (e: Entity) => void; - onSelect: (e: Entity) => void; - onCreate: () => void; - onLoadMoreBefore?: () => void; - hasMoreBefore?: boolean; - hasMoreAfter?: boolean; - onLoadMoreAfter?: () => void; -} - -export function CardTable({ - accounts, - onCreate, - onDelete, - onSelect, - onLoadMoreAfter, - onLoadMoreBefore, - hasMoreAfter, - hasMoreBefore, -}: Props): VNode { - const [rowSelection, rowSelectionHandler] = useState([]); - - const { i18n } = useTranslationContext(); - - return ( -
-
-

- - - - Bank accounts -

-
- - - -
-
-
-
-
- {accounts.length > 0 ? ( - - ) : ( - - )} - - - - - ); -} -interface TableProps { - rowSelection: string[]; - accounts: Entity[]; - onDelete: (e: Entity) => void; - onSelect: (e: Entity) => void; - rowSelectionHandler: StateUpdater; - onLoadMoreBefore?: () => void; - hasMoreBefore?: boolean; - hasMoreAfter?: boolean; - onLoadMoreAfter?: () => void; -} - -function toggleSelected(id: T): (prev: T[]) => T[] { - return (prev: T[]): T[] => - prev.indexOf(id) == -1 ? [...prev, id] : prev.filter((e) => e != id); -} - -function Table({ - accounts, - onLoadMoreAfter, - onDelete, - onSelect, - onLoadMoreBefore, - hasMoreAfter, - hasMoreBefore, -}: TableProps): VNode { - const { i18n } = useTranslationContext(); - const emptyList: Record = { "bitcoin": [], "x-taler-bank": [], "iban": [], "unknown": [], } - const accountsByType = accounts.reduce((prev, acc) => { - const parsed = parsePaytoUri(acc.payto_uri) - if (!parsed) return prev //skip - if (parsed.targetType !== "bitcoin" && parsed.targetType !== "x-taler-bank" && parsed.targetType !== "iban") { - prev["unknown"].push({ parsed, acc }) - } else { - prev[parsed.targetType].push({ parsed, acc }) - } - return prev - }, emptyList) - - const bitcoinAccounts = accountsByType["bitcoin"] - const talerbankAccounts = accountsByType["x-taler-bank"] - const ibanAccounts = accountsByType["iban"] - const unkownAccounts = accountsByType["unknown"] - - - return ( - - - {bitcoinAccounts.length > 0 &&
-

Bitcoin type accounts

-
- - - - - - - - - {bitcoinAccounts.map(({ parsed, acc }, idx) => { - const ac = parsed as PaytoUriBitcoin - return ( - - - - - - - ); - })} - -
- Address - - Sewgit 1 - - Sewgit 2 - -
onSelect(acc)} - style={{ cursor: "pointer" }} - > - {ac.targetPath} - onSelect(acc)} - style={{ cursor: "pointer" }} - > - {ac.segwitAddrs[0]} - onSelect(acc)} - style={{ cursor: "pointer" }} - > - {ac.segwitAddrs[1]} - -
- -
-
-
} - - - - {talerbankAccounts.length > 0 &&
-

Taler type accounts

- - - - - - - - - {talerbankAccounts.map(({ parsed, acc }, idx) => { - const ac = parsed as PaytoUriTalerBank - return ( - - - - - - ); - })} - -
- Host - - Account name - -
onSelect(acc)} - style={{ cursor: "pointer" }} - > - {ac.host} - onSelect(acc)} - style={{ cursor: "pointer" }} - > - {ac.account} - -
- -
-
-
} - - {ibanAccounts.length > 0 &&
-

IBAN type accounts

- - - - - - - - - - {ibanAccounts.map(({ parsed, acc }, idx) => { - const ac = parsed as PaytoUriIBAN - return ( - - - - - - - ); - })} - -
- Account name - - IBAN - - BIC - -
onSelect(acc)} - style={{ cursor: "pointer" }} - > - {ac.params["receiver-name"]} - onSelect(acc)} - style={{ cursor: "pointer" }} - > - {ac.iban} - onSelect(acc)} - style={{ cursor: "pointer" }} - > - {ac.bic ?? ""} - -
- -
-
-
} - - {unkownAccounts.length > 0 &&
-

Other type accounts

- - - - - - - - - {unkownAccounts.map(({ parsed, acc }, idx) => { - const ac = parsed as PaytoUriUnknown - return ( - - - - - - ); - })} - -
- Type - - Path - -
onSelect(acc)} - style={{ cursor: "pointer" }} - > - {ac.targetType} - onSelect(acc)} - style={{ cursor: "pointer" }} - > - {ac.targetPath} - -
- -
-
-
} - - - ); -} - -function EmptyTable(): VNode { - const { i18n } = useTranslationContext(); - return ( -
-

- - - -

-

- - There is no accounts yet, add more pressing the + sign - -

-
- ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/accounts/list/index.tsx b/packages/auditor-backoffice-ui/src/paths/instance/accounts/list/index.tsx deleted file mode 100644 index cbe03d660..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/accounts/list/index.tsx +++ /dev/null @@ -1,107 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { HttpStatusCode } from "@gnu-taler/taler-util"; -import { - ErrorType, - HttpError, - useTranslationContext, -} from "@gnu-taler/web-util/browser"; -import { Fragment, VNode, h } from "preact"; -import { useState } from "preact/hooks"; -import { Loading } from "../../../../components/exception/loading.js"; -import { NotificationCard } from "../../../../components/menu/index.js"; -import { MerchantBackend } from "../../../../declaration.js"; -import { useInstanceOtpDevices, useOtpDeviceAPI } from "../../../../hooks/otp.js"; -import { Notification } from "../../../../utils/types.js"; -import { ListPage } from "./ListPage.js"; -import { useBankAccountAPI, useInstanceBankAccounts } from "../../../../hooks/bank.js"; - -interface Props { - onUnauthorized: () => VNode; - onLoadError: (error: HttpError) => VNode; - onNotFound: () => VNode; - onCreate: () => void; - onSelect: (id: string) => void; -} - -export default function ListOtpDevices({ - onUnauthorized, - onLoadError, - onCreate, - onSelect, - onNotFound, -}: Props): VNode { - const [position, setPosition] = useState(undefined); - const { i18n } = useTranslationContext(); - const [notif, setNotif] = useState(undefined); - const { deleteBankAccount } = useBankAccountAPI(); - const result = useInstanceBankAccounts({ position }, (id) => setPosition(id)); - - if (result.loading) return ; - if (!result.ok) { - if ( - result.type === ErrorType.CLIENT && - result.status === HttpStatusCode.Unauthorized - ) - return onUnauthorized(); - if ( - result.type === ErrorType.CLIENT && - result.status === HttpStatusCode.NotFound - ) - return onNotFound(); - return onLoadError(result); - } - - return ( - - - - { - onSelect(e.h_wire); - }} - onDelete={(e: MerchantBackend.BankAccounts.BankAccountEntry) => - deleteBankAccount(e.h_wire) - .then(() => - setNotif({ - message: i18n.str`bank account delete successfully`, - type: "SUCCESS", - }), - ) - .catch((error) => - setNotif({ - message: i18n.str`could not delete the bank account`, - type: "ERROR", - description: error.message, - }), - ) - } - /> - - ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/accounts/update/Update.stories.tsx b/packages/auditor-backoffice-ui/src/paths/instance/accounts/update/Update.stories.tsx deleted file mode 100644 index 06ea9d07a..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/accounts/update/Update.stories.tsx +++ /dev/null @@ -1,32 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { h, VNode, FunctionalComponent } from "preact"; -import { UpdatePage as TestedComponent } from "./UpdatePage.js"; - -export default { - title: "Pages/OtpDevices/Update", - component: TestedComponent, - argTypes: { - onUpdate: { action: "onUpdate" }, - onBack: { action: "onBack" }, - }, -}; diff --git a/packages/auditor-backoffice-ui/src/paths/instance/accounts/update/UpdatePage.tsx b/packages/auditor-backoffice-ui/src/paths/instance/accounts/update/UpdatePage.tsx deleted file mode 100644 index 4efb822a3..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/accounts/update/UpdatePage.tsx +++ /dev/null @@ -1,195 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { useTranslationContext } from "@gnu-taler/web-util/browser"; -import { Fragment, h, VNode } from "preact"; -import { useState } from "preact/hooks"; -import { AsyncButton } from "../../../../components/exception/AsyncButton.js"; -import { - FormErrors, - FormProvider, -} from "../../../../components/form/FormProvider.js"; -import { Input } from "../../../../components/form/Input.js"; -import { MerchantBackend, WithId } from "../../../../declaration.js"; -import { InputSelector } from "../../../../components/form/InputSelector.js"; -import { InputPaytoForm } from "../../../../components/form/InputPaytoForm.js"; -import { undefinedIfEmpty } from "../../../../utils/table.js"; - -type Entity = MerchantBackend.BankAccounts.BankAccountEntry - & WithId; - -const accountAuthType = ["unedit", "none", "basic"]; -interface Props { - onUpdate: (d: MerchantBackend.BankAccounts.AccountPatchDetails) => Promise; - onBack?: () => void; - account: Entity; -} - - -export function UpdatePage({ account, onUpdate, onBack }: Props): VNode { - const { i18n } = useTranslationContext(); - - const [state, setState] = useState>(account); - - const errors: FormErrors = { - credit_facade_url: !state.credit_facade_url ? i18n.str`required` : !isValidURL(state.credit_facade_url) ? i18n.str`invalid url` : undefined, - credit_facade_credentials: undefinedIfEmpty({ - - username: state.credit_facade_credentials?.type !== "basic" ? undefined - : !state.credit_facade_credentials.username ? i18n.str`required` : undefined, - - password: state.credit_facade_credentials?.type !== "basic" ? undefined - : !state.credit_facade_credentials.password ? i18n.str`required` : undefined, - - repeatPassword: state.credit_facade_credentials?.type !== "basic" ? undefined - : !(state.credit_facade_credentials as any).repeatPassword ? i18n.str`required` : - (state.credit_facade_credentials as any).repeatPassword !== state.credit_facade_credentials.password ? i18n.str`doesn't match` - : undefined, - }), - }; - - const hasErrors = Object.keys(errors).some( - (k) => (errors as any)[k] !== undefined, - ); - - const submitForm = () => { - if (hasErrors) return Promise.reject(); - - const creds: typeof state.credit_facade_credentials = - state.credit_facade_credentials?.type === "basic" ? { - type: "basic", - password: state.credit_facade_credentials.password, - username: state.credit_facade_credentials.username, - } : state.credit_facade_credentials?.type === "none" ? { - type: "none" - } : undefined; - - return onUpdate({ - credit_facade_credentials: creds, - credit_facade_url: state.credit_facade_url, - }); - }; - - return ( -
-
-
-
-
-
-
- - Account: {account.id.substring(0, 8)}... - -
-
-
-
-
-
- -
-
-
- - - name="payto_uri" - label={i18n.str`Account`} - readonly - /> - - name="credit_facade_url" - label={i18n.str`Account info URL`} - help="https://bank.com" - expand - tooltip={i18n.str`From where the merchant can download information about incoming wire transfers to this account`} - /> - { - if (str === "none") return "Without authentication"; - if (str === "basic") return "With authentication"; - return "Do not change" - }} - /> - {state.credit_facade_credentials?.type === "basic" ? ( - - - - - - ) : undefined} - - -
- {onBack && ( - - )} - - Confirm - -
-
-
-
-
-
- ); -} - -function isValidURL(s: string): boolean { - try { - const u = new URL(s) - return true; - } catch (e) { - return false; - } -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/accounts/update/index.tsx b/packages/auditor-backoffice-ui/src/paths/instance/accounts/update/index.tsx deleted file mode 100644 index ca0b692a3..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/accounts/update/index.tsx +++ /dev/null @@ -1,96 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { HttpStatusCode } from "@gnu-taler/taler-util"; -import { - ErrorType, - HttpError, - useTranslationContext, -} from "@gnu-taler/web-util/browser"; -import { Fragment, VNode, h } from "preact"; -import { useState } from "preact/hooks"; -import { Loading } from "../../../../components/exception/loading.js"; -import { NotificationCard } from "../../../../components/menu/index.js"; -import { MerchantBackend, WithId } from "../../../../declaration.js"; -import { useBankAccountAPI, useBankAccountDetails } from "../../../../hooks/bank.js"; -import { Notification } from "../../../../utils/types.js"; -import { UpdatePage } from "./UpdatePage.js"; - -export type Entity = MerchantBackend.BankAccounts.AccountPatchDetails & WithId; - -interface Props { - onBack?: () => void; - onConfirm: () => void; - onUnauthorized: () => VNode; - onNotFound: () => VNode; - onLoadError: (e: HttpError) => VNode; - bid: string; -} -export default function UpdateValidator({ - bid, - onConfirm, - onBack, - onUnauthorized, - onNotFound, - onLoadError, -}: Props): VNode { - const { updateBankAccount } = useBankAccountAPI(); - const result = useBankAccountDetails(bid); - const [notif, setNotif] = useState(undefined); - - const { i18n } = useTranslationContext(); - - if (result.loading) return ; - if (!result.ok) { - if ( - result.type === ErrorType.CLIENT && - result.status === HttpStatusCode.Unauthorized - ) - return onUnauthorized(); - if ( - result.type === ErrorType.CLIENT && - result.status === HttpStatusCode.NotFound - ) - return onNotFound(); - return onLoadError(result); - } - - return ( - - - { - return updateBankAccount(bid, data) - .then(onConfirm) - .catch((error) => { - setNotif({ - message: i18n.str`could not update account`, - type: "ERROR", - description: error.message, - }); - }); - }} - /> - - ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/Create.stories.tsx b/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/Create.stories.tsx deleted file mode 100644 index 22bbfe28a..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/Create.stories.tsx +++ /dev/null @@ -1,43 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { h, VNode, FunctionalComponent } from "preact"; -import { CreatePage as TestedComponent } from "./CreatePage.js"; - -export default { - title: "Pages/Product/Create", - component: TestedComponent, - argTypes: { - onCreate: { action: "onCreate" }, - onBack: { action: "onBack" }, - }, -}; - -function createExample( - Component: FunctionalComponent, - props: Partial, -) { - const r = (args: any) => ; - r.args = props; - return r; -} - -export const Example = createExample(TestedComponent, {}); diff --git a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/CreatePage.tsx b/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/CreatePage.tsx deleted file mode 100644 index 6cbc26d8d..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/CreatePage.tsx +++ /dev/null @@ -1,80 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { useTranslationContext } from "@gnu-taler/web-util/browser"; -import { h, VNode } from "preact"; -import { AsyncButton } from "../../../../components/exception/AsyncButton.js"; -import { ProductForm } from "../../../../components/product/ProductForm.js"; -import { MerchantBackend } from "../../../../declaration.js"; -import { useListener } from "../../../../hooks/listener.js"; - -type Entity = MerchantBackend.Products.ProductAddDetail & { - product_id: string; -}; - -interface Props { - onCreate: (d: Entity) => Promise; - onBack?: () => void; -} - -export function CreatePage({ onCreate, onBack }: Props): VNode { - const [submitForm, addFormSubmitter] = useListener( - (result) => { - if (result) return onCreate(result); - return Promise.reject(); - }, - ); - - const { i18n } = useTranslationContext(); - - return ( -
-
-
-
-
- - -
- {onBack && ( - - )} - - Confirm - -
-
-
-
-
-
- ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/CreatedSuccessfully.tsx b/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/CreatedSuccessfully.tsx deleted file mode 100644 index 4f7da26da..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/CreatedSuccessfully.tsx +++ /dev/null @@ -1,69 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 { h, VNode } from "preact"; -import { CreatedSuccessfully as Template } from "../../../../components/notifications/CreatedSuccessfully.js"; -import { Entity } from "./index.js"; -import emptyImage from "../../assets/empty.png"; - -interface Props { - entity: Entity; - onConfirm: () => void; - onCreateAnother?: () => void; -} - -export function CreatedSuccessfully({ - entity, - onConfirm, - onCreateAnother, -}: Props): VNode { - return ( - - ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/index.tsx b/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/index.tsx deleted file mode 100644 index d537f6bf0..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/create/index.tsx +++ /dev/null @@ -1,46 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { useTranslationContext } from "@gnu-taler/web-util/browser"; -import { Fragment, h, VNode } from "preact"; -import { useState } from "preact/hooks"; -import { NotificationCard } from "../../../../components/menu/index.js"; -import { AuditorBackend } from "../../../../declaration.js"; -import { useDepositConfirmationAPI } from "../../../../hooks/deposit_confirmations.js"; -import { Notification } from "../../../../utils/types.js"; -import { CreatePage } from "./CreatePage.js"; - -export type Entity = AuditorBackend.DepositConfirmation.DepositConfirmationDetail; -interface Props { - onBack?: () => void; - onConfirm: () => void; -} -export default function CreateProduct({ onConfirm, onBack }: Props): VNode { - const { createDepositConfirmation } = useDepositConfirmationAPI(); - const [notif, setNotif] = useState(undefined); - const { i18n } = useTranslationContext(); - - return ( - - - - ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/List.stories.tsx b/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/List.stories.tsx deleted file mode 100644 index f4368293b..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/List.stories.tsx +++ /dev/null @@ -1,43 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { h, VNode, FunctionalComponent } from "preact"; -import { CardTable as TestedComponent } from "./Table.js"; - -export default { - title: "Pages/Product/List", - component: TestedComponent, - argTypes: { - onCreate: { action: "onCreate" }, - onSelect: { action: "onSelect" }, - onDelete: { action: "onDelete" }, - onUpdate: { action: "onUpdate" }, - }, -}; - -function createExample( - Component: FunctionalComponent, - props: Partial, -) { - const r = (args: any) => ; - r.args = props; - return r; -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/Table.tsx b/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/Table.tsx deleted file mode 100644 index e71b1eeaa..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/list/Table.tsx +++ /dev/null @@ -1,249 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { Amounts } from "@gnu-taler/taler-util"; -import { useTranslationContext } from "@gnu-taler/web-util/browser"; -import { format } from "date-fns"; -import { ComponentChildren, Fragment, h, VNode } from "preact"; -import { StateUpdater, useState } from "preact/hooks"; -import emptyImage from "../../../../assets/empty.png"; -import { - FormErrors, - FormProvider, -} from "../../../../components/form/FormProvider.js"; -import { InputCurrency } from "../../../../components/form/InputCurrency.js"; -import { InputNumber } from "../../../../components/form/InputNumber.js"; -import { AuditorBackend, WithId } from "../../../../declaration.js"; -import { dateFormatForSettings, useSettings } from "../../../../hooks/useSettings.js"; - -type Entity = AuditorBackend.DepositConfirmation.DepositConfirmationDetail & WithId; - -interface Props { - instances: Entity[]; - onDelete: (id: Entity) => void; - onSelect: (depositConfirmation: Entity) => void; - onUpdate: ( - id: string, - data: AuditorBackend.DepositConfirmation.DepositConfirmationDetail, - ) => Promise; - onCreate: () => void; - selected?: boolean; -} - -export function CardTable({ - instances, - onCreate, - onSelect, - onUpdate, - onDelete, -}: Props): VNode { - const [rowSelection, rowSelectionHandler] = useState( - undefined, - ); - const { i18n } = useTranslationContext(); - return ( -
-
-

- - - - Deposit Confirmations -

-
- - - -
-
-
-
-
- {instances.length > 0 ? ( - - ) : ( - - )} - - - - - ); -} -interface TableProps { - rowSelection: string | undefined; - instances: Entity[]; - onSelect: (id: Entity) => void; - onUpdate: ( - id: string, - data: AuditorBackend.DepositConfirmation.DepositConfirmationDetail, - ) => Promise; - onDelete: (serial_id: Entity) => void; - rowSelectionHandler: StateUpdater; -} - -function Table({ - rowSelection, - rowSelectionHandler, - instances, - onSelect, - onUpdate, - onDelete, -}: TableProps): VNode { - const { i18n } = useTranslationContext(); - const [settings] = useSettings(); - return ( -
-
- - - - - - - - - - - - - {instances.map((i) => { - - return ( - - - - - - - {rowSelection === i.id && ( - - - - )} - - ); - })} - -
- Image - - Description - - Price per unit - - Taxes - - Sales - - Stock - - Sold - -
- rowSelection !== i.id && rowSelectionHandler(i.id) - } - style={{ cursor: "pointer" }} - > - -
- - - - - - -
-
-
-
- ); -} - -interface FastProductUpdate { - incoming: number; - lost: number; - price: string; -} -interface UpdatePrice { - price: string; -} - - - -function EmptyTable(): VNode { - const { i18n } = useTranslationContext(); - return ( -
-

- - - -

-

- - There is no products yet, add more pressing the + sign - -

-
- ); -} - -function difference(price: string, tax: number) { - if (!tax) return price; - const ps = price.split(":"); - const p = parseInt(ps[1], 10); - ps[1] = `${p - tax}`; - return ps.join(":"); -} \ No newline at end of file diff --git a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/update/Update.stories.tsx b/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/update/Update.stories.tsx deleted file mode 100644 index d1dc9d540..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/update/Update.stories.tsx +++ /dev/null @@ -1,73 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { h, VNode, FunctionalComponent } from "preact"; -import { UpdatePage as TestedComponent } from "./UpdatePage.js"; - -export default { - title: "Pages/Product/Update", - component: TestedComponent, - argTypes: { - onUpdate: { action: "onUpdate" }, - onBack: { action: "onBack" }, - }, -}; - -function createExample( - Component: FunctionalComponent, - props: Partial, -) { - const r = (args: any) => ; - r.args = props; - return r; -} - -export const WithManagedStock = createExample(TestedComponent, { - product: { - product_id: "20102-ASDAS-QWE", - description: "description1", - description_i18n: {} as any, - image: "", - price: "TESTKUDOS:10", - taxes: [], - total_lost: 10, - total_sold: 5, - total_stock: 15, - unit: "bar", - address: {}, - }, -}); - -export const WithInfiniteStock = createExample(TestedComponent, { - product: { - product_id: "20102-ASDAS-QWE", - description: "description1", - description_i18n: {} as any, - image: "", - price: "TESTKUDOS:10", - taxes: [], - total_lost: 10, - total_sold: 5, - total_stock: -1, - unit: "bar", - address: {}, - }, -}); diff --git a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/update/UpdatePage.tsx b/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/update/UpdatePage.tsx deleted file mode 100644 index 53aa9d61f..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/deposit_confirmations/update/UpdatePage.tsx +++ /dev/null @@ -1,99 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { useTranslationContext } from "@gnu-taler/web-util/browser"; -import { h, VNode } from "preact"; -import { AsyncButton } from "../../../../components/exception/AsyncButton.js"; -import { ProductForm } from "../../../../components/product/ProductForm.js"; -import { MerchantBackend } from "../../../../declaration.js"; -import { useListener } from "../../../../hooks/listener.js"; - -type Entity = MerchantBackend.Products.ProductDetail & { product_id: string }; - -interface Props { - onUpdate: (d: Entity) => Promise; - onBack?: () => void; - product: Entity; -} - -export function UpdatePage({ product, onUpdate, onBack }: Props): VNode { - const [submitForm, addFormSubmitter] = useListener( - (result) => { - if (result) return onUpdate(result); - return Promise.resolve(); - }, - ); - - const { i18n } = useTranslationContext(); - - return ( -
-
-
-
-
-
-
- - Product id: - {product.product_id} - -
-
-
-
-
-
- -
-
-
- - -
- {onBack && ( - - )} - - Confirm - -
-
-
-
-
-
- ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/details/DetailPage.tsx b/packages/auditor-backoffice-ui/src/paths/instance/details/DetailPage.tsx deleted file mode 100644 index 6e9b51106..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/details/DetailPage.tsx +++ /dev/null @@ -1,83 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { useTranslationContext } from "@gnu-taler/web-util/browser"; -import { h, VNode } from "preact"; -import { useState } from "preact/hooks"; -import { FormProvider } from "../../../components/form/FormProvider.js"; -import { Input } from "../../../components/form/Input.js"; -import { MerchantBackend } from "../../../declaration.js"; - -type Entity = MerchantBackend.Instances.InstanceReconfigurationMessage; -interface Props { - onUpdate: () => void; - onDelete: () => void; - selected: MerchantBackend.Instances.QueryInstancesResponse; -} - -function convert( - from: MerchantBackend.Instances.QueryInstancesResponse, -): Entity { - const defaults = { - default_wire_fee_amortization: 1, - use_stefan: true, - default_pay_delay: { d_us: 1000 * 60 * 60 * 1000 }, //one hour - default_wire_transfer_delay: { d_us: 1000 * 60 * 60 * 2 * 1000 }, //two hours - }; - return { ...defaults, ...from }; -} - -export function DetailPage({ selected }: Props): VNode { - const [value, valueHandler] = useState>(convert(selected)); - - const { i18n } = useTranslationContext(); - - return ( -
-
-
-
-
-
-

Here goes the instance description

-
-
- -
-
- -
-
-
-
- object={value} valueHandler={valueHandler}> - name="name" readonly label={i18n.str`Name`} /> - -
-
-
-
-
- ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/details/index.tsx b/packages/auditor-backoffice-ui/src/paths/instance/details/index.tsx deleted file mode 100644 index 13dd3a2f6..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/details/index.tsx +++ /dev/null @@ -1,87 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 { ErrorType, HttpError } from "@gnu-taler/web-util/browser"; -import { Fragment, h, VNode } from "preact"; -import { useState } from "preact/hooks"; -import { Loading } from "../../../components/exception/loading.js"; -import { DeleteModal } from "../../../components/modal/index.js"; -import { useInstanceContext } from "../../../context/instance.js"; -import { MerchantBackend } from "../../../declaration.js"; -import { useInstanceAPI, useInstanceDetails } from "../../../hooks/instance.js"; -import { DetailPage } from "./DetailPage.js"; -import { HttpStatusCode } from "@gnu-taler/taler-util"; - -interface Props { - onUnauthorized: () => VNode; - onLoadError: (error: HttpError) => VNode; - onUpdate: () => void; - onNotFound: () => VNode; - onDelete: () => void; -} - -export default function Detail({ - onUpdate, - onLoadError, - onUnauthorized, - onDelete, - onNotFound, -}: Props): VNode { - const { id } = useInstanceContext(); - const result = useInstanceDetails(); - const [deleting, setDeleting] = useState(false); - - const { deleteInstance } = useInstanceAPI(); - - if (result.loading) return ; - if (!result.ok) { - if ( - result.type === ErrorType.CLIENT && - result.status === HttpStatusCode.Unauthorized - ) - return onUnauthorized(); - if ( - result.type === ErrorType.CLIENT && - result.status === HttpStatusCode.NotFound - ) - return onNotFound(); - return onLoadError(result); - } - - return ( - - setDeleting(true)} - /> - {deleting && ( - setDeleting(false)} - onConfirm={async (): Promise => { - try { - await deleteInstance(); - onDelete(); - } catch (error) { - //FIXME: show message error - } - setDeleting(false); - }} - /> - )} - - ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/details/stories.tsx b/packages/auditor-backoffice-ui/src/paths/instance/details/stories.tsx deleted file mode 100644 index fa6e9d763..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/details/stories.tsx +++ /dev/null @@ -1,68 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { h, VNode, FunctionalComponent } from "preact"; -import { ConfigContextProvider } from "../../../context/config.js"; -import { DetailPage as TestedComponent } from "./DetailPage.js"; - -export default { - title: "Pages/Instance/Detail", - component: TestedComponent, - argTypes: { - onUpdate: { action: "onUpdate" }, - onBack: { action: "onBack" }, - }, -}; - -function createExample( - Internal: FunctionalComponent, - props: Partial, -) { - const component = (args: any) => ( - - - - ); - return { component, props }; -} - -export const Example = createExample(TestedComponent, { - selected: { - name: "name", - auth: { method: "external" }, - address: {}, - user_type: "business", - jurisdiction: {}, - use_stefan: true, - default_pay_delay: { - d_us: 1000 * 1000, //one second - }, - default_wire_transfer_delay: { - d_us: 1000 * 1000, //one second - }, - merchant_pub: "ASDWQEKASJDKSADJ", - }, -}); diff --git a/packages/auditor-backoffice-ui/src/paths/instance/index.stories.ts b/packages/auditor-backoffice-ui/src/paths/instance/index.stories.ts deleted file mode 100644 index cd8f3d11c..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/index.stories.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -export * as details from "./details/stories.js"; -export * as kycList from "./kyc/list/ListPage.stories.js"; -export * as reserve from "./reserves/create/CreatedSuccessfully.stories.js"; diff --git a/packages/auditor-backoffice-ui/src/paths/instance/kyc/list/ListPage.stories.tsx b/packages/auditor-backoffice-ui/src/paths/instance/kyc/list/ListPage.stories.tsx deleted file mode 100644 index a914639e5..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/kyc/list/ListPage.stories.tsx +++ /dev/null @@ -1,58 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { h, VNode, FunctionalComponent } from "preact"; -import { ListPage as TestedComponent } from "./ListPage.js"; -import * as tests from "@gnu-taler/web-util/testing"; -import { MerchantBackend } from "../../../../declaration.js"; - -export default { - title: "Pages/KYC/List", - component: TestedComponent, - argTypes: { - onUpdate: { action: "onUpdate" }, - onBack: { action: "onBack" }, - }, -}; - -export const Example = tests.createExample(TestedComponent, { - status: { - timeout_kycs: [], - pending_kycs: [ - { - aml_status: 0, - exchange_url: "http://exchange.taler", - payto_uri: "payto://iban/de123123123", - kyc_url: "http://exchange.taler/kyc", - }, - { - aml_status: 1, - exchange_url: "http://exchange.taler", - payto_uri: "payto://iban/de123123123", - }, - { - aml_status: 2, - exchange_url: "http://exchange.taler", - payto_uri: "payto://iban/de123123123", - }, - ], - } as MerchantBackend.KYC.AccountKycRedirects, -}); diff --git a/packages/auditor-backoffice-ui/src/paths/instance/kyc/list/ListPage.tsx b/packages/auditor-backoffice-ui/src/paths/instance/kyc/list/ListPage.tsx deleted file mode 100644 index 2ec0137d9..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/kyc/list/ListPage.tsx +++ /dev/null @@ -1,208 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { useTranslationContext } from "@gnu-taler/web-util/browser"; -import { h, VNode } from "preact"; -import { MerchantBackend } from "../../../../declaration.js"; - -export interface Props { - status: MerchantBackend.KYC.AccountKycRedirects; -} - -export function ListPage({ status }: Props): VNode { - const { i18n } = useTranslationContext(); - - return ( -
-
-
-

- - - - Pending KYC verification -

- -
-
-
-
-
- {status.pending_kycs.length > 0 ? ( - - ) : ( - - )} -
-
-
-
- - {status.timeout_kycs.length > 0 ? ( -
-
-

- - - - Timed out -

- -
-
-
-
-
- {status.timeout_kycs.length > 0 ? ( - - ) : ( - - )} -
-
-
-
- ) : undefined} -
- ); -} -interface PendingTableProps { - entries: MerchantBackend.KYC.MerchantAccountKycRedirect[]; -} - -interface TimedOutTableProps { - entries: MerchantBackend.KYC.ExchangeKycTimeout[]; -} - -function PendingTable({ entries }: PendingTableProps): VNode { - const { i18n } = useTranslationContext(); - return ( -
- - - - - - - - - - {entries.map((e, i) => { - if (e.kyc_url === undefined) { - // blocked by AML - return ( - - - - - - ); - } else { - // blocked by KYC - return ( - - - - - - ); - } - })} - -
- Exchange - - Target account - - Reason -
{e.exchange_url}{e.payto_uri} - {e.aml_status === 1 ? ( - - There is an anti-money laundering process pending to - complete. - - ) : ( - - The account is frozen due to the anti-money laundering - rules. Contact the exchange service provider for further - instructions. - - )} -
{e.exchange_url}{e.payto_uri} - - - Pending KYC process, click here to complete - - -
-
- ); -} - -function TimedOutTable({ entries }: TimedOutTableProps): VNode { - const { i18n } = useTranslationContext(); - return ( -
- - - - - - - - - - {entries.map((e, i) => { - return ( - - - - - - ); - })} - -
- Exchange - - Code - - Http Status -
{e.exchange_url}{e.exchange_code}{e.exchange_http_status}
-
- ); -} - -function EmptyTable(): VNode { - const { i18n } = useTranslationContext(); - return ( -
-

- - - -

-

- No pending kyc verification! -

-
- ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/kyc/list/index.tsx b/packages/auditor-backoffice-ui/src/paths/instance/kyc/list/index.tsx deleted file mode 100644 index 664f05f66..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/kyc/list/index.tsx +++ /dev/null @@ -1,63 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { ErrorType, HttpError } from "@gnu-taler/web-util/browser"; -import { h, VNode } from "preact"; -import { Loading } from "../../../../components/exception/loading.js"; -import { MerchantBackend } from "../../../../declaration.js"; -import { useInstanceKYCDetails } from "../../../../hooks/instance.js"; -import { ListPage } from "./ListPage.js"; -import { HttpStatusCode } from "@gnu-taler/taler-util"; - -interface Props { - onUnauthorized: () => VNode; - onLoadError: (error: HttpError) => VNode; - onNotFound: () => VNode; -} - -export default function ListKYC({ - onUnauthorized, - onLoadError, - onNotFound, -}: Props): VNode { - const result = useInstanceKYCDetails(); - if (result.loading) return ; - if (!result.ok) { - if ( - result.type === ErrorType.CLIENT && - result.status === HttpStatusCode.Unauthorized - ) - return onUnauthorized(); - if ( - result.type === ErrorType.CLIENT && - result.status === HttpStatusCode.NotFound - ) - return onNotFound(); - return onLoadError(result); - } - - const status = result.data.type === "ok" ? undefined : result.data.status; - - if (!status) { - return
no kyc required
; - } - return ; -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/orders/create/Create.stories.tsx b/packages/auditor-backoffice-ui/src/paths/instance/orders/create/Create.stories.tsx deleted file mode 100644 index fc814b68f..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/orders/create/Create.stories.tsx +++ /dev/null @@ -1,71 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { h, VNode, FunctionalComponent } from "preact"; -import { CreatePage as TestedComponent } from "./CreatePage.js"; - -export default { - title: "Pages/Order/Create", - component: TestedComponent, - argTypes: { - onCreate: { action: "onCreate" }, - goBack: { action: "goBack" }, - }, -}; - -function createExample( - Component: FunctionalComponent, - props: Partial, -) { - const r = (args: any) => ; - r.args = props; - return r; -} - -export const Example = createExample(TestedComponent, { - instanceConfig: { - default_pay_delay: { - d_us: 1000 * 1000 * 60 * 60, //one hour - }, - default_wire_transfer_delay: { - d_us: 1000 * 1000 * 60 * 60, //one hour - }, - use_stefan: true, - }, - instanceInventory: [ - { - id: "t-shirt-1", - description: "a m size t-shirt", - price: "TESTKUDOS:1", - total_stock: -1, - }, - { - id: "t-shirt-2", - price: "TESTKUDOS:1", - description: "a xl size t-shirt", - } as any, - { - id: "t-shirt-3", - price: "TESTKUDOS:1", - description: "a s size t-shirt", - } as any, - ], -}); diff --git a/packages/auditor-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx b/packages/auditor-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx deleted file mode 100644 index 92271f52f..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx +++ /dev/null @@ -1,705 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { AbsoluteTime, Amounts, Duration, TalerProtocolDuration } from "@gnu-taler/taler-util"; -import { useTranslationContext } from "@gnu-taler/web-util/browser"; -import { format, isFuture } from "date-fns"; -import { ComponentChildren, Fragment, VNode, h } from "preact"; -import { useEffect, useState } from "preact/hooks"; -import { - FormErrors, - FormProvider, -} from "../../../../components/form/FormProvider.js"; -import { Input } from "../../../../components/form/Input.js"; -import { InputCurrency } from "../../../../components/form/InputCurrency.js"; -import { InputDate } from "../../../../components/form/InputDate.js"; -import { InputDuration } from "../../../../components/form/InputDuration.js"; -import { InputGroup } from "../../../../components/form/InputGroup.js"; -import { InputLocation } from "../../../../components/form/InputLocation.js"; -import { InputNumber } from "../../../../components/form/InputNumber.js"; -import { InputToggle } from "../../../../components/form/InputToggle.js"; -import { InventoryProductForm } from "../../../../components/product/InventoryProductForm.js"; -import { NonInventoryProductFrom } from "../../../../components/product/NonInventoryProductForm.js"; -import { ProductList } from "../../../../components/product/ProductList.js"; -import { useConfigContext } from "../../../../context/config.js"; -import { MerchantBackend, WithId } from "../../../../declaration.js"; -import { useSettings } from "../../../../hooks/useSettings.js"; -import { OrderCreateSchema as schema } from "../../../../schemas/index.js"; -import { rate } from "../../../../utils/amount.js"; -import { undefinedIfEmpty } from "../../../../utils/table.js"; - -interface Props { - onCreate: (d: MerchantBackend.Orders.PostOrderRequest) => void; - onBack?: () => void; - instanceConfig: InstanceConfig; - instanceInventory: (MerchantBackend.Products.ProductDetail & WithId)[]; -} -interface InstanceConfig { - use_stefan: boolean; - default_pay_delay: TalerProtocolDuration; - default_wire_transfer_delay: TalerProtocolDuration; -} - -function with_defaults(config: InstanceConfig, currency: string): Partial { - const defaultPayDeadline = Duration.fromTalerProtocolDuration(config.default_pay_delay); - const defaultWireDeadline = Duration.fromTalerProtocolDuration(config.default_wire_transfer_delay); - - return { - inventoryProducts: {}, - products: [], - pricing: {}, - payments: { - max_fee: undefined, - createToken: true, - pay_deadline: (defaultPayDeadline), - refund_deadline: (defaultPayDeadline), - wire_transfer_deadline: (defaultWireDeadline), - }, - shipping: {}, - extra: {}, - }; -} - -interface ProductAndQuantity { - product: MerchantBackend.Products.ProductDetail & WithId; - quantity: number; -} -export interface ProductMap { - [id: string]: ProductAndQuantity; -} - -interface Pricing { - products_price: string; - order_price: string; - summary: string; -} -interface Shipping { - delivery_date?: Date; - delivery_location?: MerchantBackend.Location; - fullfilment_url?: string; -} -interface Payments { - refund_deadline: Duration; - pay_deadline: Duration; - wire_transfer_deadline: Duration; - auto_refund_deadline: Duration; - max_fee?: string; - createToken: boolean; - minimum_age?: number; -} -interface Entity { - inventoryProducts: ProductMap; - products: MerchantBackend.Product[]; - pricing: Partial; - payments: Partial; - shipping: Partial; - extra: Record; -} - -const stringIsValidJSON = (value: string) => { - try { - JSON.parse(value.trim()); - return true; - } catch { - return false; - } -}; - -export function CreatePage({ - onCreate, - onBack, - instanceConfig, - instanceInventory, -}: Props): VNode { - const config = useConfigContext(); - const instance_default = with_defaults(instanceConfig, config.currency) - const [value, valueHandler] = useState(instance_default); - const zero = Amounts.zeroOfCurrency(config.currency); - const [settings, updateSettings] = useSettings() - const inventoryList = Object.values(value.inventoryProducts || {}); - const productList = Object.values(value.products || {}); - - const { i18n } = useTranslationContext(); - - const parsedPrice = !value.pricing?.order_price - ? undefined - : Amounts.parse(value.pricing.order_price); - - const errors: FormErrors = { - pricing: undefinedIfEmpty({ - summary: !value.pricing?.summary ? i18n.str`required` : undefined, - order_price: !value.pricing?.order_price - ? i18n.str`required` - : !parsedPrice - ? i18n.str`not valid` - : Amounts.isZero(parsedPrice) - ? i18n.str`must be greater than 0` - : undefined, - }), - payments: undefinedIfEmpty({ - refund_deadline: !value.payments?.refund_deadline - ? undefined - : value.payments.pay_deadline && - Duration.cmp(value.payments.refund_deadline, value.payments.pay_deadline) === -1 - ? i18n.str`refund deadline cannot be before pay deadline` - : value.payments.wire_transfer_deadline && - Duration.cmp( - value.payments.wire_transfer_deadline, - value.payments.refund_deadline, - ) === -1 - ? i18n.str`wire transfer deadline cannot be before refund deadline` - : undefined, - pay_deadline: !value.payments?.pay_deadline - ? i18n.str`required` - : value.payments.wire_transfer_deadline && - Duration.cmp( - value.payments.wire_transfer_deadline, - value.payments.pay_deadline, - ) === -1 - ? i18n.str`wire transfer deadline cannot be before pay deadline` - : undefined, - wire_transfer_deadline: !value.payments?.wire_transfer_deadline - ? i18n.str`required` - : undefined, - auto_refund_deadline: !value.payments?.auto_refund_deadline - ? undefined - : !value.payments?.refund_deadline - ? i18n.str`should have a refund deadline` - : Duration.cmp( - value.payments.refund_deadline, - value.payments.auto_refund_deadline, - ) == -1 - ? i18n.str`auto refund cannot be after refund deadline` - : undefined, - - }), - shipping: undefinedIfEmpty({ - delivery_date: !value.shipping?.delivery_date - ? undefined - : !isFuture(value.shipping.delivery_date) - ? i18n.str`should be in the future` - : undefined, - }), - }; - const hasErrors = Object.keys(errors).some( - (k) => (errors as any)[k] !== undefined, - ); - - const submit = (): void => { - const order = value as any; //schema.cast(value); - if (!value.payments) return; - if (!value.shipping) return; - - const request: MerchantBackend.Orders.PostOrderRequest = { - order: { - amount: order.pricing.order_price, - summary: order.pricing.summary, - products: productList, - extra: undefinedIfEmpty(value.extra), - pay_deadline: !value.payments.pay_deadline ? - i18n.str`required` : - AbsoluteTime.toProtocolTimestamp(AbsoluteTime.addDuration(AbsoluteTime.now(), value.payments.pay_deadline)) - ,// : undefined, - wire_transfer_deadline: value.payments.wire_transfer_deadline - ? AbsoluteTime.toProtocolTimestamp(AbsoluteTime.addDuration(AbsoluteTime.now(), value.payments.wire_transfer_deadline)) - : undefined, - refund_deadline: value.payments.refund_deadline - ? AbsoluteTime.toProtocolTimestamp(AbsoluteTime.addDuration(AbsoluteTime.now(), value.payments.refund_deadline)) - : undefined, - auto_refund: value.payments.auto_refund_deadline - ? Duration.toTalerProtocolDuration(value.payments.auto_refund_deadline) - : undefined, - max_fee: value.payments.max_fee as string, - - delivery_date: value.shipping.delivery_date - ? { t_s: value.shipping.delivery_date.getTime() / 1000 } - : undefined, - delivery_location: value.shipping.delivery_location, - fulfillment_url: value.shipping.fullfilment_url, - minimum_age: value.payments.minimum_age, - }, - inventory_products: inventoryList.map((p) => ({ - product_id: p.product.id, - quantity: p.quantity, - })), - create_token: value.payments.createToken, - }; - - onCreate(request); - }; - - const addProductToTheInventoryList = ( - product: MerchantBackend.Products.ProductDetail & WithId, - quantity: number, - ) => { - valueHandler((v) => { - const inventoryProducts = { ...v.inventoryProducts }; - inventoryProducts[product.id] = { product, quantity }; - return { ...v, inventoryProducts }; - }); - }; - - const removeProductFromTheInventoryList = (id: string) => { - valueHandler((v) => { - const inventoryProducts = { ...v.inventoryProducts }; - delete inventoryProducts[id]; - return { ...v, inventoryProducts }; - }); - }; - - const addNewProduct = async (product: MerchantBackend.Product) => { - return valueHandler((v) => { - const products = v.products ? [...v.products, product] : []; - return { ...v, products }; - }); - }; - - const removeFromNewProduct = (index: number) => { - valueHandler((v) => { - const products = v.products ? [...v.products] : []; - products.splice(index, 1); - return { ...v, products }; - }); - }; - - const [editingProduct, setEditingProduct] = useState< - MerchantBackend.Product | undefined - >(undefined); - - const totalPriceInventory = inventoryList.reduce((prev, cur) => { - const p = Amounts.parseOrThrow(cur.product.price); - return Amounts.add(prev, Amounts.mult(p, cur.quantity).amount).amount; - }, zero); - - const totalPriceProducts = productList.reduce((prev, cur) => { - if (!cur.price) return zero; - const p = Amounts.parseOrThrow(cur.price); - return Amounts.add(prev, Amounts.mult(p, cur.quantity).amount).amount; - }, zero); - - const hasProducts = inventoryList.length > 0 || productList.length > 0; - const totalPrice = Amounts.add(totalPriceInventory, totalPriceProducts); - - const totalAsString = Amounts.stringify(totalPrice.amount); - const allProducts = productList.concat(inventoryList.map(asProduct)); - - const [newField, setNewField] = useState("") - - useEffect(() => { - valueHandler((v) => { - return { - ...v, - pricing: { - ...v.pricing, - products_price: hasProducts ? totalAsString : undefined, - order_price: hasProducts ? totalAsString : undefined, - }, - }; - }); - }, [hasProducts, totalAsString]); - - const discountOrRise = rate( - parsedPrice ?? Amounts.zeroOfCurrency(config.currency), - totalPrice.amount, - ); - - const minAgeByProducts = allProducts.reduce( - (cur, prev) => - !prev.minimum_age || cur > prev.minimum_age ? cur : prev.minimum_age, - 0, - ); - - // if there is no default pay deadline - const noDefault_payDeadline = !instance_default.payments || !instance_default.payments.pay_deadline - // and there is no default wire deadline - const noDefault_wireDeadline = !instance_default.payments || !instance_default.payments.wire_transfer_deadline - // user required to set the taler options - const requiresSomeTalerOptions = noDefault_payDeadline || noDefault_wireDeadline - - - return ( -
- -
-
-
    -
  • { - updateSettings({ - ...settings, - advanceOrderMode: false - }) - }}> - - Simple - -
  • -
  • { - updateSettings({ - ...settings, - advanceOrderMode: true - }) - }}> - - Advanced - -
  • -
-
-
-
-
- {/* // FIXME: translating plural singular */} - 0 && ( -

- {allProducts.length} products with a total price of{" "} - {totalAsString}. -

- ) - } - tooltip={i18n.str`Manage list of products in the order.`} - > - - - {settings.advanceOrderMode && - { - setEditingProduct(undefined); - return addNewProduct(p); - }} - /> - } - - {allProducts.length > 0 && ( - { - if (e.product_id) { - removeProductFromTheInventoryList(e.product_id); - } else { - removeFromNewProduct(index); - setEditingProduct(e); - } - }, - }, - ]} - /> - )} -
- - - errors={errors} - object={value} - valueHandler={valueHandler as any} - > - {hasProducts ? ( - - - 0 && - (discountOrRise < 1 - ? `discount of %${Math.round( - (1 - discountOrRise) * 100, - )}` - : `rise of %${Math.round((discountOrRise - 1) * 100)}`) - } - tooltip={i18n.str`Amount to be paid by the customer`} - /> - - ) : ( - - )} - - - - {settings.advanceOrderMode && - - - {value.shipping?.delivery_date && ( - - - - )} - - - } - - {(settings.advanceOrderMode || requiresSomeTalerOptions) && - - {(settings.advanceOrderMode || noDefault_payDeadline) && } - withForever - withoutClear - tooltip={i18n.str`Time for the customer to pay for the offer before it expires. Inventory products will be reserved until this deadline. Time start to run after the order is created.`} - side={ - - - - } - />} - {settings.advanceOrderMode && } - withForever - withoutClear - tooltip={i18n.str`Time while the order can be refunded by the merchant. Time starts after the order is created.`} - side={ - - - - } - />} - {(settings.advanceOrderMode || noDefault_wireDeadline) && } - withoutClear - withForever - tooltip={i18n.str`Time for the exchange to make the wire transfer. Time starts after the order is created.`} - side={ - - - - } - />} - {settings.advanceOrderMode && } - tooltip={i18n.str`Time until which the wallet will automatically check for refunds without user interaction.`} - withForever - />} - - {settings.advanceOrderMode && } - {settings.advanceOrderMode && } - {settings.advanceOrderMode && 0 - ? i18n.str`Min age defined by the producs is ${minAgeByProducts}` - : i18n.str`No product with age restriction in this order` - } - />} - - } - - {settings.advanceOrderMode && - - {Object.keys(value.extra ?? {}).map((key) => { - - return { - if (value.extra && value.extra[key] !== undefined) { - console.log(value.extra) - delete value.extra[key] - } - valueHandler({ - ...value, - }) - }}>remove - } - /> - })} -
-
- -
-
-
-

- setNewField(e.currentTarget.value)} /> -

-
-
- -
-
- } - - -
- {onBack && ( - - )} - -
-
-
-
-
-
- ); -} - -function asProduct(p: ProductAndQuantity): MerchantBackend.Product { - return { - product_id: p.product.id, - image: p.product.image, - price: p.product.price, - unit: p.product.unit, - quantity: p.quantity, - description: p.product.description, - taxes: p.product.taxes, - minimum_age: p.product.minimum_age, - }; -} - - -function DeadlineHelp({ duration }: { duration?: Duration }): VNode { - const { i18n } = useTranslationContext(); - const [now, setNow] = useState(AbsoluteTime.now()) - useEffect(() => { - const iid = setInterval(() => { - setNow(AbsoluteTime.now()) - }, 60 * 1000) - return () => { - clearInterval(iid) - } - }) - if (!duration) return Disabled - const when = AbsoluteTime.addDuration(now, duration) - if (when.t_ms === "never") return No deadline - return Deadline at {format(when.t_ms, "dd/MM/yy HH:mm")} -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/orders/create/OrderCreatedSuccessfully.tsx b/packages/auditor-backoffice-ui/src/paths/instance/orders/create/OrderCreatedSuccessfully.tsx deleted file mode 100644 index 3f7b20f52..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/orders/create/OrderCreatedSuccessfully.tsx +++ /dev/null @@ -1,114 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 { h, VNode } from "preact"; -import { useEffect, useState } from "preact/hooks"; -import { CreatedSuccessfully } from "../../../../components/notifications/CreatedSuccessfully.js"; -import { useOrderAPI } from "../../../../hooks/order.js"; -import { Entity } from "./index.js"; - -interface Props { - entity: Entity; - onConfirm: () => void; - onCreateAnother?: () => void; -} - -export function OrderCreatedSuccessfully({ - entity, - onConfirm, - onCreateAnother, -}: Props): VNode { - const { getPaymentURL } = useOrderAPI(); - const [url, setURL] = useState(undefined); - const { i18n } = useTranslationContext(); - useEffect(() => { - getPaymentURL(entity.response.order_id).then((response) => { - setURL(response.data); - }); - }, [getPaymentURL, entity.response.order_id]); - - return ( - -
-
- -
-
-
-

- -

-
-
-
-
-
- -
-
-
-

- -

-
-
-
-
-
- -
-
-
-

- -

-
-
-
-
-
- -
-
-
-

- -

-
-
-
-
- ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/orders/create/index.tsx b/packages/auditor-backoffice-ui/src/paths/instance/orders/create/index.tsx deleted file mode 100644 index d2a8619ce..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/orders/create/index.tsx +++ /dev/null @@ -1,114 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { ErrorType, HttpError } from "@gnu-taler/web-util/browser"; -import { Fragment, h, VNode } from "preact"; -import { useState } from "preact/hooks"; -import { Loading } from "../../../../components/exception/loading.js"; -import { NotificationCard } from "../../../../components/menu/index.js"; -import { MerchantBackend } from "../../../../declaration.js"; -import { useInstanceDetails } from "../../../../hooks/instance.js"; -import { useOrderAPI } from "../../../../hooks/order.js"; -import { useInstanceProducts } from "../../../../hooks/product.js"; -import { Notification } from "../../../../utils/types.js"; -import { CreatePage } from "./CreatePage.js"; -import { HttpStatusCode } from "@gnu-taler/taler-util"; - -export type Entity = { - request: MerchantBackend.Orders.PostOrderRequest; - response: MerchantBackend.Orders.PostOrderResponse; -}; -interface Props { - onBack?: () => void; - onConfirm: (id: string) => void; - onUnauthorized: () => VNode; - onNotFound: () => VNode; - onLoadError: (error: HttpError) => VNode; -} -export default function OrderCreate({ - onConfirm, - onBack, - onLoadError, - onNotFound, - onUnauthorized, -}: Props): VNode { - const { createOrder } = useOrderAPI(); - const [notif, setNotif] = useState(undefined); - - const detailsResult = useInstanceDetails(); - const inventoryResult = useInstanceProducts(); - - if (detailsResult.loading) return ; - if (inventoryResult.loading) return ; - - if (!detailsResult.ok) { - if ( - detailsResult.type === ErrorType.CLIENT && - detailsResult.status === HttpStatusCode.Unauthorized - ) - return onUnauthorized(); - if ( - detailsResult.type === ErrorType.CLIENT && - detailsResult.status === HttpStatusCode.NotFound - ) - return onNotFound(); - return onLoadError(detailsResult); - } - - if (!inventoryResult.ok) { - if ( - inventoryResult.type === ErrorType.CLIENT && - inventoryResult.status === HttpStatusCode.Unauthorized - ) - return onUnauthorized(); - if ( - inventoryResult.type === ErrorType.CLIENT && - inventoryResult.status === HttpStatusCode.NotFound - ) - return onNotFound(); - return onLoadError(inventoryResult); - } - - return ( - - - - { - createOrder(request) - .then((r) => { - return onConfirm(r.data.order_id) - }) - .catch((error) => { - setNotif({ - message: "could not create order", - type: "ERROR", - description: error.message, - }); - }); - }} - instanceConfig={detailsResult.data} - instanceInventory={inventoryResult.data} - /> - - ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/orders/details/Detail.stories.tsx b/packages/auditor-backoffice-ui/src/paths/instance/orders/details/Detail.stories.tsx deleted file mode 100644 index 22c6944b3..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/orders/details/Detail.stories.tsx +++ /dev/null @@ -1,135 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { addDays } from "date-fns"; -import { h, VNode, FunctionalComponent } from "preact"; -import { MerchantBackend } from "../../../../declaration.js"; -import { DetailPage as TestedComponent } from "./DetailPage.js"; - -export default { - title: "Pages/Order/Detail", - component: TestedComponent, - argTypes: { - onRefund: { action: "onRefund" }, - onBack: { action: "onBack" }, - }, -}; - -function createExample( - Component: FunctionalComponent, - props: Partial, -) { - const r = (args: any) => ; - r.args = props; - return r; -} - -const defaultContractTerm = { - amount: "TESTKUDOS:10", - timestamp: { - t_s: new Date().getTime() / 1000, - }, - auditors: [], - exchanges: [], - max_fee: "TESTKUDOS:1", - merchant: {} as any, - merchant_base_url: "http://merchant.url/", - order_id: "2021.165-03GDFC26Y1NNG", - products: [], - summary: "text summary", - wire_transfer_deadline: { - t_s: "never", - }, - refund_deadline: { t_s: "never" }, - merchant_pub: "ASDASDASDSd", - nonce: "QWEQWEQWE", - pay_deadline: { - t_s: "never", - }, - wire_method: "x-taler-bank", - h_wire: "asd", -} as MerchantBackend.ContractTerms; - -// contract_terms: defaultContracTerm, -export const Claimed = createExample(TestedComponent, { - id: "2021.165-03GDFC26Y1NNG", - selected: { - order_status: "claimed", - contract_terms: defaultContractTerm, - }, -}); - -export const PaidNotRefundable = createExample(TestedComponent, { - id: "2021.165-03GDFC26Y1NNG", - selected: { - order_status: "paid", - contract_terms: defaultContractTerm, - refunded: false, - deposit_total: "TESTKUDOS:10", - exchange_ec: 0, - order_status_url: "http://merchant.backend/status", - exchange_hc: 0, - refund_amount: "TESTKUDOS:0", - refund_details: [], - refund_pending: false, - wire_details: [], - wire_reports: [], - wired: false, - }, -}); - -export const PaidRefundable = createExample(TestedComponent, { - id: "2021.165-03GDFC26Y1NNG", - selected: { - order_status: "paid", - contract_terms: { - ...defaultContractTerm, - refund_deadline: { - t_s: addDays(new Date(), 2).getTime() / 1000, - }, - }, - refunded: false, - deposit_total: "TESTKUDOS:10", - exchange_ec: 0, - order_status_url: "http://merchant.backend/status", - exchange_hc: 0, - refund_amount: "TESTKUDOS:0", - refund_details: [], - refund_pending: false, - wire_details: [], - wire_reports: [], - wired: false, - }, -}); - -export const Unpaid = createExample(TestedComponent, { - id: "2021.165-03GDFC26Y1NNG", - selected: { - order_status: "unpaid", - order_status_url: "http://merchant.backend/status", - creation_time: { - t_s: new Date().getTime() / 1000, - }, - summary: "text summary", - taler_pay_uri: "pay uri", - total_amount: "TESTKUDOS:10", - }, -}); diff --git a/packages/auditor-backoffice-ui/src/paths/instance/orders/details/DetailPage.tsx b/packages/auditor-backoffice-ui/src/paths/instance/orders/details/DetailPage.tsx deleted file mode 100644 index abcddb38a..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/orders/details/DetailPage.tsx +++ /dev/null @@ -1,770 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { AmountJson, Amounts, stringifyRefundUri } from "@gnu-taler/taler-util"; -import { useTranslationContext } from "@gnu-taler/web-util/browser"; -import { format, formatDistance } from "date-fns"; -import { Fragment, VNode, h } from "preact"; -import { useState } from "preact/hooks"; -import { FormProvider } from "../../../../components/form/FormProvider.js"; -import { Input } from "../../../../components/form/Input.js"; -import { InputCurrency } from "../../../../components/form/InputCurrency.js"; -import { InputDate } from "../../../../components/form/InputDate.js"; -import { InputDuration } from "../../../../components/form/InputDuration.js"; -import { InputGroup } from "../../../../components/form/InputGroup.js"; -import { InputLocation } from "../../../../components/form/InputLocation.js"; -import { TextField } from "../../../../components/form/TextField.js"; -import { ProductList } from "../../../../components/product/ProductList.js"; -import { useBackendContext } from "../../../../context/backend.js"; -import { MerchantBackend } from "../../../../declaration.js"; -import { datetimeFormatForSettings, useSettings } from "../../../../hooks/useSettings.js"; -import { mergeRefunds } from "../../../../utils/amount.js"; -import { RefundModal } from "../list/Table.js"; -import { Event, Timeline } from "./Timeline.js"; - -type Entity = MerchantBackend.Orders.MerchantOrderStatusResponse; -type CT = MerchantBackend.ContractTerms; - -interface Props { - onBack: () => void; - selected: Entity; - id: string; - onRefund: (id: string, value: MerchantBackend.Orders.RefundRequest) => void; -} - -type Paid = MerchantBackend.Orders.CheckPaymentPaidResponse & { - refund_taken: string; -}; -type Unpaid = MerchantBackend.Orders.CheckPaymentUnpaidResponse; -type Claimed = MerchantBackend.Orders.CheckPaymentClaimedResponse; - -function ContractTerms({ value }: { value: CT }) { - const { i18n } = useTranslationContext(); - - return ( - - object={value} valueHandler={null}> - - readonly - name="summary" - label={i18n.str`Summary`} - tooltip={i18n.str`human-readable description of the whole purchase`} - /> - - readonly - name="amount" - label={i18n.str`Amount`} - tooltip={i18n.str`total price for the transaction`} - /> - {value.fulfillment_url && ( - - readonly - name="fulfillment_url" - label={i18n.str`Fulfillment URL`} - tooltip={i18n.str`URL for this purchase`} - /> - )} - - readonly - name="max_fee" - label={i18n.str`Max fee`} - tooltip={i18n.str`maximum total deposit fee accepted by the merchant for this contract`} - /> - - readonly - name="timestamp" - label={i18n.str`Created at`} - tooltip={i18n.str`time when this contract was generated`} - /> - - readonly - name="refund_deadline" - label={i18n.str`Refund deadline`} - tooltip={i18n.str`after this deadline has passed no refunds will be accepted`} - /> - - readonly - name="pay_deadline" - label={i18n.str`Payment deadline`} - tooltip={i18n.str`after this deadline, the merchant won't accept payments for the contract`} - /> - - readonly - name="wire_transfer_deadline" - label={i18n.str`Wire transfer deadline`} - tooltip={i18n.str`transfer deadline for the exchange`} - /> - - readonly - name="delivery_date" - label={i18n.str`Delivery date`} - tooltip={i18n.str`time indicating when the order should be delivered`} - /> - {value.delivery_date && ( - - - - )} - - readonly - name="auto_refund" - label={i18n.str`Auto-refund delay`} - tooltip={i18n.str`how long the wallet should try to get an automatic refund for the purchase`} - /> - - readonly - name="extra" - label={i18n.str`Extra info`} - tooltip={i18n.str`extra data that is only interpreted by the merchant frontend`} - /> - - - ); -} - -function ClaimedPage({ - id, - order, -}: { - id: string; - order: MerchantBackend.Orders.CheckPaymentClaimedResponse; -}) { - const events: Event[] = []; - if (order.contract_terms.timestamp.t_s !== "never") { - events.push({ - when: new Date(order.contract_terms.timestamp.t_s * 1000), - description: "order created", - type: "start", - }); - } - if (order.contract_terms.pay_deadline.t_s !== "never") { - events.push({ - when: new Date(order.contract_terms.pay_deadline.t_s * 1000), - description: "pay deadline", - type: "deadline", - }); - } - if (order.contract_terms.refund_deadline.t_s !== "never") { - events.push({ - when: new Date(order.contract_terms.refund_deadline.t_s * 1000), - description: "refund deadline", - type: "deadline", - }); - } - if (order.contract_terms.wire_transfer_deadline.t_s !== "never") { - events.push({ - when: new Date(order.contract_terms.wire_transfer_deadline.t_s * 1000), - description: "wire deadline", - type: "deadline", - }); - } - if ( - order.contract_terms.delivery_date && - order.contract_terms.delivery_date.t_s !== "never" - ) { - events.push({ - when: new Date(order.contract_terms.delivery_date?.t_s * 1000), - description: "delivery", - type: "delivery", - }); - } - - const [value, valueHandler] = useState>(order); - const { i18n } = useTranslationContext(); - const [settings] = useSettings() - - return ( -
-
-
-
-
-
-
-
-
-
- Order #{id} -
- claimed -
-
-
-
- -
-
-
-

{order.contract_terms.amount}

-
-
-
- -
-
-
-
-

- - claimed at: - {" "} - {format( - new Date(order.contract_terms.timestamp.t_s * 1000), - datetimeFormatForSettings(settings) - )} -

-
-
-
-
-
-
- -
-
-
-
- Timeline -
- -
-
-
- Payment details -
- - object={value} - valueHandler={valueHandler} - > - - - - name="order_status" - readonly - label={i18n.str`Order status`} - /> - -
-
-
- - {order.contract_terms.products.length ? ( - -
- Product list -
- -
- ) : undefined} - - {value.contract_terms && ( - - )} -
-
-
-
-
- ); -} -function PaidPage({ - id, - order, - onRefund, -}: { - id: string; - order: MerchantBackend.Orders.CheckPaymentPaidResponse; - onRefund: (id: string) => void; -}) { - const events: Event[] = []; - if (order.contract_terms.timestamp.t_s !== "never") { - events.push({ - when: new Date(order.contract_terms.timestamp.t_s * 1000), - description: "order created", - type: "start", - }); - } - if (order.contract_terms.pay_deadline.t_s !== "never") { - events.push({ - when: new Date(order.contract_terms.pay_deadline.t_s * 1000), - description: "pay deadline", - type: "deadline", - }); - } - if (order.contract_terms.refund_deadline.t_s !== "never") { - events.push({ - when: new Date(order.contract_terms.refund_deadline.t_s * 1000), - description: "refund deadline", - type: "deadline", - }); - } - if (order.contract_terms.wire_transfer_deadline.t_s !== "never") { - events.push({ - when: new Date(order.contract_terms.wire_transfer_deadline.t_s * 1000), - description: "wire deadline", - type: "deadline", - }); - } - if ( - order.contract_terms.delivery_date && - order.contract_terms.delivery_date.t_s !== "never" - ) { - if (order.contract_terms.delivery_date) - events.push({ - when: new Date(order.contract_terms.delivery_date?.t_s * 1000), - description: "delivery", - type: "delivery", - }); - } - order.refund_details.reduce(mergeRefunds, []).forEach((e) => { - if (e.timestamp.t_s !== "never") { - events.push({ - when: new Date(e.timestamp.t_s * 1000), - description: `refund: ${e.amount}: ${e.reason}`, - type: e.pending ? "refund" : "refund-taken", - }); - } - }); - if (order.wire_details && order.wire_details.length) { - if (order.wire_details.length > 1) { - let last: MerchantBackend.Orders.TransactionWireTransfer | null = null; - let first: MerchantBackend.Orders.TransactionWireTransfer | null = null; - let total: AmountJson | null = null; - - order.wire_details.forEach((w) => { - if (last === null || last.execution_time.t_s < w.execution_time.t_s) { - last = w; - } - if (first === null || first.execution_time.t_s > w.execution_time.t_s) { - first = w; - } - total = - total === null - ? Amounts.parseOrThrow(w.amount) - : Amounts.add(total, Amounts.parseOrThrow(w.amount)).amount; - }); - const last_time = last!.execution_time.t_s; - if (last_time !== "never") { - events.push({ - when: new Date(last_time * 1000), - description: `wired ${Amounts.stringify(total!)}`, - type: "wired-range", - }); - } - const first_time = first!.execution_time.t_s; - if (first_time !== "never") { - events.push({ - when: new Date(first_time * 1000), - description: `wire transfer started...`, - type: "wired-range", - }); - } - } else { - order.wire_details.forEach((e) => { - if (e.execution_time.t_s !== "never") { - events.push({ - when: new Date(e.execution_time.t_s * 1000), - description: `wired ${e.amount}`, - type: "wired", - }); - } - }); - } - } - - const now = new Date() - const nextEvent = events.find((e) => { - return e.when.getTime() > now.getTime() - }) - - const [value, valueHandler] = useState>(order); - const { url: backendURL } = useBackendContext() - const refundurl = stringifyRefundUri({ - merchantBaseUrl: backendURL, - orderId: order.contract_terms.order_id - }) - const refundable = - new Date().getTime() < order.contract_terms.refund_deadline.t_s * 1000; - const { i18n } = useTranslationContext(); - - const amount = Amounts.parseOrThrow(order.contract_terms.amount); - const refund_taken = order.refund_details.reduce((prev, cur) => { - if (cur.pending) return prev; - return Amounts.add(prev, Amounts.parseOrThrow(cur.amount)).amount; - }, Amounts.zeroOfCurrency(amount.currency)); - value.refund_taken = Amounts.stringify(refund_taken); - - return ( -
-
-
-
-
-
-
-
-
-
- Order #{id} -
- paid -
- {order.wired ? ( -
- wired -
- ) : null} - {order.refunded ? ( -
- refunded -
- ) : null} -
-
-
-
-
-
-

{order.contract_terms.amount}

-
-
-
-
-

-
- - - -
-

-
-
-
- -
-
-
-
- {nextEvent && -

- Next event in {formatDistance( - nextEvent.when, - new Date(), - // "yyyy/MM/dd HH:mm:ss", - )} -

- } -
-
-
-
-
-
- -
-
-
-
- Timeline -
- -
-
-
- Payment details -
- - object={value} - valueHandler={valueHandler} - > - {/* name="deposit_total" readonly label={i18n.str`Deposit total`} /> */} - {order.refunded && ( - - name="refund_amount" - readonly - label={i18n.str`Refunded amount`} - /> - )} - {order.refunded && ( - - name="refund_taken" - readonly - label={i18n.str`Refund taken`} - /> - )} - - name="order_status" - readonly - label={i18n.str`Order status`} - /> - - name="order_status_url" - label={i18n.str`Status URL`} - > - - {order.order_status_url} - - - {order.refunded && ( - - name="order_status_url" - label={i18n.str`Refund URI`} - > - - {refundurl} - - - )} - -
-
-
- - {order.contract_terms.products.length ? ( - -
- Product list -
- -
- ) : undefined} - - {value.contract_terms && ( - - )} -
-
-
-
-
- ); -} - -function UnpaidPage({ - id, - order, -}: { - id: string; - order: MerchantBackend.Orders.CheckPaymentUnpaidResponse; -}) { - const [value, valueHandler] = useState>(order); - const { i18n } = useTranslationContext(); - const [settings] = useSettings() - return ( -
-
-
-
-
-
-

- Order #{id} -

-
-
- unpaid -
-
-
- -
-
-
-
-

- - pay at: - {" "} - - {order.order_status_url} - -

-

- - created at: - {" "} - {order.creation_time.t_s === "never" - ? "never" - : format( - new Date(order.creation_time.t_s * 1000), - datetimeFormatForSettings(settings) - )} -

-
-
-
-
-
-
- -
-
-
-
- object={value} valueHandler={valueHandler}> - - readonly - name="summary" - label={i18n.str`Summary`} - tooltip={i18n.str`human-readable description of the whole purchase`} - /> - - readonly - name="total_amount" - label={i18n.str`Amount`} - tooltip={i18n.str`total price for the transaction`} - /> - - name="order_status" - readonly - label={i18n.str`Order status`} - /> - - name="order_status_url" - readonly - label={i18n.str`Order status URL`} - /> - - name="taler_pay_uri" - label={i18n.str`Payment URI`} - > - - {value.taler_pay_uri} - - - -
-
-
-
-
- ); -} - -export function DetailPage({ id, selected, onRefund, onBack }: Props): VNode { - const [showRefund, setShowRefund] = useState(undefined); - const { i18n } = useTranslationContext(); - const DetailByStatus = function () { - switch (selected.order_status) { - case "claimed": - return ; - case "paid": - return ; - case "unpaid": - return ; - default: - return ( -
- - Unknown order status. This is an error, please contact the - administrator. - -
- ); - } - }; - - return ( - - {DetailByStatus()} - {showRefund && ( - setShowRefund(undefined)} - onConfirm={(value) => { - onRefund(showRefund, value); - setShowRefund(undefined); - }} - /> - )} -
-
-
-
- -
-
-
-
- - ); -} - -async function copyToClipboard(text: string) { - return navigator.clipboard.writeText(text); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/orders/details/Timeline.tsx b/packages/auditor-backoffice-ui/src/paths/instance/orders/details/Timeline.tsx deleted file mode 100644 index 1aae4da21..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/orders/details/Timeline.tsx +++ /dev/null @@ -1,129 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 { format } from "date-fns"; -import { h } from "preact"; -import { useEffect, useState } from "preact/hooks"; -import { datetimeFormatForSettings, useSettings } from "../../../../hooks/useSettings.js"; - -interface Props { - events: Event[]; -} - -export function Timeline({ events: e }: Props) { - const events = [...e]; - events.push({ - when: new Date(), - description: "now", - type: "now", - }); - - events.sort((a, b) => a.when.getTime() - b.when.getTime()); - const [settings] = useSettings(); - const [state, setState] = useState(events); - useEffect(() => { - const handle = setTimeout(() => { - const eventsWithoutNow = state.filter((e) => e.type !== "now"); - eventsWithoutNow.push({ - when: new Date(), - description: "now", - type: "now", - }); - setState(eventsWithoutNow); - }, 1000); - return () => { - clearTimeout(handle); - }; - }); - return ( -
- {events.map((e, i) => { - return ( -
- {(() => { - switch (e.type) { - case "deadline": - return ( -
- -
- ); - case "delivery": - return ( -
- -
- ); - case "start": - return ( -
- -
- ); - case "wired": - return ( -
- -
- ); - case "wired-range": - return ( -
- -
- ); - case "refund": - return ( -
- -
- ); - case "refund-taken": - return ( -
- -
- ); - case "now": - return ( -
- -
- ); - } - })()} -
- {e.description !== "now" &&

{format(e.when, datetimeFormatForSettings(settings))}

} -

{e.description}

-
-
- ); - })} -
- ); -} -export interface Event { - when: Date; - description: string; - type: - | "start" - | "refund" - | "refund-taken" - | "wired" - | "wired-range" - | "deadline" - | "delivery" - | "now"; -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/orders/details/index.tsx b/packages/auditor-backoffice-ui/src/paths/instance/orders/details/index.tsx deleted file mode 100644 index dfeaa4447..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/orders/details/index.tsx +++ /dev/null @@ -1,95 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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, - HttpError, - ErrorType, -} from "@gnu-taler/web-util/browser"; -import { Fragment, h, VNode } from "preact"; -import { useState } from "preact/hooks"; -import { Loading } from "../../../../components/exception/loading.js"; -import { NotificationCard } from "../../../../components/menu/index.js"; -import { MerchantBackend } from "../../../../declaration.js"; -import { useOrderAPI, useOrderDetails } from "../../../../hooks/order.js"; -import { Notification } from "../../../../utils/types.js"; -import { DetailPage } from "./DetailPage.js"; -import { HttpStatusCode } from "@gnu-taler/taler-util"; - -export interface Props { - oid: string; - - onBack: () => void; - onUnauthorized: () => VNode; - onNotFound: () => VNode; - onLoadError: (error: HttpError) => VNode; -} - -export default function Update({ - oid, - onBack, - onLoadError, - onNotFound, - onUnauthorized, -}: Props): VNode { - const { refundOrder } = useOrderAPI(); - const result = useOrderDetails(oid); - const [notif, setNotif] = useState(undefined); - - const { i18n } = useTranslationContext(); - - if (result.loading) return ; - if (!result.ok) { - if ( - result.type === ErrorType.CLIENT && - result.status === HttpStatusCode.Unauthorized - ) - return onUnauthorized(); - if ( - result.type === ErrorType.CLIENT && - result.status === HttpStatusCode.NotFound - ) - return onNotFound(); - return onLoadError(result); - } - - return ( - - - - - refundOrder(id, value) - .then(() => - setNotif({ - message: i18n.str`refund created successfully`, - type: "SUCCESS", - }), - ) - .catch((error) => - setNotif({ - message: i18n.str`could not create the refund`, - type: "ERROR", - description: error.message, - }), - ) - } - selected={result.data} - /> - - ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/orders/list/List.stories.tsx b/packages/auditor-backoffice-ui/src/paths/instance/orders/list/List.stories.tsx deleted file mode 100644 index 9df006083..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/orders/list/List.stories.tsx +++ /dev/null @@ -1,107 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { h, VNode, FunctionalComponent } from "preact"; -import { ListPage as TestedComponent } from "./ListPage.js"; - -export default { - title: "Pages/Order/List", - component: TestedComponent, - argTypes: { - onShowAll: { action: "onShowAll" }, - onShowPaid: { action: "onShowPaid" }, - onShowRefunded: { action: "onShowRefunded" }, - onShowNotWired: { action: "onShowNotWired" }, - onCopyURL: { action: "onCopyURL" }, - onSelectDate: { action: "onSelectDate" }, - onLoadMoreBefore: { action: "onLoadMoreBefore" }, - onLoadMoreAfter: { action: "onLoadMoreAfter" }, - onSelectOrder: { action: "onSelectOrder" }, - onRefundOrder: { action: "onRefundOrder" }, - onSearchOrderById: { action: "onSearchOrderById" }, - onCreate: { action: "onCreate" }, - }, -}; - -function createExample( - Component: FunctionalComponent, - props: Partial, -) { - const r = (args: any) => ; - r.args = props; - return r; -} - -export const Example = createExample(TestedComponent, { - orders: [ - { - id: "123", - amount: "TESTKUDOS:10", - paid: false, - refundable: true, - row_id: 1, - summary: "summary", - timestamp: { - t_s: new Date().getTime() / 1000, - }, - order_id: "123", - }, - { - id: "234", - amount: "TESTKUDOS:12", - paid: true, - refundable: true, - row_id: 2, - summary: - "summary with long text, very very long text that someone want to add as a description of the order", - timestamp: { - t_s: new Date().getTime() / 1000, - }, - order_id: "234", - }, - { - id: "456", - amount: "TESTKUDOS:1", - paid: false, - refundable: false, - row_id: 3, - summary: - "summary with long text, very very long text that someone want to add as a description of the order", - timestamp: { - t_s: new Date().getTime() / 1000, - }, - order_id: "456", - }, - { - id: "234", - amount: "TESTKUDOS:12", - paid: false, - refundable: false, - row_id: 4, - summary: - "summary with long text, very very long text that someone want to add as a description of the order", - timestamp: { - t_s: new Date().getTime() / 1000, - }, - order_id: "234", - }, - ], -}); diff --git a/packages/auditor-backoffice-ui/src/paths/instance/orders/list/ListPage.tsx b/packages/auditor-backoffice-ui/src/paths/instance/orders/list/ListPage.tsx deleted file mode 100644 index 187a1d0b4..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/orders/list/ListPage.tsx +++ /dev/null @@ -1,226 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { useTranslationContext } from "@gnu-taler/web-util/browser"; -import { format } from "date-fns"; -import { h, VNode, Fragment } from "preact"; -import { useState } from "preact/hooks"; -import { DatePicker } from "../../../../components/picker/DatePicker.js"; -import { MerchantBackend, WithId } from "../../../../declaration.js"; -import { CardTable } from "./Table.js"; -import { dateFormatForSettings, useSettings } from "../../../../hooks/useSettings.js"; - -export interface ListPageProps { - onShowAll: () => void; - onShowNotPaid: () => void; - onShowPaid: () => void; - onShowRefunded: () => void; - onShowNotWired: () => void; - onShowWired: () => void; - onCopyURL: (id: string) => void; - isAllActive: string; - isPaidActive: string; - isNotPaidActive: string; - isRefundedActive: string; - isNotWiredActive: string; - isWiredActive: string; - - jumpToDate?: Date; - onSelectDate: (date?: Date) => void; - - orders: (MerchantBackend.Orders.OrderHistoryEntry & WithId)[]; - onLoadMoreBefore?: () => void; - hasMoreBefore?: boolean; - hasMoreAfter?: boolean; - onLoadMoreAfter?: () => void; - - onSelectOrder: (o: MerchantBackend.Orders.OrderHistoryEntry & WithId) => void; - onRefundOrder: (o: MerchantBackend.Orders.OrderHistoryEntry & WithId) => void; - onCreate: () => void; -} - -export function ListPage({ - hasMoreAfter, - hasMoreBefore, - onLoadMoreAfter, - onLoadMoreBefore, - orders, - isAllActive, - onSelectOrder, - onRefundOrder, - jumpToDate, - onCopyURL, - onShowAll, - onShowPaid, - onShowNotPaid, - onShowRefunded, - onShowNotWired, - onShowWired, - onSelectDate, - isPaidActive, - isRefundedActive, - isNotWiredActive, - onCreate, - isNotPaidActive, - isWiredActive, -}: ListPageProps): VNode { - const { i18n } = useTranslationContext(); - const dateTooltip = i18n.str`select date to show nearby orders`; - const [pickDate, setPickDate] = useState(false); - const [settings] = useSettings(); - - return ( - -
-
-
- -
-
-
-
-
- {jumpToDate && ( - - )} -
- - { - setPickDate(true); - }} - /> - -
- -
-
-
-
- - setPickDate(false)} - dateReceiver={onSelectDate} - /> - - -
- ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/orders/list/Table.tsx b/packages/auditor-backoffice-ui/src/paths/instance/orders/list/Table.tsx deleted file mode 100644 index cbe8331ca..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/orders/list/Table.tsx +++ /dev/null @@ -1,417 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { Amounts } from "@gnu-taler/taler-util"; -import { useTranslationContext } from "@gnu-taler/web-util/browser"; -import { format } from "date-fns"; -import { h, VNode } from "preact"; -import { StateUpdater, useState } from "preact/hooks"; -import { - FormErrors, - FormProvider, -} from "../../../../components/form/FormProvider.js"; -import { Input } from "../../../../components/form/Input.js"; -import { InputCurrency } from "../../../../components/form/InputCurrency.js"; -import { InputGroup } from "../../../../components/form/InputGroup.js"; -import { InputSelector } from "../../../../components/form/InputSelector.js"; -import { ConfirmModal } from "../../../../components/modal/index.js"; -import { useConfigContext } from "../../../../context/config.js"; -import { MerchantBackend, WithId } from "../../../../declaration.js"; -import { mergeRefunds } from "../../../../utils/amount.js"; -import { datetimeFormatForSettings, useSettings } from "../../../../hooks/useSettings.js"; - -type Entity = MerchantBackend.Orders.OrderHistoryEntry & WithId; -interface Props { - orders: Entity[]; - onRefund: (value: Entity) => void; - onCopyURL: (id: string) => void; - onCreate: () => void; - onSelect: (order: Entity) => void; - onLoadMoreBefore?: () => void; - hasMoreBefore?: boolean; - hasMoreAfter?: boolean; - onLoadMoreAfter?: () => void; -} - -export function CardTable({ - orders, - onCreate, - onRefund, - onCopyURL, - onSelect, - onLoadMoreAfter, - onLoadMoreBefore, - hasMoreAfter, - hasMoreBefore, -}: Props): VNode { - const [rowSelection, rowSelectionHandler] = useState([]); - - const { i18n } = useTranslationContext(); - - return ( -
-
-

- - - - Orders -

- -
- -
- - - -
-
-
-
-
- {orders.length > 0 ? ( - onCopyURL(o.id)} - rowSelection={rowSelection} - rowSelectionHandler={rowSelectionHandler} - onLoadMoreAfter={onLoadMoreAfter} - onLoadMoreBefore={onLoadMoreBefore} - hasMoreAfter={hasMoreAfter} - hasMoreBefore={hasMoreBefore} - /> - ) : ( - - )} - - - - - ); -} -interface TableProps { - rowSelection: string[]; - instances: Entity[]; - onRefund: (id: Entity) => void; - onCopyURL: (id: Entity) => void; - onSelect: (id: Entity) => void; - rowSelectionHandler: StateUpdater; - onLoadMoreBefore?: () => void; - hasMoreBefore?: boolean; - hasMoreAfter?: boolean; - onLoadMoreAfter?: () => void; -} - -function Table({ - instances, - onSelect, - onRefund, - onCopyURL, - onLoadMoreAfter, - onLoadMoreBefore, - hasMoreAfter, - hasMoreBefore, -}: TableProps): VNode { - const { i18n } = useTranslationContext(); - const [settings] = useSettings(); - return ( -
- {hasMoreBefore && ( - - )} -
- - - - - - - - - {instances.map((i) => { - return ( - - - - - - - ); - })} - -
- Date - - Amount - - Summary - -
onSelect(i)} - style={{ cursor: "pointer" }} - > - {i.timestamp.t_s === "never" - ? "never" - : format( - new Date(i.timestamp.t_s * 1000), - datetimeFormatForSettings(settings), - )} - onSelect(i)} - style={{ cursor: "pointer" }} - > - {i.amount} - onSelect(i)} - style={{ cursor: "pointer" }} - > - {i.summary} - -
- {i.refundable && ( - - )} - {!i.paid && ( - - )} -
-
- {hasMoreAfter && ( - - )} -
- ); -} - -function EmptyTable(): VNode { - const { i18n } = useTranslationContext(); - return ( -
-

- - - -

-

- - No orders have been found matching your query! - -

-
- ); -} - -interface RefundModalProps { - onCancel: () => void; - onConfirm: (value: MerchantBackend.Orders.RefundRequest) => void; - order: MerchantBackend.Orders.MerchantOrderStatusResponse; -} - -export function RefundModal({ - order, - onCancel, - onConfirm, -}: RefundModalProps): VNode { - type State = { mainReason?: string; description?: string; refund?: string }; - const [form, setValue] = useState({}); - const [settings] = useSettings(); - const { i18n } = useTranslationContext(); - // const [errors, setErrors] = useState>({}); - - const refunds = ( - order.order_status === "paid" ? order.refund_details : [] - ).reduce(mergeRefunds, []); - - const config = useConfigContext(); - const totalRefunded = refunds - .map((r) => r.amount) - .reduce( - (p, c) => Amounts.add(p, Amounts.parseOrThrow(c)).amount, - Amounts.zeroOfCurrency(config.currency), - ); - const orderPrice = - order.order_status === "paid" - ? Amounts.parseOrThrow(order.contract_terms.amount) - : undefined; - const totalRefundable = !orderPrice - ? Amounts.zeroOfCurrency(totalRefunded.currency) - : refunds.length - ? Amounts.sub(orderPrice, totalRefunded).amount - : orderPrice; - - const isRefundable = Amounts.isNonZero(totalRefundable); - const duplicatedText = i18n.str`duplicated`; - - const errors: FormErrors = { - mainReason: !form.mainReason ? i18n.str`required` : undefined, - description: - !form.description && form.mainReason !== duplicatedText - ? i18n.str`required` - : undefined, - refund: !form.refund - ? i18n.str`required` - : !Amounts.parse(form.refund) - ? i18n.str`invalid format` - : Amounts.cmp(totalRefundable, Amounts.parse(form.refund)!) === -1 - ? i18n.str`this value exceed the refundable amount` - : undefined, - }; - const hasErrors = Object.keys(errors).some( - (k) => (errors as any)[k] !== undefined, - ); - - const validateAndConfirm = () => { - try { - if (!form.refund) return; - onConfirm({ - refund: Amounts.stringify( - Amounts.add(Amounts.parse(form.refund)!, totalRefunded).amount, - ), - reason: - form.description === undefined - ? form.mainReason || "" - : `${form.mainReason}: ${form.description}`, - }); - } catch (err) { - console.log(err); - } - }; - - //FIXME: parameters in the translation - return ( - - {refunds.length > 0 && ( -
-
- - - - - - - - - - - {refunds.map((r) => { - return ( - - - - - - ); - })} - -
- date - - amount - - reason -
- {r.timestamp.t_s === "never" - ? "never" - : format( - new Date(r.timestamp.t_s * 1000), - datetimeFormatForSettings(settings), - )} - {r.amount}{r.reason}
-
-
-
- )} - - {isRefundable && ( - - errors={errors} - object={form} - valueHandler={(d) => setValue(d as any)} - > - - name="refund" - label={i18n.str`Refund`} - tooltip={i18n.str`amount to be refunded`} - > - Max refundable:{" "} - {Amounts.stringify(totalRefundable)} - - - {form.mainReason && form.mainReason !== duplicatedText ? ( - - label={i18n.str`Description`} - name="description" - tooltip={i18n.str`more information to give context`} - /> - ) : undefined} - - )} -
- ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/orders/list/index.tsx b/packages/auditor-backoffice-ui/src/paths/instance/orders/list/index.tsx deleted file mode 100644 index 369ef8c8b..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/orders/list/index.tsx +++ /dev/null @@ -1,231 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { - ErrorType, - HttpError, - useTranslationContext, -} from "@gnu-taler/web-util/browser"; -import { Fragment, h, VNode } from "preact"; -import { useState } from "preact/hooks"; -import { Loading } from "../../../../components/exception/loading.js"; -import { NotificationCard } from "../../../../components/menu/index.js"; -import { MerchantBackend } from "../../../../declaration.js"; -import { - InstanceOrderFilter, - useInstanceOrders, - useOrderAPI, - useOrderDetails, -} from "../../../../hooks/order.js"; -import { Notification } from "../../../../utils/types.js"; -import { ListPage } from "./ListPage.js"; -import { RefundModal } from "./Table.js"; -import { HttpStatusCode } from "@gnu-taler/taler-util"; -import { JumpToElementById } from "../../../../components/form/JumpToElementById.js"; - -interface Props { - onUnauthorized: () => VNode; - onLoadError: (error: HttpError) => VNode; - onNotFound: () => VNode; - onSelect: (id: string) => void; - onCreate: () => void; -} - -export default function OrderList({ - onUnauthorized, - onLoadError, - onCreate, - onSelect, - onNotFound, -}: Props): VNode { - const [filter, setFilter] = useState({ paid: "no" }); - const [orderToBeRefunded, setOrderToBeRefunded] = useState< - MerchantBackend.Orders.OrderHistoryEntry | undefined - >(undefined); - - const setNewDate = (date?: Date): void => - setFilter((prev) => ({ ...prev, date })); - - const result = useInstanceOrders(filter, setNewDate); - const { refundOrder, getPaymentURL } = useOrderAPI(); - - const [notif, setNotif] = useState(undefined); - - const { i18n } = useTranslationContext(); - - if (result.loading) return ; - if (!result.ok) { - if ( - result.type === ErrorType.CLIENT && - result.status === HttpStatusCode.Unauthorized - ) - return onUnauthorized(); - if ( - result.type === ErrorType.CLIENT && - result.status === HttpStatusCode.NotFound - ) - return onNotFound(); - return onLoadError(result); - } - - const isNotPaidActive = filter.paid === "no" ? "is-active" : ""; - const isPaidActive = filter.paid === "yes" && filter.wired === undefined ? "is-active" : ""; - const isRefundedActive = filter.refunded === "yes" ? "is-active" : ""; - const isNotWiredActive = filter.wired === "no" && filter.paid === "yes" ? "is-active" : ""; - const isWiredActive = filter.wired === "yes" ? "is-active" : ""; - const isAllActive = - filter.paid === undefined && - filter.refunded === undefined && - filter.wired === undefined - ? "is-active" - : ""; - - return ( -
- - - - - ({ ...o, id: o.order_id }))} - onLoadMoreBefore={result.loadMorePrev} - hasMoreBefore={!result.isReachingStart} - onLoadMoreAfter={result.loadMore} - hasMoreAfter={!result.isReachingEnd} - onSelectOrder={(order) => onSelect(order.id)} - onRefundOrder={(value) => setOrderToBeRefunded(value)} - isAllActive={isAllActive} - isNotWiredActive={isNotWiredActive} - isWiredActive={isWiredActive} - isPaidActive={isPaidActive} - isNotPaidActive={isNotPaidActive} - isRefundedActive={isRefundedActive} - jumpToDate={filter.date} - onCopyURL={(id) => - getPaymentURL(id).then((resp) => copyToClipboard(resp.data)) - } - onCreate={onCreate} - onSelectDate={setNewDate} - onShowAll={() => setFilter({})} - onShowNotPaid={() => setFilter({ paid: "no" })} - onShowPaid={() => setFilter({ paid: "yes" })} - onShowRefunded={() => setFilter({ refunded: "yes" })} - onShowNotWired={() => setFilter({ wired: "no", paid: "yes" })} - onShowWired={() => setFilter({ wired: "yes" })} - /> - - {orderToBeRefunded && ( - setOrderToBeRefunded(undefined)} - onConfirm={(value) => - refundOrder(orderToBeRefunded.order_id, value) - .then(() => - setNotif({ - message: i18n.str`refund created successfully`, - type: "SUCCESS", - }), - ) - .catch((error) => - setNotif({ - message: i18n.str`could not create the refund`, - type: "ERROR", - description: error.message, - }), - ) - .then(() => setOrderToBeRefunded(undefined)) - } - onLoadError={(error) => { - setNotif({ - message: i18n.str`could not create the refund`, - type: "ERROR", - description: error.message, - }); - setOrderToBeRefunded(undefined); - return
; - }} - onUnauthorized={onUnauthorized} - onNotFound={() => { - setNotif({ - message: i18n.str`could not get the order to refund`, - type: "ERROR", - // description: error.message - }); - setOrderToBeRefunded(undefined); - return
; - }} - /> - )} -
- ); -} - -interface RefundProps { - id: string; - onUnauthorized: () => VNode; - onLoadError: (error: HttpError) => VNode; - onNotFound: () => VNode; - onCancel: () => void; - onConfirm: (m: MerchantBackend.Orders.RefundRequest) => void; -} - -function RefundModalForTable({ - id, - onUnauthorized, - onLoadError, - onNotFound, - onConfirm, - onCancel, -}: RefundProps): VNode { - const result = useOrderDetails(id); - - if (result.loading) return ; - if (!result.ok) { - if ( - result.type === ErrorType.CLIENT && - result.status === HttpStatusCode.Unauthorized - ) - return onUnauthorized(); - if ( - result.type === ErrorType.CLIENT && - result.status === HttpStatusCode.NotFound - ) - return onNotFound(); - return onLoadError(result); - } - - return ( - - ); -} - -async function copyToClipboard(text: string): Promise { - return navigator.clipboard.writeText(text); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/create/Create.stories.tsx b/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/create/Create.stories.tsx deleted file mode 100644 index 36b31ebe8..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/create/Create.stories.tsx +++ /dev/null @@ -1,28 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { h, VNode, FunctionalComponent } from "preact"; -import { CreatePage as TestedComponent } from "./CreatePage.js"; - -export default { - title: "Pages/OtpDevices/Create", - component: TestedComponent, -}; diff --git a/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/create/CreatePage.tsx b/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/create/CreatePage.tsx deleted file mode 100644 index e3ecb3243..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/create/CreatePage.tsx +++ /dev/null @@ -1,179 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { isRfc3548Base32Charset, randomRfc3548Base32Key } from "@gnu-taler/taler-util"; -import { useTranslationContext } from "@gnu-taler/web-util/browser"; -import { Fragment, h, VNode } from "preact"; -import { useState } from "preact/hooks"; -import { AsyncButton } from "../../../../components/exception/AsyncButton.js"; -import { - FormErrors, - FormProvider, -} from "../../../../components/form/FormProvider.js"; -import { Input } from "../../../../components/form/Input.js"; -import { InputSelector } from "../../../../components/form/InputSelector.js"; -import { InputWithAddon } from "../../../../components/form/InputWithAddon.js"; -import { useBackendContext } from "../../../../context/backend.js"; -import { MerchantBackend } from "../../../../declaration.js"; - -type Entity = MerchantBackend.OTP.OtpDeviceAddDetails; - -interface Props { - onCreate: (d: Entity) => Promise; - onBack?: () => void; -} - -const algorithms = [0, 1, 2]; -const algorithmsNames = ["off", "30s 8d TOTP-SHA1", "30s 8d eTOTP-SHA1"]; - -export function CreatePage({ onCreate, onBack }: Props): VNode { - const { i18n } = useTranslationContext(); - const backend = useBackendContext(); - - const [state, setState] = useState>({}); - - const [showKey, setShowKey] = useState(false); - - const errors: FormErrors = { - otp_device_id: !state.otp_device_id - ? i18n.str`required` - : !/[a-zA-Z0-9]*/.test(state.otp_device_id) - ? i18n.str`no valid. only characters and numbers` - : undefined, - otp_algorithm: !state.otp_algorithm ? i18n.str`required` : undefined, - otp_key: !state.otp_key - ? i18n.str`required` - : !isRfc3548Base32Charset(state.otp_key) - ? i18n.str`just letters and numbers from 2 to 7` - : state.otp_key.length !== 32 - ? i18n.str`size of the key should be 32` - : undefined, - otp_device_description: !state.otp_device_description - ? i18n.str`required` - : !/[a-zA-Z0-9]*/.test(state.otp_device_description) - ? i18n.str`no valid. only characters and numbers` - : undefined, - }; - - const hasErrors = Object.keys(errors).some( - (k) => (errors as any)[k] !== undefined, - ); - - const submitForm = () => { - if (hasErrors) return Promise.reject(); - return onCreate(state as any); - }; - - return ( -
-
-
-
-
- - - name="otp_device_id" - label={i18n.str`ID`} - tooltip={i18n.str`Internal id on the system`} - /> - - name="otp_device_description" - label={i18n.str`Descripiton`} - tooltip={i18n.str`Useful to identify the device physically`} - /> - - name="otp_algorithm" - label={i18n.str`Verification algorithm`} - tooltip={i18n.str`Algorithm to use to verify transaction in offline mode`} - values={algorithms} - toStr={(v) => algorithmsNames[v]} - fromStr={(v) => Number(v)} - /> - {state.otp_algorithm && state.otp_algorithm > 0 ? ( - - - expand - name="otp_key" - label={i18n.str`Device key`} - inputType={showKey ? "text" : "password"} - help="Be sure to be very hard to guess or use the random generator" - tooltip={i18n.str`Your device need to have exactly the same value`} - fromStr={(v) => v.toUpperCase()} - addonAfterAction={() => { - setShowKey(!showKey); - }} - addonAfter={ - - {showKey ? ( - - ) : ( - - )} - - } - side={ - - } - /> - - ) : undefined} - - -
- {onBack && ( - - )} - - Confirm - -
-
-
-
-
-
- ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/create/CreatedSuccessfully.tsx b/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/create/CreatedSuccessfully.tsx deleted file mode 100644 index cf60925a4..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/create/CreatedSuccessfully.tsx +++ /dev/null @@ -1,104 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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, VNode, h } from "preact"; -import { QR } from "../../../../components/exception/QR.js"; -import { CreatedSuccessfully as Template } from "../../../../components/notifications/CreatedSuccessfully.js"; -import { useInstanceContext } from "../../../../context/instance.js"; -import { MerchantBackend } from "../../../../declaration.js"; -import { useBackendContext } from "../../../../context/backend.js"; - -type Entity = MerchantBackend.OTP.OtpDeviceAddDetails; - -interface Props { - entity: Entity; - onConfirm: () => void; -} - -function isNotUndefined(x: X | undefined): x is X { - return !!x; -} - -export function CreatedSuccessfully({ - entity, - onConfirm, -}: Props): VNode { - const { i18n } = useTranslationContext(); - const { url: backendURL } = useBackendContext() - const { id: instanceId } = useInstanceContext(); - const issuer = new URL(backendURL).hostname; - const qrText = `otpauth://totp/${instanceId}/${entity.otp_device_id}?issuer=${issuer}&algorithm=SHA1&digits=8&period=30&secret=${entity.otp_key}`; - const qrTextSafe = `otpauth://totp/${instanceId}/${entity.otp_device_id}?issuer=${issuer}&algorithm=SHA1&digits=8&period=30&secret=${entity.otp_key.substring(0, 6)}...`; - - return ( - - ); -} - diff --git a/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/create/index.tsx b/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/create/index.tsx deleted file mode 100644 index f0b419f68..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/create/index.tsx +++ /dev/null @@ -1,70 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { useTranslationContext } from "@gnu-taler/web-util/browser"; -import { Fragment, h, VNode } from "preact"; -import { useState } from "preact/hooks"; -import { NotificationCard } from "../../../../components/menu/index.js"; -import { MerchantBackend } from "../../../../declaration.js"; -import { useWebhookAPI } from "../../../../hooks/webhooks.js"; -import { Notification } from "../../../../utils/types.js"; -import { CreatePage } from "./CreatePage.js"; -import { useOtpDeviceAPI } from "../../../../hooks/otp.js"; -import { CreatedSuccessfully } from "./CreatedSuccessfully.js"; - -export type Entity = MerchantBackend.OTP.OtpDeviceAddDetails; -interface Props { - onBack?: () => void; - onConfirm: () => void; -} - -export default function CreateValidator({ onConfirm, onBack }: Props): VNode { - const { createOtpDevice } = useOtpDeviceAPI(); - const [notif, setNotif] = useState(undefined); - const { i18n } = useTranslationContext(); - const [created, setCreated] = useState(null) - - if (created) { - return - } - - return ( - <> - - { - return createOtpDevice(request) - .then((d) => { - setCreated(request) - }) - .catch((error) => { - setNotif({ - message: i18n.str`could not create device`, - type: "ERROR", - description: error.message, - }); - }); - }} - /> - - ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/list/List.stories.tsx b/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/list/List.stories.tsx deleted file mode 100644 index 49032c80e..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/list/List.stories.tsx +++ /dev/null @@ -1,28 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { FunctionalComponent, h } from "preact"; -import { ListPage as TestedComponent } from "./ListPage.js"; - -export default { - title: "Pages/OtpDevices/List", - component: TestedComponent, -}; diff --git a/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/list/ListPage.tsx b/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/list/ListPage.tsx deleted file mode 100644 index f3b5a2088..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/list/ListPage.tsx +++ /dev/null @@ -1,64 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { h, VNode } from "preact"; -import { MerchantBackend } from "../../../../declaration.js"; -import { useTranslationContext } from "@gnu-taler/web-util/browser"; -import { CardTable } from "./Table.js"; - -export interface Props { - devices: MerchantBackend.OTP.OtpDeviceEntry[]; - onLoadMoreBefore?: () => void; - onLoadMoreAfter?: () => void; - onCreate: () => void; - onDelete: (e: MerchantBackend.OTP.OtpDeviceEntry) => void; - onSelect: (e: MerchantBackend.OTP.OtpDeviceEntry) => void; -} - -export function ListPage({ - devices, - onCreate, - onDelete, - onSelect, - onLoadMoreBefore, - onLoadMoreAfter, -}: Props): VNode { - const form = { payto_uri: "" }; - - const { i18n } = useTranslationContext(); - return ( -
- ({ - ...o, - id: String(o.otp_device_id), - }))} - onCreate={onCreate} - onDelete={onDelete} - onSelect={onSelect} - onLoadMoreBefore={onLoadMoreBefore} - hasMoreBefore={!onLoadMoreBefore} - onLoadMoreAfter={onLoadMoreAfter} - hasMoreAfter={!onLoadMoreAfter} - /> -
- ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/list/Table.tsx b/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/list/Table.tsx deleted file mode 100644 index d085d1c44..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/list/Table.tsx +++ /dev/null @@ -1,211 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { useTranslationContext } from "@gnu-taler/web-util/browser"; -import { h, VNode } from "preact"; -import { StateUpdater, useState } from "preact/hooks"; -import { MerchantBackend } from "../../../../declaration.js"; - -type Entity = MerchantBackend.OTP.OtpDeviceEntry; - -interface Props { - devices: Entity[]; - onDelete: (e: Entity) => void; - onSelect: (e: Entity) => void; - onCreate: () => void; - onLoadMoreBefore?: () => void; - hasMoreBefore?: boolean; - hasMoreAfter?: boolean; - onLoadMoreAfter?: () => void; -} - -export function CardTable({ - devices, - onCreate, - onDelete, - onSelect, - onLoadMoreAfter, - onLoadMoreBefore, - hasMoreAfter, - hasMoreBefore, -}: Props): VNode { - const [rowSelection, rowSelectionHandler] = useState([]); - - const { i18n } = useTranslationContext(); - - return ( -
-
-

- - - - OTP Devices -

-
- - - -
-
-
-
-
- {devices.length > 0 ? ( - - ) : ( - - )} - - - - - ); -} -interface TableProps { - rowSelection: string[]; - instances: Entity[]; - onDelete: (e: Entity) => void; - onSelect: (e: Entity) => void; - rowSelectionHandler: StateUpdater; - onLoadMoreBefore?: () => void; - hasMoreBefore?: boolean; - hasMoreAfter?: boolean; - onLoadMoreAfter?: () => void; -} - -function toggleSelected(id: T): (prev: T[]) => T[] { - return (prev: T[]): T[] => - prev.indexOf(id) == -1 ? [...prev, id] : prev.filter((e) => e != id); -} - -function Table({ - instances, - onLoadMoreAfter, - onDelete, - onSelect, - onLoadMoreBefore, - hasMoreAfter, - hasMoreBefore, -}: TableProps): VNode { - const { i18n } = useTranslationContext(); - return ( -
- {hasMoreBefore && ( - - )} -
- - - - - - - - {instances.map((i) => { - return ( - - - - - - ); - })} - -
- ID - - Description - -
onSelect(i)} - style={{ cursor: "pointer" }} - > - {i.otp_device_id} - onSelect(i)} - style={{ cursor: "pointer" }} - > - {i.otp_device_id} - -
- -
-
- {hasMoreAfter && ( - - )} -
- ); -} - -function EmptyTable(): VNode { - const { i18n } = useTranslationContext(); - return ( -
-

- - - -

-

- - There is no devices yet, add more pressing the + sign - -

-
- ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/list/index.tsx b/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/list/index.tsx deleted file mode 100644 index a3299326c..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/list/index.tsx +++ /dev/null @@ -1,106 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { HttpStatusCode } from "@gnu-taler/taler-util"; -import { - ErrorType, - HttpError, - useTranslationContext, -} from "@gnu-taler/web-util/browser"; -import { Fragment, VNode, h } from "preact"; -import { useState } from "preact/hooks"; -import { Loading } from "../../../../components/exception/loading.js"; -import { NotificationCard } from "../../../../components/menu/index.js"; -import { MerchantBackend } from "../../../../declaration.js"; -import { useInstanceOtpDevices, useOtpDeviceAPI } from "../../../../hooks/otp.js"; -import { Notification } from "../../../../utils/types.js"; -import { ListPage } from "./ListPage.js"; - -interface Props { - onUnauthorized: () => VNode; - onLoadError: (error: HttpError) => VNode; - onNotFound: () => VNode; - onCreate: () => void; - onSelect: (id: string) => void; -} - -export default function ListOtpDevices({ - onUnauthorized, - onLoadError, - onCreate, - onSelect, - onNotFound, -}: Props): VNode { - const [position, setPosition] = useState(undefined); - const { i18n } = useTranslationContext(); - const [notif, setNotif] = useState(undefined); - const { deleteOtpDevice } = useOtpDeviceAPI(); - const result = useInstanceOtpDevices({ position }, (id) => setPosition(id)); - - if (result.loading) return ; - if (!result.ok) { - if ( - result.type === ErrorType.CLIENT && - result.status === HttpStatusCode.Unauthorized - ) - return onUnauthorized(); - if ( - result.type === ErrorType.CLIENT && - result.status === HttpStatusCode.NotFound - ) - return onNotFound(); - return onLoadError(result); - } - - return ( - - - - { - onSelect(e.otp_device_id); - }} - onDelete={(e: MerchantBackend.OTP.OtpDeviceEntry) => - deleteOtpDevice(e.otp_device_id) - .then(() => - setNotif({ - message: i18n.str`validator delete successfully`, - type: "SUCCESS", - }), - ) - .catch((error) => - setNotif({ - message: i18n.str`could not delete the validator`, - type: "ERROR", - description: error.message, - }), - ) - } - /> - - ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/update/Update.stories.tsx b/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/update/Update.stories.tsx deleted file mode 100644 index 06ea9d07a..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/update/Update.stories.tsx +++ /dev/null @@ -1,32 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { h, VNode, FunctionalComponent } from "preact"; -import { UpdatePage as TestedComponent } from "./UpdatePage.js"; - -export default { - title: "Pages/OtpDevices/Update", - component: TestedComponent, - argTypes: { - onUpdate: { action: "onUpdate" }, - onBack: { action: "onBack" }, - }, -}; diff --git a/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/update/UpdatePage.tsx b/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/update/UpdatePage.tsx deleted file mode 100644 index 310810576..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/update/UpdatePage.tsx +++ /dev/null @@ -1,186 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { randomRfc3548Base32Key } from "@gnu-taler/taler-util"; -import { useTranslationContext } from "@gnu-taler/web-util/browser"; -import { Fragment, h, VNode } from "preact"; -import { useState } from "preact/hooks"; -import { AsyncButton } from "../../../../components/exception/AsyncButton.js"; -import { - FormErrors, - FormProvider, -} from "../../../../components/form/FormProvider.js"; -import { Input } from "../../../../components/form/Input.js"; -import { InputSelector } from "../../../../components/form/InputSelector.js"; -import { InputWithAddon } from "../../../../components/form/InputWithAddon.js"; -import { MerchantBackend, WithId } from "../../../../declaration.js"; - -type Entity = MerchantBackend.OTP.OtpDevicePatchDetails & WithId; - -interface Props { - onUpdate: (d: Entity) => Promise; - onBack?: () => void; - device: Entity; -} -const algorithms = [0, 1, 2]; -const algorithmsNames = ["off", "30s 8d TOTP-SHA1", "30s 8d eTOTP-SHA1"]; -export function UpdatePage({ device, onUpdate, onBack }: Props): VNode { - const { i18n } = useTranslationContext(); - - const [state, setState] = useState>(device); - const [showKey, setShowKey] = useState(false); - - const errors: FormErrors = {}; - - const hasErrors = Object.keys(errors).some( - (k) => (errors as any)[k] !== undefined, - ); - - const submitForm = () => { - if (hasErrors) return Promise.reject(); - return onUpdate(state as any); - }; - - return ( -
-
-
-
-
-
-
- - Device: {device.id} - -
-
-
-
-
-
- -
-
-
- - - name="otp_device_description" - label={i18n.str`Description`} - tooltip={i18n.str`Useful to identify the device physically`} - /> - - name="otp_algorithm" - label={i18n.str`Verification algorithm`} - tooltip={i18n.str`Algorithm to use to verify transaction in offline mode`} - values={algorithms} - toStr={(v) => algorithmsNames[v]} - fromStr={(v) => Number(v)} - /> - {state.otp_algorithm && state.otp_algorithm > 0 ? ( - - - name="otp_key" - label={i18n.str`Device key`} - readonly={state.otp_key === undefined} - inputType={showKey ? "text" : "password"} - help={ - state.otp_key === undefined - ? "Not modified" - : "Be sure to be very hard to guess or use the random generator" - } - tooltip={i18n.str`Your device need to have exactly the same value`} - fromStr={(v) => v.toUpperCase()} - addonAfterAction={() => { - setShowKey(!showKey); - }} - addonAfter={ - { - setShowKey(!showKey); - }} - > - {showKey ? ( - - ) : ( - - )} - - } - side={ - state.otp_key === undefined ? ( - - ) : ( - - ) - } - /> - - ) : undefined}{" "} - - -
- {onBack && ( - - )} - - Confirm - -
-
-
-
-
-
- ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/update/index.tsx b/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/update/index.tsx deleted file mode 100644 index 3128608e1..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/otp_devices/update/index.tsx +++ /dev/null @@ -1,102 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { - ErrorType, - HttpError, - useTranslationContext, -} from "@gnu-taler/web-util/browser"; -import { Fragment, h, VNode } from "preact"; -import { useState } from "preact/hooks"; -import { Loading } from "../../../../components/exception/loading.js"; -import { NotificationCard } from "../../../../components/menu/index.js"; -import { MerchantBackend, WithId } from "../../../../declaration.js"; -import { Notification } from "../../../../utils/types.js"; -import { UpdatePage } from "./UpdatePage.js"; -import { HttpStatusCode } from "@gnu-taler/taler-util"; -import { useOtpDeviceAPI, useOtpDeviceDetails } from "../../../../hooks/otp.js"; - -export type Entity = MerchantBackend.OTP.OtpDevicePatchDetails & WithId; - -interface Props { - onBack?: () => void; - onConfirm: () => void; - onUnauthorized: () => VNode; - onNotFound: () => VNode; - onLoadError: (e: HttpError) => VNode; - vid: string; -} -export default function UpdateValidator({ - vid, - onConfirm, - onBack, - onUnauthorized, - onNotFound, - onLoadError, -}: Props): VNode { - const { updateOtpDevice } = useOtpDeviceAPI(); - const result = useOtpDeviceDetails(vid); - const [notif, setNotif] = useState(undefined); - - const { i18n } = useTranslationContext(); - - if (result.loading) return ; - if (!result.ok) { - if ( - result.type === ErrorType.CLIENT && - result.status === HttpStatusCode.Unauthorized - ) - return onUnauthorized(); - if ( - result.type === ErrorType.CLIENT && - result.status === HttpStatusCode.NotFound - ) - return onNotFound(); - return onLoadError(result); - } - - return ( - - - { - return updateOtpDevice(vid, data) - .then(onConfirm) - .catch((error) => { - setNotif({ - message: i18n.str`could not update template`, - type: "ERROR", - description: error.message, - }); - }); - }} - /> - - ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/products/create/Create.stories.tsx b/packages/auditor-backoffice-ui/src/paths/instance/products/create/Create.stories.tsx deleted file mode 100644 index 22bbfe28a..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/products/create/Create.stories.tsx +++ /dev/null @@ -1,43 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { h, VNode, FunctionalComponent } from "preact"; -import { CreatePage as TestedComponent } from "./CreatePage.js"; - -export default { - title: "Pages/Product/Create", - component: TestedComponent, - argTypes: { - onCreate: { action: "onCreate" }, - onBack: { action: "onBack" }, - }, -}; - -function createExample( - Component: FunctionalComponent, - props: Partial, -) { - const r = (args: any) => ; - r.args = props; - return r; -} - -export const Example = createExample(TestedComponent, {}); diff --git a/packages/auditor-backoffice-ui/src/paths/instance/products/create/CreatePage.tsx b/packages/auditor-backoffice-ui/src/paths/instance/products/create/CreatePage.tsx deleted file mode 100644 index 6cbc26d8d..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/products/create/CreatePage.tsx +++ /dev/null @@ -1,80 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 - */ - -/** - * - * @author Sebastian Javier Marchano (sebasjm) - */ - -import { useTranslationContext } from "@gnu-taler/web-util/browser"; -import { h, VNode } from "preact"; -import { AsyncButton } from "../../../../components/exception/AsyncButton.js"; -import { ProductForm } from "../../../../components/product/ProductForm.js"; -import { MerchantBackend } from "../../../../declaration.js"; -import { useListener } from "../../../../hooks/listener.js"; - -type Entity = MerchantBackend.Products.ProductAddDetail & { - product_id: string; -}; - -interface Props { - onCreate: (d: Entity) => Promise; - onBack?: () => void; -} - -export function CreatePage({ onCreate, onBack }: Props): VNode { - const [submitForm, addFormSubmitter] = useListener( - (result) => { - if (result) return onCreate(result); - return Promise.reject(); - }, - ); - - const { i18n } = useTranslationContext(); - - return ( -
-
-
-
-
- - -
- {onBack && ( - - )} - - Confirm - -
-
-
-
-
-
- ); -} diff --git a/packages/auditor-backoffice-ui/src/paths/instance/products/create/CreatedSuccessfully.tsx b/packages/auditor-backoffice-ui/src/paths/instance/products/create/CreatedSuccessfully.tsx deleted file mode 100644 index 2b6ebed45..000000000 --- a/packages/auditor-backoffice-ui/src/paths/instance/products/create/CreatedSuccessfully.tsx +++ /dev/null @@ -1,72 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2021-2024 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 { h, VNode } from "preact"; -import { CreatedSuccessfully as Template } from "../../../../components/notifications/CreatedSuccessfully.js"; -import { Entity } from "./index.js"; -import emptyImage from "../../assets/empty.png"; - -interface Props { - entity: Entity; - onConfirm: () => void; - onCreateAnother?: () => void; -} - -export function CreatedSuccessfully({ - entity, - onConfirm, - onCreateAnother, -}: Props): VNode { - return ( -