holy fkn airball
This commit is contained in:
@@ -4,23 +4,11 @@ import { useState, useEffect } from 'react';
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { clientFetch } from "@/lib/api";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Package, TrendingUp } from "lucide-react";
|
||||
|
||||
interface ProductPerformance {
|
||||
productId: string;
|
||||
name: string;
|
||||
image: string;
|
||||
unitType: string;
|
||||
currentStock: number;
|
||||
stockStatus: string;
|
||||
totalSold: number;
|
||||
totalRevenue: number;
|
||||
orderCount: number;
|
||||
averagePrice: number;
|
||||
}
|
||||
import { Package } from "lucide-react";
|
||||
import { getProductPerformanceWithStore, type ProductPerformance } from "@/lib/services/analytics-service";
|
||||
import { formatGBP } from "@/utils/format";
|
||||
|
||||
export default function ProductPerformanceChart() {
|
||||
const [data, setData] = useState<ProductPerformance[]>([]);
|
||||
@@ -33,7 +21,7 @@ export default function ProductPerformanceChart() {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
setError(null);
|
||||
const response = await clientFetch<ProductPerformance[]>('/analytics/product-performance');
|
||||
const response = await getProductPerformanceWithStore();
|
||||
setData(response);
|
||||
} catch (err) {
|
||||
console.error('Error fetching product performance:', err);
|
||||
@@ -214,13 +202,13 @@ export default function ProductPerformanceChart() {
|
||||
{product.totalSold.toFixed(2)}
|
||||
</TableCell>
|
||||
<TableCell className="text-right font-medium text-green-600">
|
||||
${product.totalRevenue.toFixed(2)}
|
||||
{formatGBP(product.totalRevenue)}
|
||||
</TableCell>
|
||||
<TableCell className="text-right">
|
||||
{product.orderCount}
|
||||
</TableCell>
|
||||
<TableCell className="text-right">
|
||||
${product.averagePrice.toFixed(2)}
|
||||
{formatGBP(product.averagePrice)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user