Misc frontend fixes
This commit is contained in:
@@ -353,22 +353,10 @@ router.get('/stock', async (req, res) => {
|
|||||||
COALESCE(
|
COALESCE(
|
||||||
(SELECT reorder_days
|
(SELECT reorder_days
|
||||||
FROM stock_thresholds st
|
FROM stock_thresholds st
|
||||||
JOIN product_categories pc ON st.cat_id = pc.cat_id
|
WHERE st.vendor = p.vendor LIMIT 1),
|
||||||
WHERE pc.pid = p.pid
|
|
||||||
AND st.vendor = p.vendor LIMIT 1),
|
|
||||||
(SELECT reorder_days
|
(SELECT reorder_days
|
||||||
FROM stock_thresholds st
|
FROM stock_thresholds st
|
||||||
JOIN product_categories pc ON st.cat_id = pc.cat_id
|
WHERE st.vendor IS NULL LIMIT 1),
|
||||||
WHERE pc.pid = p.pid
|
|
||||||
AND st.vendor IS NULL LIMIT 1),
|
|
||||||
(SELECT reorder_days
|
|
||||||
FROM stock_thresholds st
|
|
||||||
WHERE st.cat_id IS NULL
|
|
||||||
AND st.vendor = p.vendor LIMIT 1),
|
|
||||||
(SELECT reorder_days
|
|
||||||
FROM stock_thresholds st
|
|
||||||
WHERE st.cat_id IS NULL
|
|
||||||
AND st.vendor IS NULL LIMIT 1),
|
|
||||||
14
|
14
|
||||||
) as reorder_days
|
) as reorder_days
|
||||||
FROM products p
|
FROM products p
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ export function CategoryPerformance() {
|
|||||||
>
|
>
|
||||||
{data.distribution.map((entry, index) => (
|
{data.distribution.map((entry, index) => (
|
||||||
<Cell
|
<Cell
|
||||||
key={`${entry.category}-${index}`}
|
key={`${entry.category}-${entry.value}-${index}`}
|
||||||
fill={COLORS[index % COLORS.length]}
|
fill={COLORS[index % COLORS.length]}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
@@ -170,7 +170,7 @@ export function CategoryPerformance() {
|
|||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
{data.performance.map((category) => (
|
{data.performance.map((category) => (
|
||||||
<div key={category.category} className="flex items-center">
|
<div key={`${category.category}-${category.revenue}`} className="flex items-center">
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<p className="text-sm font-medium">{getShortCategoryName(category.categoryPath)}</p>
|
<p className="text-sm font-medium">{getShortCategoryName(category.categoryPath)}</p>
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ export function PriceAnalysis() {
|
|||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
{data.recommendations.map((item) => (
|
{data.recommendations.map((item) => (
|
||||||
<div key={item.product} className="flex items-center">
|
<div key={`${item.product}-${item.currentPrice}`} className="flex items-center">
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<p className="text-sm font-medium">{item.product}</p>
|
<p className="text-sm font-medium">{item.product}</p>
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ export function ProfitAnalysis() {
|
|||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
{data.topProducts.map((product) => (
|
{data.topProducts.map((product) => (
|
||||||
<div key={product.product} className="flex items-center">
|
<div key={`${product.product}-${product.category}`} className="flex items-center">
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<p className="text-sm font-medium">{product.product}</p>
|
<p className="text-sm font-medium">{product.product}</p>
|
||||||
<div className="text-xs text-muted-foreground space-y-1">
|
<div className="text-xs text-muted-foreground space-y-1">
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ export function StockAnalysis() {
|
|||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
{data.criticalItems.map((item) => (
|
{data.criticalItems.map((item) => (
|
||||||
<div key={item.sku} className="flex items-center">
|
<div key={`${item.sku}-${item.product}`} className="flex items-center">
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<p className="text-sm font-medium">{item.product}</p>
|
<p className="text-sm font-medium">{item.product}</p>
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ export function VendorPerformance() {
|
|||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
{data.performance.map((vendor) => (
|
{data.performance.map((vendor) => (
|
||||||
<div key={vendor.vendor} className="flex items-center">
|
<div key={`${vendor.vendor}-${vendor.salesVolume}`} className="flex items-center">
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<p className="text-sm font-medium">{vendor.vendor}</p>
|
<p className="text-sm font-medium">{vendor.vendor}</p>
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
|
|||||||
@@ -28,6 +28,11 @@ interface Category {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface TypeCount {
|
||||||
|
type: number;
|
||||||
|
count: number;
|
||||||
|
}
|
||||||
|
|
||||||
interface CategoryFilters {
|
interface CategoryFilters {
|
||||||
search: string;
|
search: string;
|
||||||
type: string;
|
type: string;
|
||||||
@@ -286,7 +291,7 @@ export function Categories() {
|
|||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="all">All Types</SelectItem>
|
<SelectItem value="all">All Types</SelectItem>
|
||||||
{data?.typeCounts?.map(tc => (
|
{data?.typeCounts?.map((tc: TypeCount) => (
|
||||||
<SelectItem key={tc.type} value={tc.type.toString()}>
|
<SelectItem key={tc.type} value={tc.type.toString()}>
|
||||||
{TYPE_LABELS[tc.type]} ({tc.count})
|
{TYPE_LABELS[tc.type]} ({tc.count})
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
@@ -345,9 +350,7 @@ export function Categories() {
|
|||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<span className="font-medium">{category.name}</span>
|
<span className="font-medium">{category.name}</span>
|
||||||
<Badge variant="outline" className="h-5">
|
|
||||||
{TYPE_LABELS[category.type]}
|
|
||||||
</Badge>
|
|
||||||
</div>
|
</div>
|
||||||
{category.description && (
|
{category.description && (
|
||||||
<div className="text-xs text-muted-foreground">{category.description}</div>
|
<div className="text-xs text-muted-foreground">{category.description}</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user