diff --git a/dashboard/src/components/dashboard/StatCards.jsx b/dashboard/src/components/dashboard/StatCards.jsx index 631ea24..d682f7a 100644 --- a/dashboard/src/components/dashboard/StatCards.jsx +++ b/dashboard/src/components/dashboard/StatCards.jsx @@ -159,7 +159,7 @@ const DetailDialog = ({ children }) => ( - + {title} @@ -368,7 +368,7 @@ const BrandsCategoriesDetails = ({ data }) => { return (
-
+

Brands ({stats?.brands?.total || 0}) @@ -382,7 +382,7 @@ const BrandsCategoriesDetails = ({ data }) => { Revenue - + {brandsList.map((brand) => ( {brand.name} @@ -395,7 +395,7 @@ const BrandsCategoriesDetails = ({ data }) => {

-
+

Categories ({stats?.categories?.total || 0}) @@ -409,7 +409,7 @@ const BrandsCategoriesDetails = ({ data }) => { Revenue - + {categoriesList.map((category) => ( {category.name} @@ -432,232 +432,91 @@ const ShippingDetails = ({ data }) => { const locations = data[0]?.shipping?.locations || {}; const methodStats = data[0]?.shipping?.methodStats || []; - // Custom colors for the pie chart - const COLORS = [ - 'hsl(171.2 77.2% 53.3%)', - 'hsl(200 95% 50%)', - 'hsl(280 95% 60%)', - 'hsl(340 95% 60%)', - 'hsl(40 95% 50%)', - 'hsl(120 95% 45%)', - 'hsl(240 95% 60%)', - 'hsl(30 95% 50%)', - ]; - - // Custom label renderer for pie chart - const renderCustomizedLabel = ({ cx, cy, midAngle, innerRadius, outerRadius, percent, index, name }) => { - const RADIAN = Math.PI / 180; - // Extend the radius for label placement - const radius = outerRadius * 1.2; - - // Calculate position - const x = cx + radius * Math.cos(-midAngle * RADIAN); - const y = cy + radius * Math.sin(-midAngle * RADIAN); - - // Only show label if percentage is greater than 3% - if (percent < 0.03) return null; - - return ( - cx ? 'start' : 'end'} - dominantBaseline="central" - className="text-xs font-medium" - > - {name} ({(percent * 100).toFixed(1)}%) - - ); - }; - - // Custom legend renderer - const renderLegend = (props) => { - const { payload } = props; - - return ( -
- {payload.map((entry, index) => ( -
-
- - {entry.value}: {((entry.payload.value / shippedCount) * 100).toFixed(1)}% - -
- ))} -
- ); - }; - return (
-
- - -
- + {/* Shipping Methods */}
-

Shipping Methods Distribution

-
- - - - {methodStats.map((entry, index) => ( - - ))} - - [ - `${value.toLocaleString()} orders (${((value / shippedCount) * 100).toFixed(1)}%)`, - name - ]} - contentStyle={{ - backgroundColor: 'hsl(var(--background))', - border: '1px solid hsl(var(--border))', - borderRadius: '0.5rem', - padding: '0.5rem' - }} - /> - - - +

+ + Shipping Methods +

+
+ + + + Method + Orders + % of Total + + + + {methodStats.map((method) => ( + + {method.name} + {method.value.toLocaleString()} + + {((method.value / shippedCount) * 100).toFixed(1)}% + + + ))} + +
+ {/* Countries */}
-

Shipping Locations

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

{country.country}

-

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

-
-
-
{country.count.toLocaleString()}
-
- {country.percentage.toFixed(1)}% -
-
-
-
-
-
- - ))} -
+

+ + Countries ({locations.byCountry?.length || 0}) +

+
+ + + + Country + Orders + % of Total + + + + {locations.byCountry?.map((country) => ( + + {country.country} + {country.count.toLocaleString()} + {country.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()} - -
+ {/* States */} +
+

+ + States/Regions ({locations.byState?.length || 0}) +

+
+ + + + State + Orders + % of Total + + + + {locations.byState?.map((state) => ( + + {state.state} + {state.count.toLocaleString()} + {state.percentage.toFixed(1)}% + + ))} + +
@@ -1553,7 +1412,7 @@ const StatCards = ({ case 'brands_categories': return ; case 'shipping': - return ; + return ; case 'peak_hour': if (!['today', 'yesterday'].includes(timeRange)) { return
Peak hour details are only available for single-day periods.
;