Files
clinicpro/assets/admin/components/inventory/InventoryStatusBadge.tsx
T
hamedandClaude Opus 4.8 519bc8d7f6 feat: port inventory (انبارداری) page from tauri to admin dashboard
Add a per-tenant (doctor/clinic) Inventory domain and admin page, ported
from clinic-pro-tauri /inventory (which was static/mock) into a real feature.

Backend (src/Inventory/):
- Entities InventoryItem, InventoryPackage, InventoryPackageItem, scoped via
  entity_type/entity_id like TenantTag. Item status is derived, package total
  and availability derived at read time.
- InventoryService (stats, package assembly, availability), thin
  InventoryController with CRUD for items and packages + categories endpoint.
- Migration + docs/api/inventory.md + functional tests (10 tests, 42 assertions).

Frontend (assets/admin/):
- InventoryPage with two tabs (کالاهای مصرفی / پکیج), stat cards, items table
  (desktop + mobile cards), packages accordion, add/edit item and package
  modals, search + category filter — pixel-matched to the tauri source.
- useInventory hook (TanStack Query), route + sidebar link for doctor/clinic.
- Vitest coverage (real data, empty state, modal, packages tab).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-15 13:48:29 +03:30

15 lines
670 B
TypeScript

import React from 'react';
import type { InventoryStatus } from '../../hooks/useInventory';
const CONFIG: Record<InventoryStatus, { label: string; cls: string }> = {
in_stock: { label: 'موجود', cls: 'in-stock' },
low_stock: { label: 'کم موجود', cls: 'low-stock' },
out_of_stock: { label: 'اتمام یافته', cls: 'out-of-stock' },
};
/** Colored availability pill — colors mirror the tauri InventoryStatus component. */
export default function InventoryStatusBadge({ status }: { status: InventoryStatus }) {
const c = CONFIG[status] ?? CONFIG.out_of_stock;
return <span className={`inv-badge ${c.cls}`}>{c.label}</span>;
}