From 3e060b80428943c6562250a6ff77eff10a0259b7 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 24 Oct 2022 10:46:14 +0200 Subject: repo: integrate packages from former merchant-backoffice.git --- packages/merchant-backoffice-ui/src/.babelrc | 26 + .../merchant-backoffice-ui/src/AdminRoutes.tsx | 58 + .../src/ApplicationReadyRoutes.tsx | 120 + .../merchant-backoffice-ui/src/InstanceRoutes.tsx | 528 +++ .../merchant-backoffice-ui/src/assets/empty.png | Bin 0 -> 2785 bytes .../src/assets/icons/android-chrome-192x192.png | Bin 0 -> 14058 bytes .../src/assets/icons/android-chrome-512x512.png | Bin 0 -> 51484 bytes .../src/assets/icons/apple-touch-icon.png | Bin 0 -> 12746 bytes .../src/assets/icons/favicon-16x16.png | Bin 0 -> 626 bytes .../src/assets/icons/favicon-32x32.png | Bin 0 -> 1487 bytes .../src/assets/icons/languageicon.svg | 48 + .../src/assets/icons/mstile-150x150.png | Bin 0 -> 9050 bytes .../merchant-backoffice-ui/src/assets/logo.jpeg | Bin 0 -> 39336 bytes .../src/components/exception/AsyncButton.tsx | 49 + .../src/components/exception/QR.tsx | 49 + .../src/components/exception/loading.tsx | 32 + .../src/components/exception/login.tsx | 143 + .../src/components/form/FormProvider.tsx | 81 + .../src/components/form/Input.tsx | 71 + .../src/components/form/InputArray.tsx | 97 + .../src/components/form/InputBoolean.tsx | 72 + .../src/components/form/InputCurrency.tsx | 47 + .../src/components/form/InputDate.tsx | 159 + .../src/components/form/InputDuration.tsx | 172 + .../src/components/form/InputGroup.tsx | 66 + .../src/components/form/InputImage.tsx | 95 + .../src/components/form/InputLocation.tsx | 43 + .../src/components/form/InputNumber.tsx | 42 + .../src/components/form/InputPayto.tsx | 39 + .../src/components/form/InputPaytoForm.tsx | 392 +++ .../src/components/form/InputSearchProduct.tsx | 139 + .../src/components/form/InputSecured.stories.tsx | 55 + .../src/components/form/InputSecured.tsx | 119 + .../src/components/form/InputSelector.tsx | 86 + .../src/components/form/InputStock.stories.tsx | 162 + .../src/components/form/InputStock.tsx | 171 + .../src/components/form/InputTaxes.tsx | 97 + .../src/components/form/InputWithAddon.tsx | 77 + .../src/components/form/TextField.tsx | 53 + .../src/components/form/useField.tsx | 86 + .../src/components/form/useGroupField.tsx | 40 + .../instance/DefaultInstanceFormFields.tsx | 135 + .../src/components/menu/LangSelector.tsx | 73 + .../src/components/menu/NavigationBar.tsx | 58 + .../src/components/menu/SideBar.tsx | 227 ++ .../src/components/menu/index.tsx | 210 ++ .../src/components/modal/index.tsx | 262 ++ .../notifications/CreatedSuccessfully.tsx | 49 + .../notifications/Notifications.stories.tsx | 57 + .../src/components/notifications/index.tsx | 52 + .../src/components/picker/DatePicker.tsx | 324 ++ .../components/picker/DurationPicker.stories.tsx | 50 + .../src/components/picker/DurationPicker.tsx | 211 ++ .../product/InventoryProductForm.stories.tsx | 58 + .../components/product/InventoryProductForm.tsx | 95 + .../components/product/NonInventoryProductForm.tsx | 146 + .../src/components/product/ProductForm.tsx | 176 + .../src/components/product/ProductList.tsx | 105 + .../merchant-backoffice-ui/src/context/backend.ts | 82 + .../merchant-backoffice-ui/src/context/config.ts | 32 + .../merchant-backoffice-ui/src/context/fetch.ts | 54 + .../merchant-backoffice-ui/src/context/instance.ts | 35 + .../merchant-backoffice-ui/src/context/listener.ts | 35 + .../src/context/translation.ts | 59 + packages/merchant-backoffice-ui/src/custom.d.ts | 40 + .../merchant-backoffice-ui/src/declaration.d.ts | 1443 ++++++++ packages/merchant-backoffice-ui/src/hooks/async.ts | 76 + .../merchant-backoffice-ui/src/hooks/backend.ts | 319 ++ packages/merchant-backoffice-ui/src/hooks/index.ts | 110 + .../merchant-backoffice-ui/src/hooks/instance.ts | 292 ++ .../merchant-backoffice-ui/src/hooks/listener.ts | 81 + .../src/hooks/notifications.ts | 48 + packages/merchant-backoffice-ui/src/hooks/order.ts | 323 ++ .../merchant-backoffice-ui/src/hooks/product.ts | 187 ++ .../merchant-backoffice-ui/src/hooks/reserves.ts | 218 ++ .../merchant-backoffice-ui/src/hooks/transfer.ts | 217 ++ packages/merchant-backoffice-ui/src/i18n/de.po | 1057 ++++++ packages/merchant-backoffice-ui/src/i18n/en.po | 1057 ++++++ packages/merchant-backoffice-ui/src/i18n/es.po | 1065 ++++++ packages/merchant-backoffice-ui/src/i18n/fr.po | 1057 ++++++ packages/merchant-backoffice-ui/src/i18n/index.tsx | 215 ++ packages/merchant-backoffice-ui/src/i18n/it.po | 1057 ++++++ packages/merchant-backoffice-ui/src/i18n/poheader | 27 + .../src/i18n/strings-prelude | 19 + .../merchant-backoffice-ui/src/i18n/strings.ts | 3445 ++++++++++++++++++++ packages/merchant-backoffice-ui/src/i18n/sv.po | 1057 ++++++ .../src/i18n/taler-merchant-backoffice.pot | 1054 ++++++ packages/merchant-backoffice-ui/src/index.tsx | 111 + packages/merchant-backoffice-ui/src/manifest.json | 21 + .../src/paths/admin/create/Create.stories.tsx | 46 + .../src/paths/admin/create/CreatePage.tsx | 234 ++ .../admin/create/InstanceCreatedSuccessfully.tsx | 65 + .../src/paths/admin/create/index.tsx | 74 + .../src/paths/admin/list/TableActive.tsx | 184 ++ .../src/paths/admin/list/View.stories.tsx | 82 + .../src/paths/admin/list/View.tsx | 80 + .../src/paths/admin/list/index.tsx | 126 + .../src/paths/instance/details/DetailPage.tsx | 87 + .../src/paths/instance/details/Details.stories.tsx | 61 + .../src/paths/instance/details/index.tsx | 65 + .../src/paths/instance/kyc/list/ListPage.tsx | 178 + .../src/paths/instance/kyc/list/index.tsx | 51 + .../instance/orders/create/Create.stories.tsx | 70 + .../paths/instance/orders/create/CreatePage.tsx | 576 ++++ .../orders/create/OrderCreatedSuccessfully.tsx | 89 + .../src/paths/instance/orders/create/index.tsx | 82 + .../instance/orders/details/Detail.stories.tsx | 137 + .../paths/instance/orders/details/DetailPage.tsx | 776 +++++ .../src/paths/instance/orders/details/Timeline.tsx | 128 + .../src/paths/instance/orders/details/index.tsx | 67 + .../paths/instance/orders/list/List.stories.tsx | 107 + .../src/paths/instance/orders/list/ListPage.tsx | 146 + .../src/paths/instance/orders/list/Table.tsx | 412 +++ .../src/paths/instance/orders/list/index.tsx | 171 + .../instance/products/create/Create.stories.tsx | 42 + .../paths/instance/products/create/CreatePage.tsx | 65 + .../products/create/CreatedSuccessfully.tsx | 67 + .../src/paths/instance/products/create/index.tsx | 55 + .../paths/instance/products/list/List.stories.tsx | 58 + .../src/paths/instance/products/list/Table.tsx | 479 +++ .../src/paths/instance/products/list/index.tsx | 80 + .../instance/products/update/Update.stories.tsx | 71 + .../paths/instance/products/update/UpdatePage.tsx | 77 + .../src/paths/instance/products/update/index.tsx | 71 + .../instance/reserves/create/Create.stories.tsx | 42 + .../paths/instance/reserves/create/CreatePage.tsx | 168 + .../create/CreatedSuccessfully.stories.tsx | 53 + .../reserves/create/CreatedSuccessfully.tsx | 79 + .../src/paths/instance/reserves/create/index.tsx | 71 + .../paths/instance/reserves/details/DetailPage.tsx | 278 ++ .../instance/reserves/details/Details.stories.tsx | 105 + .../paths/instance/reserves/details/TipInfo.tsx | 87 + .../src/paths/instance/reserves/details/index.tsx | 56 + .../instance/reserves/list/AutorizeTipModal.tsx | 85 + .../instance/reserves/list/CreatedSuccessfully.tsx | 100 + .../paths/instance/reserves/list/List.stories.tsx | 102 + .../src/paths/instance/reserves/list/Table.tsx | 313 ++ .../src/paths/instance/reserves/list/index.tsx | 117 + .../instance/transfers/create/Create.stories.tsx | 43 + .../paths/instance/transfers/create/CreatePage.tsx | 104 + .../src/paths/instance/transfers/create/index.tsx | 60 + .../paths/instance/transfers/list/List.stories.tsx | 93 + .../src/paths/instance/transfers/list/ListPage.tsx | 89 + .../src/paths/instance/transfers/list/Table.tsx | 225 ++ .../src/paths/instance/transfers/list/index.tsx | 85 + .../src/paths/instance/transfers/update/index.tsx | 26 + .../src/paths/instance/update/Update.stories.tsx | 61 + .../src/paths/instance/update/UpdatePage.tsx | 259 ++ .../src/paths/instance/update/index.tsx | 113 + .../src/paths/login/index.tsx | 29 + .../src/paths/notfound/index.tsx | 36 + .../merchant-backoffice-ui/src/schemas/index.ts | 202 ++ .../src/scss/DurationPicker.scss | 71 + .../merchant-backoffice-ui/src/scss/_aside.scss | 179 + .../merchant-backoffice-ui/src/scss/_card.scss | 69 + .../src/scss/_custom-calendar.scss | 254 ++ .../merchant-backoffice-ui/src/scss/_footer.scss | 35 + .../merchant-backoffice-ui/src/scss/_form.scss | 64 + .../merchant-backoffice-ui/src/scss/_hero-bar.scss | 55 + .../merchant-backoffice-ui/src/scss/_loading.scss | 51 + .../src/scss/_main-section.scss | 24 + .../merchant-backoffice-ui/src/scss/_misc.scss | 50 + .../merchant-backoffice-ui/src/scss/_mixins.scss | 34 + .../merchant-backoffice-ui/src/scss/_modal.scss | 35 + .../merchant-backoffice-ui/src/scss/_nav-bar.scss | 144 + .../merchant-backoffice-ui/src/scss/_table.scss | 173 + .../src/scss/_theme-default.scss | 136 + .../merchant-backoffice-ui/src/scss/_tiles.scss | 25 + .../src/scss/_title-bar.scss | 50 + .../src/scss/fonts/XRXV3I6Li01BKofINeaE.ttf | Bin 0 -> 43752 bytes .../src/scss/fonts/nunito.css | 22 + .../fonts/materialdesignicons-webfont-4.9.95.eot | Bin 0 -> 844600 bytes .../fonts/materialdesignicons-webfont-4.9.95.ttf | Bin 0 -> 844380 bytes .../fonts/materialdesignicons-webfont-4.9.95.woff | Bin 0 -> 404384 bytes .../fonts/materialdesignicons-webfont-4.9.95.woff2 | Bin 0 -> 283040 bytes .../scss/icons/materialdesignicons-4.9.95.min.css | 3 + .../merchant-backoffice-ui/src/scss/libs/_all.scss | 29 + packages/merchant-backoffice-ui/src/scss/main.scss | 191 ++ packages/merchant-backoffice-ui/src/sw.js | 25 + packages/merchant-backoffice-ui/src/template.html | 52 + .../merchant-backoffice-ui/src/utils/amount.ts | 70 + .../merchant-backoffice-ui/src/utils/constants.ts | 194 ++ .../src/utils/switchableAxios.ts | 66 + packages/merchant-backoffice-ui/src/utils/table.ts | 37 + packages/merchant-backoffice-ui/src/utils/types.ts | 31 + 185 files changed, 31104 insertions(+) create mode 100644 packages/merchant-backoffice-ui/src/.babelrc create mode 100644 packages/merchant-backoffice-ui/src/AdminRoutes.tsx create mode 100644 packages/merchant-backoffice-ui/src/ApplicationReadyRoutes.tsx create mode 100644 packages/merchant-backoffice-ui/src/InstanceRoutes.tsx create mode 100644 packages/merchant-backoffice-ui/src/assets/empty.png create mode 100644 packages/merchant-backoffice-ui/src/assets/icons/android-chrome-192x192.png create mode 100644 packages/merchant-backoffice-ui/src/assets/icons/android-chrome-512x512.png create mode 100644 packages/merchant-backoffice-ui/src/assets/icons/apple-touch-icon.png create mode 100644 packages/merchant-backoffice-ui/src/assets/icons/favicon-16x16.png create mode 100644 packages/merchant-backoffice-ui/src/assets/icons/favicon-32x32.png create mode 100644 packages/merchant-backoffice-ui/src/assets/icons/languageicon.svg create mode 100644 packages/merchant-backoffice-ui/src/assets/icons/mstile-150x150.png create mode 100644 packages/merchant-backoffice-ui/src/assets/logo.jpeg create mode 100644 packages/merchant-backoffice-ui/src/components/exception/AsyncButton.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/exception/QR.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/exception/loading.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/exception/login.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/FormProvider.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/Input.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/InputArray.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/InputBoolean.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/InputCurrency.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/InputDate.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/InputDuration.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/InputGroup.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/InputImage.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/InputLocation.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/InputNumber.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/InputPayto.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/InputPaytoForm.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/InputSearchProduct.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/InputSecured.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/InputSecured.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/InputSelector.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/InputStock.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/InputStock.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/InputTaxes.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/InputWithAddon.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/TextField.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/useField.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/form/useGroupField.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/instance/DefaultInstanceFormFields.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/menu/LangSelector.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/menu/NavigationBar.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/menu/SideBar.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/menu/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/modal/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/notifications/CreatedSuccessfully.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/notifications/Notifications.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/notifications/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/picker/DatePicker.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/picker/DurationPicker.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/picker/DurationPicker.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/product/InventoryProductForm.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/product/InventoryProductForm.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/product/NonInventoryProductForm.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/product/ProductForm.tsx create mode 100644 packages/merchant-backoffice-ui/src/components/product/ProductList.tsx create mode 100644 packages/merchant-backoffice-ui/src/context/backend.ts create mode 100644 packages/merchant-backoffice-ui/src/context/config.ts create mode 100644 packages/merchant-backoffice-ui/src/context/fetch.ts create mode 100644 packages/merchant-backoffice-ui/src/context/instance.ts create mode 100644 packages/merchant-backoffice-ui/src/context/listener.ts create mode 100644 packages/merchant-backoffice-ui/src/context/translation.ts create mode 100644 packages/merchant-backoffice-ui/src/custom.d.ts create mode 100644 packages/merchant-backoffice-ui/src/declaration.d.ts create mode 100644 packages/merchant-backoffice-ui/src/hooks/async.ts create mode 100644 packages/merchant-backoffice-ui/src/hooks/backend.ts create mode 100644 packages/merchant-backoffice-ui/src/hooks/index.ts create mode 100644 packages/merchant-backoffice-ui/src/hooks/instance.ts create mode 100644 packages/merchant-backoffice-ui/src/hooks/listener.ts create mode 100644 packages/merchant-backoffice-ui/src/hooks/notifications.ts create mode 100644 packages/merchant-backoffice-ui/src/hooks/order.ts create mode 100644 packages/merchant-backoffice-ui/src/hooks/product.ts create mode 100644 packages/merchant-backoffice-ui/src/hooks/reserves.ts create mode 100644 packages/merchant-backoffice-ui/src/hooks/transfer.ts create mode 100644 packages/merchant-backoffice-ui/src/i18n/de.po create mode 100644 packages/merchant-backoffice-ui/src/i18n/en.po create mode 100644 packages/merchant-backoffice-ui/src/i18n/es.po create mode 100644 packages/merchant-backoffice-ui/src/i18n/fr.po create mode 100644 packages/merchant-backoffice-ui/src/i18n/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/i18n/it.po create mode 100644 packages/merchant-backoffice-ui/src/i18n/poheader create mode 100644 packages/merchant-backoffice-ui/src/i18n/strings-prelude create mode 100644 packages/merchant-backoffice-ui/src/i18n/strings.ts create mode 100644 packages/merchant-backoffice-ui/src/i18n/sv.po create mode 100644 packages/merchant-backoffice-ui/src/i18n/taler-merchant-backoffice.pot create mode 100644 packages/merchant-backoffice-ui/src/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/manifest.json create mode 100644 packages/merchant-backoffice-ui/src/paths/admin/create/Create.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/admin/create/CreatePage.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/admin/create/InstanceCreatedSuccessfully.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/admin/create/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/admin/list/TableActive.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/admin/list/View.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/admin/list/View.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/admin/list/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/details/DetailPage.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/details/Details.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/details/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/kyc/list/ListPage.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/kyc/list/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/orders/create/Create.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/orders/create/OrderCreatedSuccessfully.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/orders/create/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/orders/details/Detail.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/orders/details/DetailPage.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/orders/details/Timeline.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/orders/details/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/orders/list/List.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/orders/list/ListPage.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/orders/list/Table.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/orders/list/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/products/create/Create.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/products/create/CreatePage.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/products/create/CreatedSuccessfully.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/products/create/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/products/list/List.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/products/list/Table.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/products/list/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/products/update/Update.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/products/update/UpdatePage.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/products/update/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/reserves/create/Create.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/reserves/create/CreatePage.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/reserves/create/CreatedSuccessfully.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/reserves/create/CreatedSuccessfully.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/reserves/create/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/reserves/details/DetailPage.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/reserves/details/Details.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/reserves/details/TipInfo.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/reserves/details/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/reserves/list/AutorizeTipModal.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/reserves/list/CreatedSuccessfully.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/reserves/list/List.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/reserves/list/Table.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/reserves/list/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/transfers/create/Create.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/transfers/create/CreatePage.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/transfers/create/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/transfers/list/List.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/transfers/list/ListPage.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/transfers/list/Table.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/transfers/list/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/transfers/update/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/update/Update.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/update/UpdatePage.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/update/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/login/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/notfound/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/schemas/index.ts create mode 100644 packages/merchant-backoffice-ui/src/scss/DurationPicker.scss create mode 100644 packages/merchant-backoffice-ui/src/scss/_aside.scss create mode 100644 packages/merchant-backoffice-ui/src/scss/_card.scss create mode 100644 packages/merchant-backoffice-ui/src/scss/_custom-calendar.scss create mode 100644 packages/merchant-backoffice-ui/src/scss/_footer.scss create mode 100644 packages/merchant-backoffice-ui/src/scss/_form.scss create mode 100644 packages/merchant-backoffice-ui/src/scss/_hero-bar.scss create mode 100644 packages/merchant-backoffice-ui/src/scss/_loading.scss create mode 100644 packages/merchant-backoffice-ui/src/scss/_main-section.scss create mode 100644 packages/merchant-backoffice-ui/src/scss/_misc.scss create mode 100644 packages/merchant-backoffice-ui/src/scss/_mixins.scss create mode 100644 packages/merchant-backoffice-ui/src/scss/_modal.scss create mode 100644 packages/merchant-backoffice-ui/src/scss/_nav-bar.scss create mode 100644 packages/merchant-backoffice-ui/src/scss/_table.scss create mode 100644 packages/merchant-backoffice-ui/src/scss/_theme-default.scss create mode 100644 packages/merchant-backoffice-ui/src/scss/_tiles.scss create mode 100644 packages/merchant-backoffice-ui/src/scss/_title-bar.scss create mode 100644 packages/merchant-backoffice-ui/src/scss/fonts/XRXV3I6Li01BKofINeaE.ttf create mode 100644 packages/merchant-backoffice-ui/src/scss/fonts/nunito.css create mode 100644 packages/merchant-backoffice-ui/src/scss/icons/fonts/materialdesignicons-webfont-4.9.95.eot create mode 100644 packages/merchant-backoffice-ui/src/scss/icons/fonts/materialdesignicons-webfont-4.9.95.ttf create mode 100644 packages/merchant-backoffice-ui/src/scss/icons/fonts/materialdesignicons-webfont-4.9.95.woff create mode 100644 packages/merchant-backoffice-ui/src/scss/icons/fonts/materialdesignicons-webfont-4.9.95.woff2 create mode 100644 packages/merchant-backoffice-ui/src/scss/icons/materialdesignicons-4.9.95.min.css create mode 100644 packages/merchant-backoffice-ui/src/scss/libs/_all.scss create mode 100644 packages/merchant-backoffice-ui/src/scss/main.scss create mode 100644 packages/merchant-backoffice-ui/src/sw.js create mode 100644 packages/merchant-backoffice-ui/src/template.html create mode 100644 packages/merchant-backoffice-ui/src/utils/amount.ts create mode 100644 packages/merchant-backoffice-ui/src/utils/constants.ts create mode 100644 packages/merchant-backoffice-ui/src/utils/switchableAxios.ts create mode 100644 packages/merchant-backoffice-ui/src/utils/table.ts create mode 100644 packages/merchant-backoffice-ui/src/utils/types.ts (limited to 'packages/merchant-backoffice-ui/src') diff --git a/packages/merchant-backoffice-ui/src/.babelrc b/packages/merchant-backoffice-ui/src/.babelrc new file mode 100644 index 000000000..3ec8a6291 --- /dev/null +++ b/packages/merchant-backoffice-ui/src/.babelrc @@ -0,0 +1,26 @@ +/* + This file is part of GNU Taler + (C) 2021 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) + */ + +{ + "presets": [ + "preact-cli/babel" + ] +} diff --git a/packages/merchant-backoffice-ui/src/AdminRoutes.tsx b/packages/merchant-backoffice-ui/src/AdminRoutes.tsx new file mode 100644 index 000000000..a3ffbe2e6 --- /dev/null +++ b/packages/merchant-backoffice-ui/src/AdminRoutes.tsx @@ -0,0 +1,58 @@ +/* + This file is part of GNU Taler + (C) 2021 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 Router, { route, Route } from "preact-router"; +import InstanceCreatePage from "./paths/admin/create"; +import InstanceListPage from './paths/admin/list'; + + +export enum AdminPaths { + list_instances = '/instances', + new_instance = '/instance/new', +} + +export function AdminRoutes(): VNode { + + return + + { + route(AdminPaths.new_instance); + }} + + onUpdate={(id: string): void => { + route(`/instance/${id}/update`); + }} + + /> + + route(AdminPaths.list_instances)} + + onConfirm={() => { + // route(AdminPaths.list_instances); + }} + + // onError={(error: any) => { + // }} + + /> + + + +} \ No newline at end of file diff --git a/packages/merchant-backoffice-ui/src/ApplicationReadyRoutes.tsx b/packages/merchant-backoffice-ui/src/ApplicationReadyRoutes.tsx new file mode 100644 index 000000000..ebc3d1d95 --- /dev/null +++ b/packages/merchant-backoffice-ui/src/ApplicationReadyRoutes.tsx @@ -0,0 +1,120 @@ +/* + This file is part of GNU Taler + (C) 2021 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 { Fragment, h, VNode } from "preact"; +import Router, { Route, route } from "preact-router"; +import { useBackendContext } from "./context/backend"; +import { useBackendInstancesTestForAdmin } from "./hooks/backend"; +import { InstanceRoutes } from "./InstanceRoutes"; +import LoginPage from "./paths/login"; +import { INSTANCE_ID_LOOKUP } from "./utils/constants"; +import { NotYetReadyAppMenu, Menu, NotificationCard } from "./components/menu"; +import { useTranslator } from "./i18n"; +import { createHashHistory } from "history"; +import { useState } from "preact/hooks"; + +export function ApplicationReadyRoutes(): VNode { + const i18n = useTranslator(); + const { + url: backendURL, + updateLoginStatus, + clearAllTokens, + } = useBackendContext(); + + const result = useBackendInstancesTestForAdmin(); + + const clearTokenAndGoToRoot = () => { + clearAllTokens(); + route("/"); + }; + + if (result.clientError && result.isUnauthorized) { + return ( + + + + + + ); + } + + if (result.loading) return ; + + let admin = true; + let instanceNameByBackendURL; + + if (!result.ok) { + const path = new URL(backendURL).pathname; + const match = INSTANCE_ID_LOOKUP.exec(path); + if (!match || !match[1]) { + // this should be rare because + // query to /config is ok but the URL + // does not match our pattern + return ( + + + + + + ); + } + + admin = false; + instanceNameByBackendURL = match[1]; + } + + const history = createHashHistory(); + return ( + + + + ); +} + +function DefaultMainRoute({ instance, admin, instanceNameByBackendURL }: any) { + const [instanceName, setInstanceName] = useState( + instanceNameByBackendURL || instance || "default" + ); + + return ( + + ); +} diff --git a/packages/merchant-backoffice-ui/src/InstanceRoutes.tsx b/packages/merchant-backoffice-ui/src/InstanceRoutes.tsx new file mode 100644 index 000000000..06f1db17c --- /dev/null +++ b/packages/merchant-backoffice-ui/src/InstanceRoutes.tsx @@ -0,0 +1,528 @@ +/* + This file is part of GNU Taler + (C) 2021 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 { Fragment, FunctionComponent, h, VNode } from "preact"; +import { Route, route, Router } from "preact-router"; +import { useCallback, useEffect, useMemo, useState } from "preact/hooks"; +import { Loading } from "./components/exception/loading"; +import { Menu, NotificationCard } from "./components/menu"; +import { useBackendContext } from "./context/backend"; +import { InstanceContextProvider } from "./context/instance"; +import { + useBackendDefaultToken, + useBackendInstanceToken, + useLocalStorage, +} from "./hooks"; +import { HttpError } from "./hooks/backend"; +import { Translate, useTranslator } from "./i18n"; +import InstanceCreatePage from "./paths/admin/create"; +import InstanceListPage from "./paths/admin/list"; +import OrderCreatePage from "./paths/instance/orders/create"; +import OrderDetailsPage from "./paths/instance/orders/details"; +import OrderListPage from "./paths/instance/orders/list"; +import ProductCreatePage from "./paths/instance/products/create"; +import ProductListPage from "./paths/instance/products/list"; +import ProductUpdatePage from "./paths/instance/products/update"; +import TransferListPage from "./paths/instance/transfers/list"; +import TransferCreatePage from "./paths/instance/transfers/create"; +import ReservesCreatePage from "./paths/instance/reserves/create"; +import ReservesDetailsPage from "./paths/instance/reserves/details"; +import ReservesListPage from "./paths/instance/reserves/list"; +import ListKYCPage from "./paths/instance/kyc/list"; +import InstanceUpdatePage, { + Props as InstanceUpdatePageProps, + AdminUpdate as InstanceAdminUpdatePage, +} from "./paths/instance/update"; +import LoginPage from "./paths/login"; +import NotFoundPage from "./paths/notfound"; +import { Notification } from "./utils/types"; +import { useInstanceKYCDetails } from "./hooks/instance"; +import { format } from "date-fns"; + +export enum InstancePaths { + // details = '/', + error = "/error", + update = "/update", + + product_list = "/products", + product_update = "/product/:pid/update", + product_new = "/product/new", + + order_list = "/orders", + order_new = "/order/new", + order_details = "/order/:oid/details", + + reserves_list = "/reserves", + reserves_details = "/reserves/:rid/details", + reserves_new = "/reserves/new", + + kyc = "/kyc", + + transfers_list = "/transfers", + transfers_new = "/transfer/new", +} + +// eslint-disable-next-line @typescript-eslint/no-empty-function +const noop = () => {}; + +export enum AdminPaths { + list_instances = "/instances", + new_instance = "/instance/new", + update_instance = "/instance/:id/update", +} + +export interface Props { + id: string; + admin?: boolean; + setInstanceName: (s: string) => void; +} + +export function InstanceRoutes({ id, admin, setInstanceName }: Props): VNode { + const [_, updateDefaultToken] = useBackendDefaultToken(); + const [token, updateToken] = useBackendInstanceToken(id); + const { + updateLoginStatus: changeBackend, + addTokenCleaner, + clearAllTokens, + } = useBackendContext(); + const cleaner = useCallback(() => { + updateToken(undefined); + }, [id]); + const i18n = useTranslator(); + + type GlobalNotifState = (Notification & { to: string }) | undefined; + const [globalNotification, setGlobalNotification] = + useState(undefined); + + useEffect(() => { + addTokenCleaner(cleaner); + }, [addTokenCleaner, cleaner]); + + const changeToken = (token?: string) => { + if (admin) { + updateToken(token); + } else { + updateDefaultToken(token); + } + }; + const updateLoginStatus = (url: string, token?: string) => { + changeBackend(url); + if (!token) return; + changeToken(token); + }; + + const value = useMemo( + () => ({ id, token, admin, changeToken }), + [id, token, admin] + ); + + function ServerErrorRedirectTo(to: InstancePaths | AdminPaths) { + return function ServerErrorRedirectToImpl(error: HttpError) { + setGlobalNotification({ + message: i18n`The backend reported a problem: HTTP status #${error.status}`, + description: i18n`Diagnostic from ${error.info?.url} is "${error.message}"`, + details: + error.clientError || error.serverError + ? error.error?.detail + : undefined, + type: "ERROR", + to, + }); + return ; + }; + } + + const LoginPageAccessDenied = () => ( + + + + + ); + + function IfAdminCreateDefaultOr(Next: FunctionComponent) { + return function IfAdminCreateDefaultOrImpl(props?: T) { + if (admin && id === "default") { + return ( + + + { + route(AdminPaths.list_instances); + }} + /> + + ); + } + if (props) { + return ; + } + return ; + }; + } + + const clearTokenAndGoToRoot = () => { + clearAllTokens(); + route("/"); + }; + + return ( + + + + + + { + const movingOutFromNotification = + globalNotification && e.url !== globalNotification.to; + if (movingOutFromNotification) { + setGlobalNotification(undefined); + } + }} + > + + + {/** + * Admin pages + */} + {admin && ( + { + route(AdminPaths.new_instance); + }} + onUpdate={(id: string): void => { + route(`/instance/${id}/update`); + }} + setInstanceName={setInstanceName} + onUnauthorized={LoginPageAccessDenied} + onLoadError={ServerErrorRedirectTo(InstancePaths.error)} + /> + )} + + {admin && ( + route(AdminPaths.list_instances)} + onConfirm={() => { + route(AdminPaths.list_instances); + }} + /> + )} + + {admin && ( + route(AdminPaths.list_instances)} + onConfirm={() => { + route(AdminPaths.list_instances); + }} + onUpdateError={ServerErrorRedirectTo(AdminPaths.list_instances)} + onLoadError={ServerErrorRedirectTo(AdminPaths.list_instances)} + onNotFound={NotFoundPage} + /> + )} + + {/** + * Update instance page + */} + { + route(`/`); + }} + onConfirm={() => { + route(`/`); + }} + onUpdateError={noop} + onNotFound={IfAdminCreateDefaultOr(NotFoundPage)} + onUnauthorized={LoginPageAccessDenied} + onLoadError={ServerErrorRedirectTo(InstancePaths.error)} + /> + + {/** + * Product pages + */} + { + route(InstancePaths.product_new); + }} + onSelect={(id: string) => { + route(InstancePaths.product_update.replace(":pid", id)); + }} + onNotFound={IfAdminCreateDefaultOr(NotFoundPage)} + /> + { + route(InstancePaths.product_list); + }} + onBack={() => { + route(InstancePaths.product_list); + }} + onNotFound={IfAdminCreateDefaultOr(NotFoundPage)} + /> + { + route(InstancePaths.product_list); + }} + onBack={() => { + route(InstancePaths.product_list); + }} + /> + + {/** + * Order pages + */} + { + route(InstancePaths.order_new); + }} + onSelect={(id: string) => { + route(InstancePaths.order_details.replace(":oid", id)); + }} + onUnauthorized={LoginPageAccessDenied} + onLoadError={ServerErrorRedirectTo(InstancePaths.update)} + onNotFound={IfAdminCreateDefaultOr(NotFoundPage)} + /> + { + route(InstancePaths.order_list); + }} + /> + { + route(InstancePaths.order_list); + }} + onBack={() => { + route(InstancePaths.order_list); + }} + /> + + {/** + * Transfer pages + */} + { + route(InstancePaths.transfers_new); + }} + /> + + { + route(InstancePaths.transfers_list); + }} + onBack={() => { + route(InstancePaths.transfers_list); + }} + /> + + {/** + * reserves pages + */} + { + route(InstancePaths.reserves_details.replace(":rid", id)); + }} + onCreate={() => { + route(InstancePaths.reserves_new); + }} + /> + + { + route(InstancePaths.reserves_list); + }} + /> + + { + route(InstancePaths.reserves_list); + }} + onBack={() => { + route(InstancePaths.reserves_list); + }} + /> + + + {/** + * Example pages + */} + + + + + ); +} + +export function Redirect({ to }: { to: string }): null { + useEffect(() => { + route(to, true); + }); + return null; +} + +function AdminInstanceUpdatePage({ + id, + ...rest +}: { id: string } & InstanceUpdatePageProps) { + const [token, changeToken] = useBackendInstanceToken(id); + const { updateLoginStatus: changeBackend } = useBackendContext(); + const updateLoginStatus = (url: string, token?: string) => { + changeBackend(url); + if (token) changeToken(token); + }; + const value = useMemo( + () => ({ id, token, admin: true, changeToken }), + [id, token] + ); + const i18n = useTranslator(); + + return ( + + { + return ( + + + + + ); + }} + onUnauthorized={() => { + return ( + + + + + ); + }} + /> + + ); +} + +function KycBanner(): VNode { + const kycStatus = useInstanceKYCDetails(); + const today = format(new Date(), "yyyy-MM-dd"); + const [lastHide, setLastHide] = useLocalStorage("kyc-last-hide"); + const hasBeenHidden = today === lastHide; + const needsToBeShown = kycStatus.ok && kycStatus.data.type === "redirect"; + if (hasBeenHidden || !needsToBeShown) return ; + return ( + +

+ Some transfer are on hold until a KYC process is completed. Go to + the KYC section in the left panel for more information +

+
+ +
+ + ), + }} + /> + ); +} diff --git a/packages/merchant-backoffice-ui/src/assets/empty.png b/packages/merchant-backoffice-ui/src/assets/empty.png new file mode 100644 index 000000000..5120d3138 Binary files /dev/null and b/packages/merchant-backoffice-ui/src/assets/empty.png differ diff --git a/packages/merchant-backoffice-ui/src/assets/icons/android-chrome-192x192.png b/packages/merchant-backoffice-ui/src/assets/icons/android-chrome-192x192.png new file mode 100644 index 000000000..93ebe2e2c Binary files /dev/null and b/packages/merchant-backoffice-ui/src/assets/icons/android-chrome-192x192.png differ diff --git a/packages/merchant-backoffice-ui/src/assets/icons/android-chrome-512x512.png b/packages/merchant-backoffice-ui/src/assets/icons/android-chrome-512x512.png new file mode 100644 index 000000000..52d1623ea Binary files /dev/null and b/packages/merchant-backoffice-ui/src/assets/icons/android-chrome-512x512.png differ diff --git a/packages/merchant-backoffice-ui/src/assets/icons/apple-touch-icon.png b/packages/merchant-backoffice-ui/src/assets/icons/apple-touch-icon.png new file mode 100644 index 000000000..254e4bb4d Binary files /dev/null and b/packages/merchant-backoffice-ui/src/assets/icons/apple-touch-icon.png differ diff --git a/packages/merchant-backoffice-ui/src/assets/icons/favicon-16x16.png b/packages/merchant-backoffice-ui/src/assets/icons/favicon-16x16.png new file mode 100644 index 000000000..e81177dcb Binary files /dev/null and b/packages/merchant-backoffice-ui/src/assets/icons/favicon-16x16.png differ diff --git a/packages/merchant-backoffice-ui/src/assets/icons/favicon-32x32.png b/packages/merchant-backoffice-ui/src/assets/icons/favicon-32x32.png new file mode 100644 index 000000000..40e9b5b47 Binary files /dev/null and b/packages/merchant-backoffice-ui/src/assets/icons/favicon-32x32.png differ diff --git a/packages/merchant-backoffice-ui/src/assets/icons/languageicon.svg b/packages/merchant-backoffice-ui/src/assets/icons/languageicon.svg new file mode 100644 index 000000000..22d58da65 --- /dev/null +++ b/packages/merchant-backoffice-ui/src/assets/icons/languageicon.svg @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/merchant-backoffice-ui/src/assets/icons/mstile-150x150.png b/packages/merchant-backoffice-ui/src/assets/icons/mstile-150x150.png new file mode 100644 index 000000000..9cfb889be Binary files /dev/null and b/packages/merchant-backoffice-ui/src/assets/icons/mstile-150x150.png differ diff --git a/packages/merchant-backoffice-ui/src/assets/logo.jpeg b/packages/merchant-backoffice-ui/src/assets/logo.jpeg new file mode 100644 index 000000000..489832f7c Binary files /dev/null and b/packages/merchant-backoffice-ui/src/assets/logo.jpeg differ diff --git a/packages/merchant-backoffice-ui/src/components/exception/AsyncButton.tsx b/packages/merchant-backoffice-ui/src/components/exception/AsyncButton.tsx new file mode 100644 index 000000000..92bab4bfb --- /dev/null +++ b/packages/merchant-backoffice-ui/src/components/exception/AsyncButton.tsx @@ -0,0 +1,49 @@ +/* + This file is part of GNU Taler + (C) 2021 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 { ComponentChildren, h } from "preact"; +import { LoadingModal } from "../modal"; +import { useAsync } from "../../hooks/async"; +import { Translate } from "../../i18n"; + +type Props = { + children: ComponentChildren, + disabled: boolean; + onClick?: () => Promise; + [rest:string]: any, +}; + +export function AsyncButton({ onClick, disabled, children, ...rest }: Props) { + const { isSlow, isLoading, request, cancel } = useAsync(onClick); + + if (isSlow) { + return ; + } + if (isLoading) { + return ; + } + + return + + ; +} diff --git a/packages/merchant-backoffice-ui/src/components/exception/QR.tsx b/packages/merchant-backoffice-ui/src/components/exception/QR.tsx new file mode 100644 index 000000000..bcb9964a5 --- /dev/null +++ b/packages/merchant-backoffice-ui/src/components/exception/QR.tsx @@ -0,0 +1,49 @@ +/* + This file is part of GNU Taler + (C) 2021 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 { useEffect, useRef } from "preact/hooks"; +import qrcode from "qrcode-generator"; + +export function QR({ text }: { text: string }): VNode { + const divRef = useRef(null); + useEffect(() => { + const qr = qrcode(0, "L"); + qr.addData(text); + qr.make(); + if (divRef.current) { + divRef.current.innerHTML = qr.createSvgTag({ + scalable: true, + }); + } + }); + + return ( +
+
+
+ ); +} diff --git a/packages/merchant-backoffice-ui/src/components/exception/loading.tsx b/packages/merchant-backoffice-ui/src/components/exception/loading.tsx new file mode 100644 index 000000000..f2139a17e --- /dev/null +++ b/packages/merchant-backoffice-ui/src/components/exception/loading.tsx @@ -0,0 +1,32 @@ +/* + This file is part of GNU Taler + (C) 2021 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"; + +export function Loading(): VNode { + return
+ +
+} + +export function Spinner(): VNode { + return
+} \ No newline at end of file diff --git a/packages/merchant-backoffice-ui/src/components/exception/login.tsx b/packages/merchant-backoffice-ui/src/components/exception/login.tsx new file mode 100644 index 000000000..498d994ed --- /dev/null +++ b/packages/merchant-backoffice-ui/src/components/exception/login.tsx @@ -0,0 +1,143 @@ +/* + This file is part of GNU Taler + (C) 2021 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 { useState } from "preact/hooks"; +import { useBackendContext } from "../../context/backend"; +import { useInstanceContext } from "../../context/instance"; +import { Translate, useTranslator } from "../../i18n"; +import { Notification } from "../../utils/types"; + +interface Props { + withMessage?: Notification; + onConfirm: (backend: string, token?: string) => void; +} + +function getTokenValuePart(t?: string): string | undefined { + if (!t) return t; + const match = /secret-token:(.*)/.exec(t); + if (!match || !match[1]) return undefined; + return match[1]; +} + +function normalizeToken(r: string | undefined): string | undefined { + return r ? `secret-token:${encodeURIComponent(r)}` : undefined; +} + +export function LoginModal({ onConfirm, withMessage }: Props): VNode { + const { url: backendUrl, token: baseToken } = useBackendContext(); + const { admin, token: instanceToken } = useInstanceContext(); + const currentToken = getTokenValuePart( + !admin ? baseToken : instanceToken || "" + ); + const [token, setToken] = useState(currentToken); + + const [url, setURL] = useState(backendUrl); + const i18n = useTranslator(); + + return ( +
+
+ +
+
+ ); +} diff --git a/packages/merchant-backoffice-ui/src/components/form/FormProvider.tsx b/packages/merchant-backoffice-ui/src/components/form/FormProvider.tsx new file mode 100644 index 000000000..aef410ce7 --- /dev/null +++ b/packages/merchant-backoffice-ui/src/components/form/FormProvider.tsx @@ -0,0 +1,81 @@ +/* + This file is part of GNU Taler + (C) 2021 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 { ComponentChildren, createContext, h, VNode } from "preact"; +import { useContext, useMemo } from "preact/hooks"; + +type Updater = (value: ((prevState: S) => S) ) => void; + +export interface Props { + object?: Partial; + errors?: FormErrors; + name?: string; + valueHandler: Updater> | null; + children: ComponentChildren +} + +const noUpdater: Updater> = () => (s: unknown) => s + +export function FormProvider({ object = {}, errors = {}, name = '', valueHandler, children }: Props): VNode { + const initialObject = useMemo(() => object, []); + const value = useMemo>(() => ({ errors, object, initialObject, valueHandler: valueHandler ? valueHandler : noUpdater, name, toStr: {}, fromStr: {} }), [errors, object, valueHandler]); + + return +
{ + e.preventDefault(); + // if (valueHandler) valueHandler(object); + }}> + {children} +
+
; +} + +export interface FormType { + object: Partial; + initialObject: Partial; + errors: FormErrors; + toStr: FormtoStr; + name: string; + fromStr: FormfromStr; + valueHandler: Updater>; +} + +const FormContext = createContext>(null!) + +export function useFormContext() { + return useContext>(FormContext) +} + +export type FormErrors = { + [P in keyof T]?: string | FormErrors +} + +export type FormtoStr = { + [P in keyof T]?: ((f?: T[P]) => string) +} + +export type FormfromStr = { + [P in keyof T]?: ((f: string) => T[P]) +} + +export type FormUpdater = { + [P in keyof T]?: (f: keyof T) => (v: T[P]) => void +} diff --git a/packages/merchant-backoffice-ui/src/components/form/Input.tsx b/packages/merchant-backoffice-ui/src/components/form/Input.tsx new file mode 100644 index 000000000..9a9691e9b --- /dev/null +++ b/packages/merchant-backoffice-ui/src/components/form/Input.tsx @@ -0,0 +1,71 @@ +/* + This file is part of GNU Taler + (C) 2021 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 { ComponentChildren, h, VNode } from "preact"; +import { useField, InputProps } from "./useField"; + +interface Props extends InputProps { + inputType?: 'text' | 'number' | 'multiline' | 'password'; + expand?: boolean; + toStr?: (v?: any) => string; + fromStr?: (s: string) => any; + inputExtra?: any, + side?: ComponentChildren; + children?: ComponentChildren; +} + +const defaultToString = (f?: any): string => f || '' +const defaultFromString = (v: string): any => v as any + +const TextInput = ({ inputType, error, ...rest }: any) => inputType === 'multiline' ? +