From 4ce9dae7ab6932cf60cf35ebb0d5b2df4ac3cbb6 Mon Sep 17 00:00:00 2001 From: grey Date: Mon, 8 May 2023 20:05:07 +0200 Subject: [PATCH] - category wip --- src/frontend/categoryManager.eta.html | 32 +++++++++++++++++++++++++ src/frontend/partials/controls.eta.html | 9 +++++++ src/routes/frontend/categoryManager.ts | 15 ++++++++++++ src/routes/frontend/index.ts | 2 ++ 4 files changed, 58 insertions(+) create mode 100644 src/frontend/categoryManager.eta.html create mode 100644 src/routes/frontend/categoryManager.ts diff --git a/src/frontend/categoryManager.eta.html b/src/frontend/categoryManager.eta.html new file mode 100644 index 0000000..fa21e16 --- /dev/null +++ b/src/frontend/categoryManager.eta.html @@ -0,0 +1,32 @@ +<%~ E.includeFile("partials/head.eta.html", {"title": "Settings - Category"}) %> <%~ E.includeFile("partials/controls.eta.html", {"active": "SETT_CAT"}) %> + +

All categories

+
+ + + + + + + + + + + + + + <% it.items.forEach(function(user){ %> + + + + + <% }) %> + +
#NameDescription
<%= user.id %><%= user.name %><%= user.description %>
+
+ +<%~ E.includeFile("partials/controlsFoot.eta.html") %> <%~ E.includeFile("partials/foot.eta.html") %> diff --git a/src/frontend/partials/controls.eta.html b/src/frontend/partials/controls.eta.html index c10a1b9..e7b4282 100644 --- a/src/frontend/partials/controls.eta.html +++ b/src/frontend/partials/controls.eta.html @@ -93,6 +93,15 @@ JSON Import + + diff --git a/src/routes/frontend/categoryManager.ts b/src/routes/frontend/categoryManager.ts new file mode 100644 index 0000000..c15f823 --- /dev/null +++ b/src/routes/frontend/categoryManager.ts @@ -0,0 +1,15 @@ +import express, { Request, Response } from 'express'; +import { prisma, __path } from '../../index.js'; + +export default (req: Request, res: Response) => { + prisma.category + .findMany({}) + .then((items) => { + // Count amount of total items + res.render(__path + '/src/frontend/categoryManager.eta.html', { items: items }); + }) + .catch((err) => { + console.error(err); + res.status(500).render(__path + '/src/frontend/errors/dbError.eta.html', { error: err }); + }); +}; diff --git a/src/routes/frontend/index.ts b/src/routes/frontend/index.ts index 885f74e..f5bf2e5 100644 --- a/src/routes/frontend/index.ts +++ b/src/routes/frontend/index.ts @@ -6,6 +6,7 @@ import testRoute from './test.js'; import dashboardRoute from './dashboard.js'; import csvImportRoute from './import/csvImport.js'; import listAllItems from './listAllItems.js'; +import categoryManager from './categoryManager.js'; // Router base is '/' const Router = express.Router({ strict: false }); @@ -13,6 +14,7 @@ const Router = express.Router({ strict: false }); Router.use('/test', testRoute); Router.use('/allItems', listAllItems) +Router.use('/allCategories', categoryManager) Router.use('/import/csv', csvImportRoute); Router.use('/:id(\\w{8})', skuRoute); Router.use('/', dashboardRoute);