Instruction file imported from Fardus-Hassan/Laam-CRM (
.cursor/rules/inventory-live-data.mdc). Copyright stays with the author.
Inventory UI — live data, not hardcoded mocks
When building inventory forms, dropdowns, and pickers:
- Load options via
inventoryApi(e.g.listSuppliers(),listProducts(),listWarehouses()). - Do not import
MOCK_*arrays frommock-inventory.tsinto page/components for UI options. - Mock data belongs only inside the mock API implementation (
createMockInventoryApi/mock-inventory.tshelpers). - Filter to
status === 'active'(or equivalent) for selectable lists unless the screen is admin/history. - Follow the pattern in
create-purchase-page.tsx:useEffect→ API → map to{ value, label }options.
// BAD — UI hardcodes mock suppliers
import { MOCK_SUPPLIERS } from '@/features/inventory/data/mock-inventory';
options={MOCK_SUPPLIERS.map((s) => ({ value: s.name, label: s.name }))}
// GOOD — UI uses inventoryApi (works for both mock and HTTP modes)
const res = await inventoryApi.listSuppliers();
options={res.items.filter((s) => s.status === 'active').map((s) => ({ value: s.name, label: s.name }))}