diff --git a/src/Components/ProductsPage/ViewManager.tsx b/src/Components/ProductsPage/ViewManager.tsx index 0ef4659..da535a6 100644 --- a/src/Components/ProductsPage/ViewManager.tsx +++ b/src/Components/ProductsPage/ViewManager.tsx @@ -4,11 +4,21 @@ import { Switch } from "@mui/material"; import TableView from "../../Components/ProductsPage/TableView/TableView"; import BlobView from "../../Components/ProductsPage/BlobView/BlobView"; import { ProductList } from "../../Interfaces/Interfaces"; +import styles from "../../styles"; export interface props {} export default function ViewManager(props: ProductList) { - const [tableView, toggleTableView] = useState(false); + const [tableView, toggleTableView] = useState(true); + if (props.Products.length === 0) { + return ( +
+

+ No products yet. Add one! +

+
+ ); + } if (tableView) { return (
diff --git a/src/Routes/Dashboard/Dashboard.tsx b/src/Routes/Dashboard/Dashboard.tsx index c52dfac..8be0dce 100644 --- a/src/Routes/Dashboard/Dashboard.tsx +++ b/src/Routes/Dashboard/Dashboard.tsx @@ -16,7 +16,7 @@ export default function Dashboard() {
-

Dashboard

+

Dashboard

-

+

Total Products -

+

-

+

2546 Unique Items -

-

+

+

In inventory -

+

-

+

Current Session -

+

-

+

Added -

+

-

254

+

254

-

+

Removed -

+

-

118

+

118

-

+

Low Stock -

+

-

+

Canned Pagmamahal -

-

+

+

In Stock: 3 -

+

-

Recently Added -

+

-

+

Zidane's Water -

-

+

+

Added 02/17/2023 -

+

@@ -133,66 +133,58 @@ export default function Dashboard() {
-

- Recent -

-

+

Recent

+

Transactions -

+

-

+

Kopiko Blanca -

-

- Added: 96 -

-

+

+

Added: 96

+

Removed: 105 -

-

+

+

02/17/2023 -

+

-

+

Zidane's Water -

-

- Added: 49 -

-

+

+

Added: 49

+

Removed: 24 -

-

+

+

02/17/2023 -

+

-

+

Dan's Beefed Corn -

-

- Added: 32 -

-

+

+

Added: 32

+

Removed: 64 -

-

+

+

02/17/2023 -

+

-

+

Canned Pagmamahal -

+

-

Added: 0

-

+

Added: 0

+

Removed: 60 -

-

+

+

02/17/2023 -

+

diff --git a/src/Routes/Login/Login.tsx b/src/Routes/Login/Login.tsx index bd62753..e2ace97 100644 --- a/src/Routes/Login/Login.tsx +++ b/src/Routes/Login/Login.tsx @@ -36,9 +36,9 @@ export default function Login() { >
-

+

Login to Ivy -

+

Username

diff --git a/src/Routes/Logs/Logs.tsx b/src/Routes/Logs/Logs.tsx index 4bd49fe..5ef42a2 100644 --- a/src/Routes/Logs/Logs.tsx +++ b/src/Routes/Logs/Logs.tsx @@ -18,7 +18,7 @@ export default function Logs() {
-

Logs

+

Logs

-

- Add Product -

+

Add Product

diff --git a/src/Routes/Product/Product.tsx b/src/Routes/Product/Product.tsx index 6ea3d2c..5497a35 100644 --- a/src/Routes/Product/Product.tsx +++ b/src/Routes/Product/Product.tsx @@ -1,12 +1,14 @@ import * as React from "react"; import styles from "../../styles"; import { Button } from "@mui/material"; -import { useParams } from "react-router-dom"; +import { useNavigate, useParams } from "react-router-dom"; import LoginChecker from "../../Components/LoginChecker/LoginChecker"; -import { GetProduct } from "../../Components/Api/Api"; -import { useQuery } from "react-query"; +import { DeleteProduct, GetProduct } from "../../Components/Api/Api"; +import { useMutation, useQuery, useQueryClient } from "react-query"; +import ProductIcon from "../../Components/Icons/ProductIcon/ProductIcon"; export default function Product() { + const navigate = useNavigate(); let { id } = useParams(); const { data: product, @@ -16,17 +18,38 @@ export default function Product() { queryKey: ["product", Number(id)], queryFn: () => GetProduct(Number(id)), }); + const queryClient = useQueryClient(); + const mutation = useMutation({ + mutationFn: DeleteProduct, + onSuccess: () => { + queryClient.invalidateQueries("products"); + }, + }); if (isLoading) { return (
-

+

Individual Product View for id {id} -

+

-

+

Loading product... -

+

+
+
+ ); + } else if (error) { + return ( +
+ +

+ Individual Product View for id {id} +

+
+

+ Error loading product +

); @@ -34,24 +57,32 @@ export default function Product() { return (
-

- Individual Product View for id {id} -

+
+ +

Product View

+
+
-

- Product Name: {product.name} -

-

- Date Added: {product.date_added} -

+
+

+ Product Name: {product.name} +

+

+ Date Added: {product.date_added} +

+
diff --git a/src/Routes/Products/Products.tsx b/src/Routes/Products/Products.tsx index bd81804..95e6a37 100644 --- a/src/Routes/Products/Products.tsx +++ b/src/Routes/Products/Products.tsx @@ -25,16 +25,16 @@ export default function Products() {
-

+

Products -

+

-

+

Loading products... -

+

); @@ -45,16 +45,16 @@ export default function Products() {
-

+

Products -

+

-

+

Error loading products -

+

); @@ -65,9 +65,7 @@ export default function Products() {
-

- Products -

+

Products

-

Inventory

+

Inventory