From f7e6cbbc6540ba0785ba6de56a97483a0947dffb Mon Sep 17 00:00:00 2001 From: Marius Tarau Date: Wed, 18 Feb 2026 06:35:33 +0200 Subject: [PATCH] feat(it-inventory): add IP/MAC/warranty/cost/rack/vendor/model fields and delete confirmation - New fields: ipAddress, macAddress, warrantyExpiry, purchaseCost, rackLocation, vendor, model - Delete confirmation dialog - Expanded table columns for vendor/model and IP - Search includes IP, vendor, and model - Form layout with organized field groups Co-Authored-By: Claude Opus 4.6 --- .../components/it-inventory-module.tsx | 80 +++++++++++++++---- .../it-inventory/hooks/use-inventory.ts | 20 ++++- src/modules/it-inventory/types.ts | 15 ++++ 3 files changed, 96 insertions(+), 19 deletions(-) diff --git a/src/modules/it-inventory/components/it-inventory-module.tsx b/src/modules/it-inventory/components/it-inventory-module.tsx index 1e54fca..843408e 100644 --- a/src/modules/it-inventory/components/it-inventory-module.tsx +++ b/src/modules/it-inventory/components/it-inventory-module.tsx @@ -9,6 +9,7 @@ import { Textarea } from '@/shared/components/ui/textarea'; import { Badge } from '@/shared/components/ui/badge'; import { Card, CardContent, CardHeader, CardTitle } from '@/shared/components/ui/card'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/shared/components/ui/select'; +import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from '@/shared/components/ui/dialog'; import type { CompanyId } from '@/core/auth/types'; import type { InventoryItem, InventoryItemType, InventoryItemStatus } from '../types'; import { useInventory } from '../hooks/use-inventory'; @@ -28,8 +29,9 @@ export function ItInventoryModule() { const { items, allItems, loading, filters, updateFilter, addItem, updateItem, removeItem } = useInventory(); const [viewMode, setViewMode] = useState('list'); const [editingItem, setEditingItem] = useState(null); + const [deletingId, setDeletingId] = useState(null); - const handleSubmit = async (data: Omit) => { + const handleSubmit = async (data: Omit) => { if (viewMode === 'edit' && editingItem) { await updateItem(editingItem.id, data); } else { @@ -39,6 +41,13 @@ export function ItInventoryModule() { setEditingItem(null); }; + const handleDeleteConfirm = async () => { + if (deletingId) { + await removeItem(deletingId); + setDeletingId(null); + } + }; + return (
{/* Stats */} @@ -51,7 +60,6 @@ export function ItInventoryModule() { {viewMode === 'list' && ( <> - {/* Filters */}
@@ -80,7 +88,6 @@ export function ItInventoryModule() {
- {/* Table */} {loading ? (

Se încarcă...

) : items.length === 0 ? ( @@ -91,7 +98,9 @@ export function ItInventoryModule() { Nume Tip + Vendor/Model S/N + IP Atribuit Locație Status @@ -102,16 +111,22 @@ export function ItInventoryModule() { {item.name} {TYPE_LABELS[item.type]} + + {item.vendor && {item.vendor}} + {item.vendor && item.model && / } + {item.model && {item.model}} + {item.serialNumber} + {item.ipAddress} {item.assignedTo} - {item.location} + {item.rackLocation || item.location} {STATUS_LABELS[item.status]}
-
@@ -137,13 +152,25 @@ export function ItInventoryModule() { )} + + {/* Delete confirmation */} + { if (!open) setDeletingId(null); }}> + + Confirmare ștergere +

Ești sigur că vrei să ștergi acest echipament? Acțiunea este ireversibilă.

+ + + + +
+
); } function InventoryForm({ initial, onSubmit, onCancel }: { initial?: InventoryItem; - onSubmit: (data: Omit) => void; + onSubmit: (data: Omit) => void; onCancel: () => void; }) { const [name, setName] = useState(initial?.name ?? ''); @@ -154,12 +181,26 @@ function InventoryForm({ initial, onSubmit, onCancel }: { const [location, setLocation] = useState(initial?.location ?? ''); const [purchaseDate, setPurchaseDate] = useState(initial?.purchaseDate ?? ''); const [status, setStatus] = useState(initial?.status ?? 'active'); + const [ipAddress, setIpAddress] = useState(initial?.ipAddress ?? ''); + const [macAddress, setMacAddress] = useState(initial?.macAddress ?? ''); + const [warrantyExpiry, setWarrantyExpiry] = useState(initial?.warrantyExpiry ?? ''); + const [purchaseCost, setPurchaseCost] = useState(initial?.purchaseCost ?? ''); + const [rackLocation, setRackLocation] = useState(initial?.rackLocation ?? ''); + const [vendor, setVendor] = useState(initial?.vendor ?? ''); + const [model, setModel] = useState(initial?.model ?? ''); const [notes, setNotes] = useState(initial?.notes ?? ''); return ( -
{ e.preventDefault(); onSubmit({ name, type, serialNumber, assignedTo, company, location, purchaseDate, status, notes, tags: initial?.tags ?? [], visibility: initial?.visibility ?? 'all' }); }} className="space-y-4"> + { + e.preventDefault(); + onSubmit({ + name, type, serialNumber, assignedTo, company, location, purchaseDate, status, + ipAddress, macAddress, warrantyExpiry, purchaseCost, rackLocation, vendor, model, + notes, tags: initial?.tags ?? [], visibility: initial?.visibility ?? 'all', + }); + }} className="space-y-4">
-
setName(e.target.value)} className="mt-1" required />
+
setName(e.target.value)} className="mt-1" required />
-
+
+
setVendor(e.target.value)} className="mt-1" placeholder="Dell, HP, Lenovo..." />
+
setModel(e.target.value)} className="mt-1" />
setSerialNumber(e.target.value)} className="mt-1" />
-
setAssignedTo(e.target.value)} className="mt-1" />
+
setIpAddress(e.target.value)} className="mt-1" placeholder="192.168.1.x" />
+
setMacAddress(e.target.value)} className="mt-1" placeholder="AA:BB:CC:DD:EE:FF" />
+
setAssignedTo(e.target.value)} className="mt-1" />
+
+
-
setLocation(e.target.value)} className="mt-1" />
-
setPurchaseDate(e.target.value)} className="mt-1" />
-
-
+
setLocation(e.target.value)} className="mt-1" />
+
setRackLocation(e.target.value)} className="mt-1" />
-