import { useState } from 'react' import { useTranslation } from 'react-i18next' import { toast } from 'sonner' import { PageShell } from '@/layouts/PageShell' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs' import { branches, stockRows } from '@/mocks/data' export function StockPage() { const { t } = useTranslation() const [entry, setEntry] = useState('') const [rows, setRows] = useState(stockRows) const duplicates = entry.length > 2 ? rows.filter((r) => r.name.toLowerCase().includes(entry.toLowerCase()) || r.sku.toLowerCase().includes(entry.toLowerCase())) : [] const resolve = (sku: string) => { setRows((prev) => prev.map((r) => (r.sku === sku ? { ...r, qty: r.erpQty } : r))) toast.success(`Discrepancy resolved for ${sku}`) } return ( Inventory ERP sync AI-assisted entry Transfers SKU Name Branch Qty Batch Expiry Alert {rows.map((r) => ( {r.sku} {r.name} {branches.find((b) => b.id === r.branchId)?.name} {r.qty} {r.batch} {r.expiry} {r.qty < 20 ? low stock : ok} ))}
Platform vs ERP discrepancies {rows .filter((r) => r.qty !== r.erpQty) .map((r) => (

{r.sku}

Platform {r.qty} · ERP {r.erpQty}

))} {rows.every((r) => r.qty === r.erpQty) && (

No open discrepancies

)}
Duplicate detection while typing setEntry(e.target.value)} /> {duplicates.map((d) => (
Possible match: {d.name} ({d.sku}) — merge requires human approval
))}

Stock Manager owns inter-branch transfers. Suggest move of Vitamin C from Bole → CMC (fast mover).

) }