From 01b86459a31ef0db1b2369263a0db151b7a15c99 Mon Sep 17 00:00:00 2001 From: Matt Date: Sun, 22 Dec 2024 15:15:06 -0500 Subject: [PATCH] Improve shipping locations table --- .../src/components/dashboard/StatCards.jsx | 119 ++++++++++++++---- 1 file changed, 98 insertions(+), 21 deletions(-) diff --git a/dashboard/src/components/dashboard/StatCards.jsx b/dashboard/src/components/dashboard/StatCards.jsx index 5514af1..4b5d8c3 100644 --- a/dashboard/src/components/dashboard/StatCards.jsx +++ b/dashboard/src/components/dashboard/StatCards.jsx @@ -629,30 +629,107 @@ const ShippingDetails = ({ data }) => {

Shipping Locations

-
-
- {locations.byState?.map((location) => ( -
-
- {location.state} - - {location.country} - +
+ {/* Country summary cards */} +
+ {locations.byCountry?.slice(0, 3).map((country) => ( + +
+
+

{country.country}

+

+ {country.states.length} states/regions +

+
+
+
{country.count.toLocaleString()}
+
+ {country.percentage.toFixed(1)}% +
+
-
- - {location.count.toLocaleString()} - - - ({location.percentage.toFixed(1)}%) - +
+
-
+ ))}
+ + {/* States grid */} +
+
+ {/* Left column */} +
+
+ Top States + Orders +
+ {locations.byState?.slice(0, Math.ceil(locations.byState.length / 2)).map((location) => ( +
+
+ {location.state} + + {location.country} + +
+
+ + {location.count.toLocaleString()} + + + {location.percentage.toFixed(1)}% + +
+
+ ))} +
+ + {/* Right column */} +
+
+ Additional States + Orders +
+ {locations.byState?.slice(Math.ceil(locations.byState.length / 2)).map((location) => ( +
+
+ {location.state} + + {location.country} + +
+
+ + {location.count.toLocaleString()} + + + {location.percentage.toFixed(1)}% + +
+
+ ))} +
+
+
+ + {/* Summary footer */} +
+ + Showing all {locations.byState?.length || 0} states across {locations.byCountry?.length || 0} countries + + + Total Orders: {shippedCount.toLocaleString()} + +
@@ -1299,7 +1376,7 @@ const StatCards = ({ } finally { setDetailDataLoading(prev => ({ ...prev, [metric]: false })); } - }, [timeRange, startDate, endDate, shouldUseLast30Days, setCacheData, getCacheData]); + }, [timeRange, startDate, endDate]); // Corrected preloadDetailData function const preloadDetailData = useCallback(() => { const metrics = [