From fd0e6d1789f17b2afd61a92ee338acec19808a6c Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 23 Dec 2024 14:14:16 -0500 Subject: [PATCH] Clean up revenue, AOV, brands & categories dialogs --- Dev.code-workspace | 19 -- .../src/components/dashboard/StatCards.jsx | 211 ++++++------------ 2 files changed, 69 insertions(+), 161 deletions(-) delete mode 100644 Dev.code-workspace diff --git a/Dev.code-workspace b/Dev.code-workspace deleted file mode 100644 index 08b245b..0000000 --- a/Dev.code-workspace +++ /dev/null @@ -1,19 +0,0 @@ -{ - "folders": [ - { - "path": "." - } - ], - "settings": { - "folder-color.pathColors": [ - { - "folderPath": "Dev/dashboard/", - "badge": "🔵" - }, - { - "folderPath": "Dev/dashboard-server/", - "badge": "🟣" - } - ] - } -} \ No newline at end of file diff --git a/dashboard/src/components/dashboard/StatCards.jsx b/dashboard/src/components/dashboard/StatCards.jsx index c929d13..631ea24 100644 --- a/dashboard/src/components/dashboard/StatCards.jsx +++ b/dashboard/src/components/dashboard/StatCards.jsx @@ -159,7 +159,7 @@ const DetailDialog = ({ children }) => ( - + {title} @@ -180,54 +180,15 @@ const RevenueDetails = ({ data }) => { date: DateTime.fromISO(day.timestamp).toFormat('LLL d') })).sort((a, b) => DateTime.fromISO(a.timestamp) - DateTime.fromISO(b.timestamp)); - // Calculate summary statistics - const totalRevenue = chartData.reduce((sum, day) => sum + day.revenue, 0); - const averageDailyRevenue = totalRevenue / chartData.length; - const maxRevenue = Math.max(...chartData.map(day => day.revenue)); - const minRevenue = Math.min(...chartData.map(day => day.revenue)); - return ( -
- formatCurrency(value)} - height={400} - /> - -
- - - d.revenue === maxRevenue)?.date} - colorClass="text-green-600 dark:text-green-400" - icon={ArrowUp} - /> - d.revenue === minRevenue)?.date} - colorClass="text-green-600 dark:text-green-400" - icon={ArrowDown} - /> -
-
+ formatCurrency(value)} + height={400} + /> ); }; @@ -300,31 +261,13 @@ const AverageOrderDetails = ({ data, orderCount }) => { if (!data?.length) return
No data available for the selected time range.
; return ( - <> - formatCurrency(value)} - /> -
- -
- + formatCurrency(value)} + /> ); }; @@ -419,81 +362,65 @@ const CancellationsDetails = ({ data }) => { const BrandsCategoriesDetails = ({ data }) => { if (!data?.length) return
No data available for the selected time range.
; - const brandData = data[0]?.brands?.list?.map(brand => ({ - name: brand.name, - count: brand.count, - revenue: brand.revenue, - percentage: (brand.count / data[0]?.itemCount * 100) || 0 - }))?.sort((a, b) => b.count - a.count) || []; - - const categoryData = data[0]?.categories?.list?.map(category => ({ - name: category.name, - count: category.count, - revenue: category.revenue, - percentage: (category.count / data[0]?.itemCount * 100) || 0 - }))?.sort((a, b) => b.count - a.count) || []; - - if (!brandData.length && !categoryData.length) { - return
No brands or categories data available.
; - } + const stats = data[0]; + const brandsList = stats?.brands?.list || []; + const categoriesList = stats?.categories?.list || []; return ( -
- {brandData.length > 0 && ( -
-

All Brands

-
- - - - Brand - Items - Revenue - % of Total +
+
+

+ + Brands ({stats?.brands?.total || 0}) +

+
+
+ + + Brand + Items + Revenue + + + + {brandsList.map((brand) => ( + + {brand.name} + {brand.count?.toLocaleString()} + ${brand.revenue?.toFixed(2)} - - - {brandData.map((brand, index) => ( - - {brand.name} - {brand.count.toLocaleString()} - {formatCurrency(brand.revenue)} - {brand.percentage.toFixed(1)}% - - ))} - -
-
+ ))} + +
- )} - - {categoryData.length > 0 && ( -
-

All Categories

-
- - - - Category - Items - Revenue - % of Total + + +
+

+ + Categories ({stats?.categories?.total || 0}) +

+
+
+ + + Category + Items + Revenue + + + + {categoriesList.map((category) => ( + + {category.name} + {category.count?.toLocaleString()} + ${category.revenue?.toFixed(2)} - - - {categoryData.map((category, index) => ( - - {category.name} - {category.count.toLocaleString()} - {formatCurrency(category.revenue)} - {category.percentage.toFixed(1)}% - - ))} - -
-
+ ))} + +
- )} +
); };