From cf7f819685c19adfe6443a6bdd10f3afe10b247d Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Mon, 19 Dec 2022 16:25:09 -0300
Subject: templates

---
 .../merchant-backoffice-ui/src/InstanceRoutes.tsx  | 57 +++++++++++++++++-----
 1 file changed, 46 insertions(+), 11 deletions(-)

(limited to 'packages/merchant-backoffice-ui/src/InstanceRoutes.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 {
         }}
       >
         <Route path="/" component={Redirect} to={InstancePaths.order_list} />
-
         {/**
          * Admin pages
          */}
@@ -236,7 +242,6 @@ export function InstanceRoutes({ id, admin, setInstanceName }: Props): VNode {
             onLoadError={ServerErrorRedirectTo(InstancePaths.error)}
           />
         )}
-
         {admin && (
           <Route
             path={AdminPaths.new_instance}
@@ -247,7 +252,6 @@ export function InstanceRoutes({ id, admin, setInstanceName }: Props): VNode {
             }}
           />
         )}
-
         {admin && (
           <Route
             path={AdminPaths.update_instance}
@@ -261,7 +265,6 @@ export function InstanceRoutes({ id, admin, setInstanceName }: Props): VNode {
             onNotFound={NotFoundPage}
           />
         )}
-
         {/**
          * 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);
           }}
         />
-
         <Route
           path={InstancePaths.transfers_new}
           component={TransferCreatePage}
@@ -381,6 +380,45 @@ export function InstanceRoutes({ id, admin, setInstanceName }: Props): VNode {
             route(InstancePaths.transfers_list);
           }}
         />
+        {/**
+         * Templates pages
+         */}
+        <Route
+          path={InstancePaths.templates_list}
+          component={TemplateListPage}
+          onUnauthorized={LoginPageAccessDenied}
+          onNotFound={IfAdminCreateDefaultOr(NotFoundPage)}
+          onLoadError={ServerErrorRedirectTo(InstancePaths.update)}
+          onCreate={() => {
+            route(InstancePaths.templates_new);
+          }}
+          onSelect={(id: string) => {
+            route(InstancePaths.templates_update.replace(":tid", id));
+          }}
+        />
+        <Route
+          path={InstancePaths.templates_update}
+          component={TemplateUpdatePage}
+          onConfirm={() => {
+            route(InstancePaths.templates_list);
+          }}
+          onUnauthorized={LoginPageAccessDenied}
+          onLoadError={ServerErrorRedirectTo(InstancePaths.templates_list)}
+          onNotFound={IfAdminCreateDefaultOr(NotFoundPage)}
+          onBack={() => {
+            route(InstancePaths.templates_list);
+          }}
+        />
+        <Route
+          path={InstancePaths.templates_new}
+          component={TemplateCreatePage}
+          onConfirm={() => {
+            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);
           }}
         />
-
         <Route
           path={InstancePaths.reserves_details}
           component={ReservesDetailsPage}
@@ -409,7 +446,6 @@ export function InstanceRoutes({ id, admin, setInstanceName }: Props): VNode {
             route(InstancePaths.reserves_list);
           }}
         />
-
         <Route
           path={InstancePaths.reserves_new}
           component={ReservesCreatePage}
@@ -420,7 +456,6 @@ export function InstanceRoutes({ id, admin, setInstanceName }: Props): VNode {
             route(InstancePaths.reserves_list);
           }}
         />
-
         <Route path={InstancePaths.kyc} component={ListKYCPage} />
         {/**
          * Example pages
-- 
cgit v1.2.3

