From d636c29f698615d7794227edea78f6a6015b7e79 Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 4 Jan 2025 00:07:25 -0500 Subject: [PATCH] Minieventfeed tweaks and saleschart skeletons --- .../components/dashboard/MiniEventFeed.jsx | 10 +- .../components/dashboard/MiniSalesChart.jsx | 344 ++++++++++-------- 2 files changed, 195 insertions(+), 159 deletions(-) diff --git a/dashboard/src/components/dashboard/MiniEventFeed.jsx b/dashboard/src/components/dashboard/MiniEventFeed.jsx index 62f4fad..4c3f1ad 100644 --- a/dashboard/src/components/dashboard/MiniEventFeed.jsx +++ b/dashboard/src/components/dashboard/MiniEventFeed.jsx @@ -239,7 +239,7 @@ const EventCard = ({ event }) => { {event.metric_id === METRIC_IDS.SHIPPED_ORDER && ( <> -
+
{details.ShippingName}
@@ -252,7 +252,7 @@ const EventCard = ({ event }) => { {event.metric_id === METRIC_IDS.ACCOUNT_CREATED && ( <> -
+
{details.FirstName} {details.LastName}
@@ -263,7 +263,7 @@ const EventCard = ({ event }) => { {event.metric_id === METRIC_IDS.CANCELED_ORDER && ( <> -
+
{details.ShippingName}
@@ -279,7 +279,7 @@ const EventCard = ({ event }) => { {event.metric_id === METRIC_IDS.PAYMENT_REFUNDED && ( <> -
+
{details.ShippingName}
@@ -295,7 +295,7 @@ const EventCard = ({ event }) => { {event.metric_id === METRIC_IDS.NEW_BLOG_POST && ( <> -
+
{details.title}
diff --git a/dashboard/src/components/dashboard/MiniSalesChart.jsx b/dashboard/src/components/dashboard/MiniSalesChart.jsx index e1b3eae..79d9b9f 100644 --- a/dashboard/src/components/dashboard/MiniSalesChart.jsx +++ b/dashboard/src/components/dashboard/MiniSalesChart.jsx @@ -134,6 +134,35 @@ const MiniStatCard = memo(({ MiniStatCard.displayName = "MiniStatCard"; +const SkeletonCard = ({ colorScheme = "emerald" }) => ( + + + +
+ +
+
+
+
+
+
+ + +
+
+ +
+
+ +
+ +
+
+
+
+ +); + const MiniSalesChart = ({ className = "" }) => { const [data, setData] = useState([]); const [loading, setLoading] = useState(true); @@ -247,47 +276,8 @@ const MiniSalesChart = ({ className = "" }) => {
{/* Stat Cards */}
- - - - - -
-
- -
- - -
- -
- - -
-
-
- - - - - - - -
-
- -
- - -
- -
- - -
-
-
- + +
{/* Chart Card */} @@ -304,129 +294,175 @@ const MiniSalesChart = ({ className = "" }) => {
{/* Stat Cards */}
- = 0 ? "up" : "down"} - trendValue={`${Math.abs(Math.round(summaryStats.growth.revenue))}%`} - colorClass="text-emerald-300" - titleClass="text-emerald-300 font-bold text-md" - descriptionClass="text-emerald-300 text-md font-semibold" - icon={PiggyBank} - iconColor="text-emerald-900" - iconBackground="bg-emerald-300" - onClick={() => toggleMetric('revenue')} - active={visibleMetrics.revenue} - /> - = 0 ? "up" : "down"} - trendValue={`${Math.abs(Math.round(summaryStats.growth.orders))}%`} - colorClass="text-blue-300" - titleClass="text-blue-300 font-bold text-md" - descriptionClass="text-blue-300 text-md font-semibold" - icon={Truck} - iconColor="text-blue-900" - iconBackground="bg-blue-300" - onClick={() => toggleMetric('orders')} - active={visibleMetrics.orders} - /> + {loading ? ( + <> + + + + ) : ( + <> + = 0 ? "up" : "down"} + trendValue={`${Math.abs(Math.round(summaryStats.growth.revenue))}%`} + colorClass="text-emerald-300" + titleClass="text-emerald-300 font-bold text-md" + descriptionClass="text-emerald-300 text-md font-semibold" + icon={PiggyBank} + iconColor="text-emerald-900" + iconBackground="bg-emerald-300" + onClick={() => toggleMetric('revenue')} + active={visibleMetrics.revenue} + /> + = 0 ? "up" : "down"} + trendValue={`${Math.abs(Math.round(summaryStats.growth.orders))}%`} + colorClass="text-blue-300" + titleClass="text-blue-300 font-bold text-md" + descriptionClass="text-blue-300 text-md font-semibold" + icon={Truck} + iconColor="text-blue-900" + iconBackground="bg-blue-300" + onClick={() => toggleMetric('orders')} + active={visibleMetrics.orders} + /> + + )}
{/* Chart Card */}
- - - - - {visibleMetrics.revenue && ( - formatCurrency(value, false)} + {loading ? ( +
+ {/* Grid lines */} + {[...Array(5)].map((_, i) => ( +
+ ))} + {/* Y-axis labels */} +
+ {[...Array(5)].map((_, i) => ( + + ))} +
+ {/* X-axis labels */} +
+ {[...Array(6)].map((_, i) => ( + + ))} +
+ {/* Chart lines */} +
+
+
+
+
+
+ ) : ( + + + + - )} - {visibleMetrics.orders && ( - 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; + }} /> - )} - { - 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 && ( - - )} -
-
+ {visibleMetrics.revenue && ( + + )} + {visibleMetrics.orders && ( + + )} + + + )}