From cf7f819685c19adfe6443a6bdd10f3afe10b247d Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 19 Dec 2022 16:25:09 -0300 Subject: [PATCH] templates --- .../src/InstanceRoutes.tsx | 57 +++- .../src/components/menu/SideBar.tsx | 16 +- .../src/declaration.d.ts | 84 ++++++ .../src/hooks/templates.ts | 280 ++++++++++++++++++ .../src/paths/instance/orders/list/index.tsx | 23 +- .../templates/create/Create.stories.tsx | 41 +++ .../instance/templates/create/CreatePage.tsx | 163 ++++++++++ .../paths/instance/templates/create/index.tsx | 63 ++++ .../instance/templates/list/List.stories.tsx | 28 ++ .../instance/templates/list/ListPage.tsx | 64 ++++ .../paths/instance/templates/list/Table.tsx | 207 +++++++++++++ .../paths/instance/templates/list/index.tsx | 95 ++++++ .../templates/update/Update.stories.tsx | 32 ++ .../instance/templates/update/UpdatePage.tsx | 174 +++++++++++ .../paths/instance/templates/update/index.tsx | 86 ++++++ .../src/scss/_custom-calendar.scss | 12 +- .../src/utils/amount.ts | 25 +- 17 files changed, 1400 insertions(+), 50 deletions(-) create mode 100644 packages/merchant-backoffice-ui/src/hooks/templates.ts create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/templates/create/Create.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/templates/create/CreatePage.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/templates/create/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/templates/list/List.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/templates/list/ListPage.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/templates/list/Table.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/templates/list/index.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/templates/update/Update.stories.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/templates/update/UpdatePage.tsx create mode 100644 packages/merchant-backoffice-ui/src/paths/instance/templates/update/index.tsx diff --git a/packages/merchant-backoffice-ui/src/InstanceRoutes.tsx b/packages/merchant-backoffice-ui/src/InstanceRoutes.tsx index adfc73e20..817de5f7b 100644 --- a/packages/merchant-backoffice-ui/src/InstanceRoutes.tsx +++ b/packages/merchant-backoffice-ui/src/InstanceRoutes.tsx @@ -43,6 +43,9 @@ import ProductListPage from "./paths/instance/products/list/index.js"; import ProductUpdatePage from "./paths/instance/products/update/index.js"; import TransferListPage from "./paths/instance/transfers/list/index.js"; import TransferCreatePage from "./paths/instance/transfers/create/index.js"; +import TemplateListPage from "./paths/instance/templates/list/index.js"; +import TemplateUpdatePage from "./paths/instance/templates/update/index.js"; +import TemplateCreatePage from "./paths/instance/templates/create/index.js"; import ReservesCreatePage from "./paths/instance/reserves/create/index.js"; import ReservesDetailsPage from "./paths/instance/reserves/details/index.js"; import ReservesListPage from "./paths/instance/reserves/list/index.js"; @@ -78,6 +81,10 @@ export enum InstancePaths { transfers_list = "/transfers", transfers_new = "/transfer/new", + + templates_list = "/templates", + templates_update = "/templates/:tid/update", + templates_new = "/templates/new", } // eslint-disable-next-line @typescript-eslint/no-empty-function @@ -217,7 +224,6 @@ export function InstanceRoutes({ id, admin, setInstanceName }: Props): VNode { }} > - {/** * Admin pages */} @@ -236,7 +242,6 @@ export function InstanceRoutes({ id, admin, setInstanceName }: Props): VNode { onLoadError={ServerErrorRedirectTo(InstancePaths.error)} /> )} - {admin && ( )} - {admin && ( )} - {/** * Update instance page */} @@ -279,7 +282,6 @@ export function InstanceRoutes({ id, admin, setInstanceName }: Props): VNode { onUnauthorized={LoginPageAccessDenied} onLoadError={ServerErrorRedirectTo(InstancePaths.error)} /> - {/** * Product pages */} @@ -319,7 +321,6 @@ export function InstanceRoutes({ id, admin, setInstanceName }: Props): VNode { route(InstancePaths.product_list); }} /> - {/** * Order pages */} @@ -356,7 +357,6 @@ export function InstanceRoutes({ id, admin, setInstanceName }: Props): VNode { route(InstancePaths.order_list); }} /> - {/** * Transfer pages */} @@ -370,7 +370,6 @@ export function InstanceRoutes({ id, admin, setInstanceName }: Props): VNode { route(InstancePaths.transfers_new); }} /> - + {/** + * Templates pages + */} + { + route(InstancePaths.templates_new); + }} + onSelect={(id: string) => { + route(InstancePaths.templates_update.replace(":tid", id)); + }} + /> + { + route(InstancePaths.templates_list); + }} + onUnauthorized={LoginPageAccessDenied} + onLoadError={ServerErrorRedirectTo(InstancePaths.templates_list)} + onNotFound={IfAdminCreateDefaultOr(NotFoundPage)} + onBack={() => { + route(InstancePaths.templates_list); + }} + /> + { + route(InstancePaths.templates_list); + }} + onBack={() => { + route(InstancePaths.templates_list); + }} + /> {/** * reserves pages @@ -398,7 +436,6 @@ export function InstanceRoutes({ id, admin, setInstanceName }: Props): VNode { route(InstancePaths.reserves_new); }} /> - - - {/** * Example pages diff --git a/packages/merchant-backoffice-ui/src/components/menu/SideBar.tsx b/packages/merchant-backoffice-ui/src/components/menu/SideBar.tsx index 1d15bb094..ea49be99a 100644 --- a/packages/merchant-backoffice-ui/src/components/menu/SideBar.tsx +++ b/packages/merchant-backoffice-ui/src/components/menu/SideBar.tsx @@ -51,12 +51,6 @@ export function Sidebar({ const kycStatus = useInstanceKYCDetails(); const needKYC = kycStatus.ok && kycStatus.data.type === "redirect"; - // const withInstanceIdIfNeeded = useCallback(function (path: string) { - // if (mimic) { - // return path + '?instance=' + instance - // } - // return path - // },[instance]) return (