From 4e42794aadcb14e92a955628d2fbf94ff0975109 Mon Sep 17 00:00:00 2001 From: Pattadon Date: Tue, 1 Apr 2025 10:47:22 +0700 Subject: [PATCH] feat: enhance EditInventoryItem component with props and status selection --- .../inventory/edit-inventory-item.tsx | 82 +++++++++++-------- frontend/app/(sidebar)/inventory/page.tsx | 16 ++-- 2 files changed, 56 insertions(+), 42 deletions(-) diff --git a/frontend/app/(sidebar)/inventory/edit-inventory-item.tsx b/frontend/app/(sidebar)/inventory/edit-inventory-item.tsx index 0affb70..b5d2a7a 100644 --- a/frontend/app/(sidebar)/inventory/edit-inventory-item.tsx +++ b/frontend/app/(sidebar)/inventory/edit-inventory-item.tsx @@ -36,14 +36,32 @@ import { cn } from "@/lib/utils"; // import { updateInventoryItem } from "@/api/inventory"; // import type { UpdateInventoryItemInput } from "@/types"; -export function EditInventoryItem() { - const [date, setDate] = useState(); +export interface EditInventoryItemProps { + id: string; + name: string; + category: string; + status: string; + type: string; + unit: string; + quantity: number; +} + +export function EditInventoryItem({ + id, + name, + category, + status, + type, + unit, + quantity, +}: EditInventoryItemProps) { const [open, setOpen] = useState(false); - const [itemName, setItemName] = useState(""); - const [itemType, setItemType] = useState(""); - const [itemCategory, setItemCategory] = useState(""); - const [itemQuantity, setItemQuantity] = useState(0); - const [itemUnit, setItemUnit] = useState(""); + const [itemName, setItemName] = useState(name); + const [itemType, setItemType] = useState(type); + const [itemCategory, setItemCategory] = useState(category); + const [itemQuantity, setItemQuantity] = useState(quantity); + const [itemUnit, setItemUnit] = useState(unit); + const [itemStatus, setItemStatus] = useState(status); // const queryClient = useQueryClient(); @@ -103,7 +121,7 @@ export function EditInventoryItem() { - @@ -116,6 +134,27 @@ export function EditInventoryItem() { +
+ + +
-
- - - - - - - - - -