Add profit analytics chart and service
Introduces a new ProfitAnalyticsChart component to display profit-related metrics, including total revenue, cost, profit, and top profitable products. Updates the AnalyticsDashboard to include a Profit tab and adds a profit-analytics-service for fetching profit data from the backend.
This commit is contained in:
@@ -17,7 +17,8 @@ import {
|
||||
Activity,
|
||||
RefreshCw,
|
||||
Eye,
|
||||
EyeOff
|
||||
EyeOff,
|
||||
Calculator
|
||||
} from "lucide-react";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
import MetricsCard from "./MetricsCard";
|
||||
@@ -44,6 +45,10 @@ const OrderAnalyticsChart = dynamic(() => import('./OrderAnalyticsChart'), {
|
||||
loading: () => <ChartSkeleton />
|
||||
});
|
||||
|
||||
const ProfitAnalyticsChart = dynamic(() => import('./ProfitAnalyticsChart'), {
|
||||
loading: () => <ChartSkeleton />
|
||||
});
|
||||
|
||||
// Chart loading skeleton
|
||||
function ChartSkeleton() {
|
||||
return (
|
||||
@@ -249,7 +254,7 @@ export default function AnalyticsDashboard({ initialData }: AnalyticsDashboardPr
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold">Time Period</h3>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Revenue and Orders tabs use time filtering. Products and Customers show all-time data.
|
||||
Revenue, Profit, and Orders tabs use time filtering. Products and Customers show all-time data.
|
||||
</p>
|
||||
</div>
|
||||
<Select value={timeRange} onValueChange={setTimeRange}>
|
||||
@@ -267,11 +272,15 @@ export default function AnalyticsDashboard({ initialData }: AnalyticsDashboardPr
|
||||
{/* Analytics Tabs */}
|
||||
<div className="space-y-6">
|
||||
<Tabs defaultValue="revenue" className="space-y-6">
|
||||
<TabsList className="grid w-full grid-cols-4">
|
||||
<TabsList className="grid w-full grid-cols-5">
|
||||
<TabsTrigger value="revenue" className="flex items-center gap-2">
|
||||
<TrendingUp className="h-4 w-4" />
|
||||
Revenue
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="profit" className="flex items-center gap-2">
|
||||
<Calculator className="h-4 w-4" />
|
||||
Profit
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="products" className="flex items-center gap-2">
|
||||
<Package className="h-4 w-4" />
|
||||
Products
|
||||
@@ -292,6 +301,12 @@ export default function AnalyticsDashboard({ initialData }: AnalyticsDashboardPr
|
||||
</Suspense>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="profit" className="space-y-6">
|
||||
<Suspense fallback={<ChartSkeleton />}>
|
||||
<ProfitAnalyticsChart timeRange={timeRange} hideNumbers={hideNumbers} />
|
||||
</Suspense>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="products" className="space-y-6">
|
||||
<Suspense fallback={<ChartSkeleton />}>
|
||||
<ProductPerformanceChart />
|
||||
|
||||
Reference in New Issue
Block a user