From f3fb067da716f15d144d1b6c0e4715caa488f891 Mon Sep 17 00:00:00 2001 From: NotII <46204250+NotII@users.noreply.github.com> Date: Tue, 26 Aug 2025 21:03:05 +0100 Subject: [PATCH] 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. --- components/analytics/AnalyticsDashboard.tsx | 21 +- components/analytics/ProfitAnalyticsChart.tsx | 270 ++++++++++++++++++ lib/services/profit-analytics-service.ts | 48 ++++ 3 files changed, 336 insertions(+), 3 deletions(-) create mode 100644 components/analytics/ProfitAnalyticsChart.tsx create mode 100644 lib/services/profit-analytics-service.ts diff --git a/components/analytics/AnalyticsDashboard.tsx b/components/analytics/AnalyticsDashboard.tsx index edcc9c2..428c9de 100644 --- a/components/analytics/AnalyticsDashboard.tsx +++ b/components/analytics/AnalyticsDashboard.tsx @@ -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: () => }); +const ProfitAnalyticsChart = dynamic(() => import('./ProfitAnalyticsChart'), { + loading: () => +}); + // Chart loading skeleton function ChartSkeleton() { return ( @@ -249,7 +254,7 @@ export default function AnalyticsDashboard({ initialData }: AnalyticsDashboardPr

Time Period

- 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.