'use client'; import { useState, useEffect } from 'react'; import Header from '@/components/Header'; import { AlertTriangle, CheckCircle, PackageSearch, RefreshCw, Send, ListTree, ArrowDownRight, ArrowUpRight } from 'lucide-react'; export default function DiscrepancyDashboard() { const [warehouse, setWarehouse] = useState('11'); const [data, setData] = useState({ discrepancies: [], accurate: [] }); const [loading, setLoading] = useState(true); useEffect(() => { fetchData(); }, [warehouse]); const fetchData = async () => { setLoading(true); try { const res = await fetch(`/api/reports/discrepancies?warehouse=${warehouse}`); if (res.ok) { const result = await res.json(); setData(result); } } catch (e) { console.error(e); } finally { setLoading(false); } }; const handleRecount = async (productId, productName) => { // In a full system, this would call /api/tasks to assign a recount task alert(`تسک بازشماری برای کالا "${productName}" (کد: ${productId}) صادر شد.`); }; return (
انبار مورد نظر برای بررسی مغایرت
کالاهای دارای مغایرت
{loading ? '-' : data.discrepancies.length}
کالاهای بدون مغایرت
{loading ? '-' : data.accurate.length}
| کالا | موجودی سیستم | شمارش شده | مغایرت | قفسهها | عملیات |
|---|---|---|---|---|---|
|
{item.product_name} کد: {item.product_id} |
{item.system_expected} | {item.total_counted} |
0 ? 'bg-blue-100 text-blue-700' : 'bg-red-100 text-red-700'}`}>
{item.difference > 0 ?
|
{item.locations.length > 0 ? item.locations.join('، ') : 'پیدا نشد'} |
|
| هیچ مغایرتی یافت نشد. همه چیز مرتب است! 🎉 | |||||
| در حال پردازش و مقایسه اطلاعات... | |||||