File size: 2,553 Bytes
621df6e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | export const DataResponseCard = ({ data }) => {
if (data.type === 'inventory') {
return (
<div className="space-y-3">
<p className="text-slate-200">Current store inventory details:</p>
<div className="grid grid-cols-2 gap-2 text-xs">
<div className="bg-slate-900 p-2.5 rounded-lg border border-slate-700">
<span className="text-slate-400 block">Product Lines</span>
<span className="text-lg font-bold text-emerald-400">{data.productCount}</span>
</div>
<div className="bg-slate-900 p-2.5 rounded-lg border border-slate-700">
<span className="text-slate-400 block">Total Units</span>
<span className="text-lg font-bold text-emerald-400">{data.totalUnits}</span>
</div>
</div>
<div className="bg-slate-900 rounded-lg p-3 border border-slate-700 space-y-1 text-xs">
<div className="font-semibold text-slate-300 mb-1">Items List</div>
{data.products.length === 0 ? (
<p className="text-slate-500">No products found in database.</p>
) : (
data.products.map(p => (
<div key={p.id || p.product_name} className="flex justify-between py-1 border-b border-slate-800 last:border-0">
<span>{p.product_name}</span>
<span className="text-slate-400">{p.stock_quantity} in stock (₱{p.price})</span>
</div>
))
)}
</div>
</div>
);
}
if (data.type === 'sales') {
return (
<div className="space-y-3">
<p className="text-slate-200">Sales metrics summary:</p>
<div className="grid grid-cols-3 gap-2 text-xs">
<div className="bg-slate-900 p-2.5 rounded-lg border border-slate-700">
<span className="text-slate-400 block">Revenue</span>
<span className="text-sm font-bold text-emerald-400">₱{data.totalRev.toFixed(2)}</span>
</div>
<div className="bg-slate-900 p-2.5 rounded-lg border border-slate-700">
<span className="text-slate-400 block">Orders</span>
<span className="text-sm font-bold text-emerald-400">{data.totalOrders}</span>
</div>
<div className="bg-slate-900 p-2.5 rounded-lg border border-slate-700">
<span className="text-slate-400 block">Average</span>
<span className="text-sm font-bold text-emerald-400">₱{data.avgOrder.toFixed(2)}</span>
</div>
</div>
</div>
);
}
return null;
}; |