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

@@ -584,7 +584,7 @@ router.get('/best-sellers', async (req, res) => {
GROUP BY c.cat_id, c.name
)
SELECT
cat_id as category_id,
cat_id,
name,
units_sold,
revenue,
@@ -604,28 +604,30 @@ router.get('/best-sellers', async (req, res) => {
// Format response with explicit type conversion
const formattedProducts = products.map(p => ({
...p,
pid: p.pid,
sku: p.sku,
title: p.title,
units_sold: parseInt(p.units_sold) || 0,
revenue: parseFloat(p.revenue) || 0,
profit: parseFloat(p.profit) || 0,
growth_rate: parseFloat(p.growth_rate) || 0
revenue: p.revenue.toString(),
profit: p.profit.toString(),
growth_rate: p.growth_rate.toString()
}));
const formattedBrands = brands.map(b => ({
brand: b.brand,
units_sold: parseInt(b.units_sold) || 0,
revenue: parseFloat(b.revenue) || 0,
profit: parseFloat(b.profit) || 0,
growth_rate: parseFloat(b.growth_rate) || 0
revenue: b.revenue.toString(),
profit: b.profit.toString(),
growth_rate: b.growth_rate.toString()
}));
const formattedCategories = categories.map(c => ({
category_id: c.cat_id,
cat_id: c.cat_id,
name: c.name,
units_sold: parseInt(c.units_sold) || 0,
revenue: parseFloat(c.revenue) || 0,
profit: parseFloat(c.profit) || 0,
growth_rate: parseFloat(c.growth_rate) || 0
revenue: c.revenue.toString(),
profit: c.profit.toString(),
growth_rate: c.growth_rate.toString()
}));
res.json({