Frontend fixes - dashboard, products, forecasting

This commit is contained in:
2025-01-28 14:26:44 -05:00
parent 7e341a152c
commit b1f252bea8
5 changed files with 40 additions and 34 deletions

View File

@@ -18,9 +18,10 @@ interface Product {
interface Category {
cat_id: number;
name: string;
total_revenue: string;
total_profit: string;
total_units: number;
units_sold: number;
revenue: string;
profit: string;
growth_rate: string;
}
interface BestSellerBrand {
@@ -159,9 +160,9 @@ export function BestSellers() {
{data?.categories.map((category) => (
<TableRow key={category.cat_id}>
<TableCell>{category.name}</TableCell>
<TableCell className="text-right">{category.total_units}</TableCell>
<TableCell className="text-right">{formatCurrency(Number(category.total_revenue))}</TableCell>
<TableCell className="text-right">{formatCurrency(Number(category.total_profit))}</TableCell>
<TableCell className="text-right">{category.units_sold}</TableCell>
<TableCell className="text-right">{formatCurrency(Number(category.revenue))}</TableCell>
<TableCell className="text-right">{formatCurrency(Number(category.profit))}</TableCell>
</TableRow>
))}
</TableBody>

View File

@@ -205,8 +205,8 @@ export function ProductDetail({ productId, onClose }: ProductDetailProps) {
</div>
)}
<div>
<h2 className="text-xl font-semibold">{product?.title || 'Loading...'}</h2>
<p className="text-sm text-muted-foreground">{product?.SKU || ''}</p>
<VaulDrawer.Title className="text-xl font-semibold">{product?.title || 'Loading...'}</VaulDrawer.Title>
<VaulDrawer.Description className="text-sm text-muted-foreground">{product?.SKU || ''}</VaulDrawer.Description>
</div>
</div>
<Button variant="ghost" size="icon" onClick={onClose}>

View File

@@ -67,12 +67,14 @@ export default function Forecasting() {
avgTotalSold: Number(item.avgTotalSold) || 0,
products: item.products?.map((p: any) => ({
pid: p.pid,
name: p.title,
title: p.title,
sku: p.sku,
stock_quantity: Number(p.stock_quantity) || 0,
total_sold: Number(p.total_sold) || 0,
avg_price: Number(p.avg_price) || 0,
first_received_date: p.first_received_date,
daily_sales_avg: Number(p.daily_sales_avg) || 0,
forecast_units: Number(p.forecast_units) || 0,
forecast_revenue: Number(p.forecast_revenue) || 0,
confidence_level: Number(p.confidence_level) || 0
}))
}));
},