From d6db0209f42a61ae3a47a75ac899c7746e125298 Mon Sep 17 00:00:00 2001 From: kennyboy55 Date: Sat, 18 May 2024 18:48:59 +0200 Subject: [PATCH] Add statistics page --- app/components/cards/drink.page.tsx | 59 +++++++++--- app/components/filters/drink.filter.tsx | 3 +- app/components/header.tsx | 15 ++-- app/models/drinks.filter.server.ts | 8 +- app/models/drinks.server.ts | 6 +- app/models/drinks.sort.server.ts | 24 ++++- app/models/types.tsx | 17 +++- app/routes/inventory/route.tsx | 16 ++-- app/routes/inventory/stats/route.tsx | 114 ++++++++++++++++++++++++ app/routes/scan/route.tsx | 10 ++- prisma/schema.prisma | 11 +-- prisma/seed.ts | 50 ++++------- schema.zmodel | 1 + vite.config.ts | 3 + 14 files changed, 262 insertions(+), 75 deletions(-) create mode 100644 app/routes/inventory/stats/route.tsx diff --git a/app/components/cards/drink.page.tsx b/app/components/cards/drink.page.tsx index 7689f4e..3d25f03 100644 --- a/app/components/cards/drink.page.tsx +++ b/app/components/cards/drink.page.tsx @@ -1,6 +1,6 @@ import { Manufacturer } from '@zenstackhq/runtime/models'; -import { Col, Container, Image, Row } from 'react-bootstrap'; +import { Col, Container, Image, Row, Table } from 'react-bootstrap'; import { ContainerWithSection, DrinkComposite, isDrinkWithContainersAndSection, isDrinkWithManufacturer, isDrinkWithStyle } from '~/models/types'; interface Arguments { @@ -30,39 +30,74 @@ function DrinkPage(arg:Arguments) { return ( -
+

{arg.drink.name}

+ ABV: {arg.drink.abv}% {arg.drink.gluten ? "" : " | Gluten-free"} {arg.drink.organic ? " | Organic" : ""}

{arg.drink.description}

+ + + + + + + + + + +
- +

Inventory

{totalinventory == 0 ? ( "No inventory" - ) : ""} - {containers.map((container) => ( -

{container.section.name} | {container.type} | {container.inventory}

- ))} + ) : ( + + + + + + + + + + {containers.map((container) => ( + + + + + + ))} + +
SectionContainerAmount
{container.section.name}{container.type}{container.inventory}
+ )}
{ manufacturer ? ( - -
-

{manufacturer.name}

-

{manufacturer.description}

-
+ + + + +

{manufacturer.name} ({manufacturer.country_id})

+

{manufacturer.description}

+ + + + +
+
) : ""}
diff --git a/app/components/filters/drink.filter.tsx b/app/components/filters/drink.filter.tsx index 94ba64b..ae9e68e 100644 --- a/app/components/filters/drink.filter.tsx +++ b/app/components/filters/drink.filter.tsx @@ -57,6 +57,7 @@ function DrinkFilter(arg : Arguments) { Sort { [ ["name", "Name"], + ["popular", "Popularity"], ["abv-asc", "ABV Low -> High"], ["abv-desc", "ABV High -> Low"], ["inv-asc", "Inventoy Low -> High"], @@ -89,7 +90,7 @@ function DrinkFilter(arg : Arguments) { Drink - { ["Gluten-free", "Lactose-free", "Organic"].map(key => ( + { ["Gluten-free", "Organic"].map(key => ( - { loggedin ? ( - - ) : "" }