From 3bd532c02cbc168eef4cfd69205de729eb8dd335 Mon Sep 17 00:00:00 2001 From: keannu125 Date: Thu, 2 Mar 2023 22:29:30 +0800 Subject: [PATCH] Made stocks color responsive to input --- src/routes/Inventory/Inventory.tsx | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/routes/Inventory/Inventory.tsx b/src/routes/Inventory/Inventory.tsx index d9112c5..a37534d 100644 --- a/src/routes/Inventory/Inventory.tsx +++ b/src/routes/Inventory/Inventory.tsx @@ -22,36 +22,36 @@ export default function Inventory() { } } function StockRender(in_stock: number) { - const [stock, setStock] = useState("" + in_stock); - if (in_stock > 0 && in_stock < 3) { + const [stock, setStock] = useState(in_stock); + if (stock >= 0 && stock <= 3) { return ( - + ) => { if (is_number(e.target.value) === true) { - setStock(e.target.value); + setStock(parseInt(e.target.value)); } }} /> ); - } else if (in_stock > 3 && in_stock < 9) { + } else if (stock >= 4 && stock < 9) { return ( - + ) => { if (is_number(e.target.value) === true) { - setStock(e.target.value); + setStock(parseInt(e.target.value)); } }} /> @@ -59,16 +59,16 @@ export default function Inventory() { ); } else { return ( - + ) => { if (is_number(e.target.value) === true) { - setStock(e.target.value); + setStock(parseInt(e.target.value)); } }} />