feat: Implement category and unit selection for inventory items

- Added a new 'category' field to the InventoryItem entity and updated the database schema.
- Replaced free-text input for 'unit' and 'category' with select dropdowns in the AddItemModal.
- Introduced a new API endpoint to fetch metadata for units and categories.
- Updated inventory filtering logic to use the new 'category' field instead of 'consumable'.
- Enhanced validation for item creation and updates to ensure valid unit and category values.
- Updated tests to cover new functionality and ensure proper validation.
This commit is contained in:
hamed
2026-07-15 14:32:29 +03:30
parent defa0db023
commit 3e5dee0ad5
12 changed files with 513 additions and 36 deletions
+3 -2
View File
@@ -14,7 +14,7 @@ type Tab = 'stock' | 'packages';
/** انبارداری — consumable stock items + packages. Ported from clinic-pro-tauri /inventory. */
export default function InventoryPage() {
const {
items, stats, packages, categories, itemsLoading, packagesLoading,
items, stats, packages, categories, meta, itemsLoading, packagesLoading,
createItem, updateItem, deleteItem, createPackage, updatePackage, deletePackage,
} = useInventory();
@@ -31,7 +31,7 @@ export default function InventoryPage() {
const q = search.trim();
return items.filter((it) =>
(q === '' || it.name.includes(q)) &&
(category === '' || it.consumable === category)
(category === '' || it.category === category)
);
}, [items, search, category]);
@@ -120,6 +120,7 @@ export default function InventoryPage() {
<AddItemModal
open={itemModal.open}
editing={itemModal.editing}
meta={meta}
saving={createItem.isPending || updateItem.isPending}
onClose={() => setItemModal({ open: false, editing: null })}
onSave={saveItem}