diff --git a/src/routes/Products/AddProduct/AddProduct.tsx b/src/routes/Products/AddProduct/AddProduct.tsx index 8f67675..d36e1b8 100644 --- a/src/routes/Products/AddProduct/AddProduct.tsx +++ b/src/routes/Products/AddProduct/AddProduct.tsx @@ -47,9 +47,8 @@ export default function AddProduct() {
-

Products

+

Add Product

-

Add Product

diff --git a/src/routes/Products/EditProduct/EditProduct.tsx b/src/routes/Products/EditProduct/EditProduct.tsx index 614c2dd..5ffc8ed 100644 --- a/src/routes/Products/EditProduct/EditProduct.tsx +++ b/src/routes/Products/EditProduct/EditProduct.tsx @@ -8,10 +8,10 @@ import { TableHead, TableRow, TextField, - IconButton, } from "@mui/material"; import { ProductType } from "../../../Components/ProductType/ProductType"; import ProductsLists from "../../../Components/ProductsLists/ProductsLists"; +import ProductsIcon from "../../../Components/Icons/ProductsIcon/ProductsIcon"; import styles from "../../../styles"; type EditProductParams = { @@ -26,30 +26,26 @@ export default function EditProduct() { const [stocks, setStocks] = useState(""); useEffect(() => { - const product = ProductsLists.find((product) => product.id.toString() === id); + const product = ProductsLists.find((product) => product.id.toString().padStart(3, '0') === id); if (product) { setName(product.name); setStocks(product.stocks.toString()); } }, [id]); - const handleNameChange = (event: React.ChangeEvent) => { - setName(event.target.value); - }; - const handleStocksChange = (event: React.ChangeEvent) => { setStocks(event.target.value); }; const handleUpdateProduct = () => { const updatedProduct: ProductType = { - id: parseInt(id || "0"), // add a default value of "0" for id if it's undefined + id: parseInt(id || "0"), // add a default value of "0" for id if it's undefined and pad with leading zeros name: name, stocks: parseInt(stocks), lastModified: new Date().toLocaleString(), }; - const index = ProductsLists.findIndex((product) => product.id.toString() === id); + const index = ProductsLists.findIndex((product) => product.id.toString().padStart(3, '0') === id); ProductsLists.splice(index, 1, updatedProduct); navigate("/Products"); @@ -60,8 +56,9 @@ export default function EditProduct() { }; return ( -
+
+

Edit Product