From 7b17576add66530996b6f9d79ef4a50ea3070848 Mon Sep 17 00:00:00 2001 From: keannu125 Date: Mon, 6 Mar 2023 22:41:40 +0800 Subject: [PATCH] Polished empty inventory page --- .../InventoryPage/RowRenderer/RowRenderer.tsx | 15 -------- src/routes/Inventory/Inventory.tsx | 34 +++++++++++++++++++ 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/Components/InventoryPage/RowRenderer/RowRenderer.tsx b/src/Components/InventoryPage/RowRenderer/RowRenderer.tsx index a1f064d..7d1dbf8 100644 --- a/src/Components/InventoryPage/RowRenderer/RowRenderer.tsx +++ b/src/Components/InventoryPage/RowRenderer/RowRenderer.tsx @@ -5,21 +5,6 @@ import { TableBody, TableRow, TableCell } from "@mui/material"; import StockRenderer from "../StockRenderer/StockRenderer"; export default function RowRenderer(props: ProductList) { - if (props.Products.length === 0) { - return ( -
-

- No products yet. Add one! -

-
- ); - } return ( {props.Products.map((row) => ( diff --git a/src/routes/Inventory/Inventory.tsx b/src/routes/Inventory/Inventory.tsx index 1cc56f9..afb07ad 100644 --- a/src/routes/Inventory/Inventory.tsx +++ b/src/routes/Inventory/Inventory.tsx @@ -2,6 +2,7 @@ import React from "react"; import styles from "../../styles"; import InventoryIcon from "../../Components/Icons/InventoryIcon/InventoryIcon"; import { + Button, Table, TableBody, TableCell, @@ -15,6 +16,8 @@ import LoginChecker from "../../Components/LoginChecker/LoginChecker"; import { GetProducts, UpdateProduct } from "../../Components/Api/Api"; import { useMutation, useQuery, useQueryClient } from "react-query"; import RowRenderer from "../../Components/InventoryPage/RowRenderer/RowRenderer"; +import AddIcon from "../../Components/Icons/AddIcon/AddIcon"; +import { useNavigate } from "react-router-dom"; export default function Inventory() { const { @@ -22,6 +25,7 @@ export default function Inventory() { isLoading, error, } = useQuery("products", GetProducts, { retry: 0 }); + const navigate = useNavigate(); if (isLoading) { return ( @@ -64,6 +68,36 @@ export default function Inventory() { ); + } else if (products.length === 0) { + return ( +
+ +
+ +

Inventory

+
+
+

+ No products yet. Add one! +

+ +
+
+ ); } return (