From c9df4b5fe1362eab0818798264aa2f0303ad9d0d Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 2 Jan 2025 16:58:28 -0500 Subject: [PATCH] Fix time formatting bug and update skeletons to match --- .../dashboard/MiniRealtimeAnalytics.jsx | 95 +++++-- .../components/dashboard/MiniSalesChart.jsx | 268 +++++++++++------- .../components/dashboard/MiniStatCards.jsx | 94 +++++- 3 files changed, 321 insertions(+), 136 deletions(-) diff --git a/dashboard/src/components/dashboard/MiniRealtimeAnalytics.jsx b/dashboard/src/components/dashboard/MiniRealtimeAnalytics.jsx index 0b0b9b4..98cbad3 100644 --- a/dashboard/src/components/dashboard/MiniRealtimeAnalytics.jsx +++ b/dashboard/src/components/dashboard/MiniRealtimeAnalytics.jsx @@ -78,24 +78,81 @@ const MiniRealtimeAnalytics = () => { if (loading && !basicData) { return ( - - -
- - Real-Time Analytics - - -
-
+
+
+ + + + + +
+
+ +
+ + +
+ + +
+
+ + + + + + +
+
+ +
+ + +
+ + +
+
+ +
- -
- - -
- -
-
+ + +
+ {/* Grid lines */} + {[...Array(5)].map((_, i) => ( +
+ ))} + {/* Y-axis labels */} +
+ {[...Array(5)].map((_, i) => ( + + ))} +
+ {/* X-axis labels */} +
+ {[...Array(6)].map((_, i) => ( + + ))} +
+ {/* Bars */} +
+ {[...Array(24)].map((_, i) => ( +
+ ))} +
+
+ + +
); } @@ -160,13 +217,11 @@ const MiniRealtimeAnalytics = () => { { if (active && payload && payload.length) { - const timestamp = payload[0].payload.timestamp; - const formattedTime = timestamp ? format(new Date(timestamp), "h:mm a") : "N/A"; return (

- {formattedTime} + {payload[0].payload.timestamp}

diff --git a/dashboard/src/components/dashboard/MiniSalesChart.jsx b/dashboard/src/components/dashboard/MiniSalesChart.jsx index acccd8c..3aa51b3 100644 --- a/dashboard/src/components/dashboard/MiniSalesChart.jsx +++ b/dashboard/src/components/dashboard/MiniSalesChart.jsx @@ -23,34 +23,45 @@ import { AlertCircle, TrendingUp, DollarSign, ShoppingCart, Truck, PiggyBank, Ar import { formatCurrency, CustomTooltip, processData, StatCard } from "./SalesChart.jsx"; const SkeletonChart = () => ( -
+
+ {/* Grid lines */} {[...Array(5)].map((_, i) => (
))} + {/* Y-axis labels */}
{[...Array(5)].map((_, i) => ( - + ))}
+ {/* X-axis labels */}
{[...Array(6)].map((_, i) => ( - + ))}
+ {/* Chart lines */}
+
@@ -231,6 +242,64 @@ const MiniSalesChart = ({ className = "" }) => { ); } + if (loading && !data) { + return ( +
+ {/* Stat Cards */} +
+ + + + + +
+
+ +
+ + +
+ +
+ + +
+
+
+ + + + + + + +
+
+ +
+ + +
+ +
+ + +
+
+
+ +
+ + {/* Chart Card */} + + + + + +
+ ); + } + return (
{/* Stat Cards */} @@ -271,112 +340,97 @@ const MiniSalesChart = ({ className = "" }) => { {/* Chart Card */} - {loading ? ( - - - - ) : !data.length ? ( - -
-
- -
No sales data available
-
-
-
- ) : ( - -
- - - - +
+ + + + + {visibleMetrics.revenue && ( + formatCurrency(value, false)} className="text-xs" tick={{ fill: "#f5f5f4" }} /> - {visibleMetrics.revenue && ( - formatCurrency(value, false)} - className="text-xs" - tick={{ fill: "#f5f5f4" }} - /> - )} - {visibleMetrics.orders && ( - - )} - { - if (active && payload && payload.length) { - const timestamp = new Date(payload[0].payload.timestamp); - return ( - - -

- {timestamp.toLocaleDateString([], { - weekday: "short", - month: "short", - day: "numeric" - })} -

- {payload - .filter(entry => visibleMetrics[entry.dataKey]) - .map((entry, index) => ( -
- - {entry.name}: - - - {entry.dataKey === 'revenue' - ? formatCurrency(entry.value) - : entry.value.toLocaleString()} - -
- ))} -
-
- ); - } - return null; - }} + )} + {visibleMetrics.orders && ( + - {visibleMetrics.revenue && ( - - )} - {visibleMetrics.orders && ( - - )} -
-
-
- - )} + )} + { + if (active && payload && payload.length) { + const timestamp = new Date(payload[0].payload.timestamp); + return ( + + +

+ {timestamp.toLocaleDateString([], { + weekday: "short", + month: "short", + day: "numeric" + })} +

+ {payload + .filter(entry => visibleMetrics[entry.dataKey]) + .map((entry, index) => ( +
+ + {entry.name}: + + + {entry.dataKey === 'revenue' + ? formatCurrency(entry.value) + : entry.value.toLocaleString()} + +
+ ))} +
+
+ ); + } + return null; + }} + /> + {visibleMetrics.revenue && ( + + )} + {visibleMetrics.orders && ( + + )} +
+
+
+
); diff --git a/dashboard/src/components/dashboard/MiniStatCards.jsx b/dashboard/src/components/dashboard/MiniStatCards.jsx index aaac8e4..3bbc7f2 100644 --- a/dashboard/src/components/dashboard/MiniStatCards.jsx +++ b/dashboard/src/components/dashboard/MiniStatCards.jsx @@ -350,15 +350,91 @@ const MiniStatCards = ({ if (loading && !stats) { return ( - - -
- {[...Array(4)].map((_, i) => ( - - ))} -
-
-
+
+ + + + + +
+
+ +
+ + +
+ +
+ + +
+
+
+ + + + + + + +
+
+ +
+ + +
+ +
+ + +
+
+
+ + + + + + + +
+
+ +
+ + +
+ +
+ + +
+
+
+ + + + + + + +
+
+ +
+ + +
+ +
+ + +
+
+
+ +
); }