From 4d603961b26754f10b134e6c03b0c6f31b75ee98 Mon Sep 17 00:00:00 2001 From: Terry Date: Mon, 13 Feb 2023 00:53:39 -0500 Subject: [PATCH 1/4] IEEE-249: Issues with negative stock number and blank datasheet and manufacturing number fixed --- .../src/components/inventory/Item/Item.tsx | 4 +- .../ProductOverview/ProductOverview.tsx | 42 +++++++++++-------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/hackathon_site/dashboard/frontend/src/components/inventory/Item/Item.tsx b/hackathon_site/dashboard/frontend/src/components/inventory/Item/Item.tsx index 9c7c33c..e112737 100644 --- a/hackathon_site/dashboard/frontend/src/components/inventory/Item/Item.tsx +++ b/hackathon_site/dashboard/frontend/src/components/inventory/Item/Item.tsx @@ -18,8 +18,8 @@ const Item = ({ image, title, total, currentStock }: ItemProps): ReactElement => const stock = !currentStock ? "OUT OF STOCK" : userType === "participant" - ? currentStock + " IN STOCK" - : currentStock + " OF " + total + " IN STOCK"; + ? Math.max(currentStock, 0) + " IN STOCK" + : Math.max(currentStock, 0) + " OF " + total + " IN STOCK"; const stockStyle = !currentStock ? styles.outOfStock : styles.inStock; const coverStyle = !currentStock ? styles.itemBlack : styles.itemBox; diff --git a/hackathon_site/dashboard/frontend/src/components/inventory/ProductOverview/ProductOverview.tsx b/hackathon_site/dashboard/frontend/src/components/inventory/ProductOverview/ProductOverview.tsx index 3a8f847..7d89e96 100644 --- a/hackathon_site/dashboard/frontend/src/components/inventory/ProductOverview/ProductOverview.tsx +++ b/hackathon_site/dashboard/frontend/src/components/inventory/ProductOverview/ProductOverview.tsx @@ -230,21 +230,29 @@ export const DetailInfoSection = ({ Manufacturer {manufacturer} - - Model Number - - {modelNumber} - - Datasheet - - + {modelNumber && ( + <> + + Model Number + + {modelNumber} + + )} + {datasheet && ( + <> + + Datasheet + + + + )} {notes && ( <> @@ -279,11 +287,11 @@ const MainSection = ({ OUT OF STOCK ) : userType === "participant" ? ( - {quantityRemaining} IN STOCK + {Math.max(quantityRemaining, 0)} IN STOCK ) : ( - {quantityRemaining} OF {quantityAvailable} IN STOCK + {Math.max(quantityRemaining, 0)} OF {quantityAvailable} IN STOCK ); From 5066b6353cd1b681c726d700df4d7c09aef686fb Mon Sep 17 00:00:00 2001 From: Terry Date: Wed, 15 Feb 2023 14:50:43 -0500 Subject: [PATCH 2/4] IEEE-249: Fixed Item.tsx formatting issues --- .../dashboard/frontend/src/components/inventory/Item/Item.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hackathon_site/dashboard/frontend/src/components/inventory/Item/Item.tsx b/hackathon_site/dashboard/frontend/src/components/inventory/Item/Item.tsx index e112737..764d0a1 100644 --- a/hackathon_site/dashboard/frontend/src/components/inventory/Item/Item.tsx +++ b/hackathon_site/dashboard/frontend/src/components/inventory/Item/Item.tsx @@ -18,8 +18,8 @@ const Item = ({ image, title, total, currentStock }: ItemProps): ReactElement => const stock = !currentStock ? "OUT OF STOCK" : userType === "participant" - ? Math.max(currentStock, 0) + " IN STOCK" - : Math.max(currentStock, 0) + " OF " + total + " IN STOCK"; + ? Math.max(currentStock, 0) + " IN STOCK" + : Math.max(currentStock, 0) + " OF " + total + " IN STOCK"; const stockStyle = !currentStock ? styles.outOfStock : styles.inStock; const coverStyle = !currentStock ? styles.itemBlack : styles.itemBox; From 552e82a906250ae79eb8ef00b82adc17c377b413 Mon Sep 17 00:00:00 2001 From: Terry Date: Fri, 17 Feb 2023 00:00:04 -0500 Subject: [PATCH 3/4] Added OUT OF STOCK option --- .../dashboard/frontend/src/components/inventory/Item/Item.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hackathon_site/dashboard/frontend/src/components/inventory/Item/Item.tsx b/hackathon_site/dashboard/frontend/src/components/inventory/Item/Item.tsx index 764d0a1..cb7a2d0 100644 --- a/hackathon_site/dashboard/frontend/src/components/inventory/Item/Item.tsx +++ b/hackathon_site/dashboard/frontend/src/components/inventory/Item/Item.tsx @@ -19,7 +19,9 @@ const Item = ({ image, title, total, currentStock }: ItemProps): ReactElement => ? "OUT OF STOCK" : userType === "participant" ? Math.max(currentStock, 0) + " IN STOCK" - : Math.max(currentStock, 0) + " OF " + total + " IN STOCK"; + : currentStock === 0 + ? "OUT OF STOCK" + : Math.max(currentStock, 1) + " OF " + total + " IN STOCK"; const stockStyle = !currentStock ? styles.outOfStock : styles.inStock; const coverStyle = !currentStock ? styles.itemBlack : styles.itemBox; From 537561009f3876ff6932a8b7e88fcf9490025573 Mon Sep 17 00:00:00 2001 From: Terry Date: Sat, 18 Feb 2023 10:05:52 -0500 Subject: [PATCH 4/4] Replaced minimum function with Out of Stock --- .../frontend/src/components/inventory/Item/Item.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/hackathon_site/dashboard/frontend/src/components/inventory/Item/Item.tsx b/hackathon_site/dashboard/frontend/src/components/inventory/Item/Item.tsx index cb7a2d0..bf3566b 100644 --- a/hackathon_site/dashboard/frontend/src/components/inventory/Item/Item.tsx +++ b/hackathon_site/dashboard/frontend/src/components/inventory/Item/Item.tsx @@ -15,13 +15,11 @@ interface ItemProps { const Item = ({ image, title, total, currentStock }: ItemProps): ReactElement => { const userType = useSelector(userTypeSelector); - const stock = !currentStock + const stock = !currentStock || currentStock < 0 ? "OUT OF STOCK" : userType === "participant" - ? Math.max(currentStock, 0) + " IN STOCK" - : currentStock === 0 - ? "OUT OF STOCK" - : Math.max(currentStock, 1) + " OF " + total + " IN STOCK"; + ? currentStock + " IN STOCK" + : currentStock + " OF " + total + " IN STOCK"; const stockStyle = !currentStock ? styles.outOfStock : styles.inStock; const coverStyle = !currentStock ? styles.itemBlack : styles.itemBox;