Minieventfeed tweaks and saleschart skeletons
This commit is contained in:
@@ -239,7 +239,7 @@ const EventCard = ({ event }) => {
|
|||||||
|
|
||||||
{event.metric_id === METRIC_IDS.SHIPPED_ORDER && (
|
{event.metric_id === METRIC_IDS.SHIPPED_ORDER && (
|
||||||
<>
|
<>
|
||||||
<div className={`text-xl font-bold ${eventType.textColor}`}>
|
<div className={`text-xl truncate font-bold ${eventType.textColor}`}>
|
||||||
{details.ShippingName}
|
{details.ShippingName}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center justify-between mt-1">
|
<div className="flex items-center justify-between mt-1">
|
||||||
@@ -252,7 +252,7 @@ const EventCard = ({ event }) => {
|
|||||||
|
|
||||||
{event.metric_id === METRIC_IDS.ACCOUNT_CREATED && (
|
{event.metric_id === METRIC_IDS.ACCOUNT_CREATED && (
|
||||||
<>
|
<>
|
||||||
<div className={`text-xl font-bold ${eventType.textColor}`}>
|
<div className={`text-xl truncate font-bold ${eventType.textColor}`}>
|
||||||
{details.FirstName} {details.LastName}
|
{details.FirstName} {details.LastName}
|
||||||
</div>
|
</div>
|
||||||
<div className={`text-sm font-semibold ${eventType.textColor} opacity-80 truncate mt-1`}>
|
<div className={`text-sm font-semibold ${eventType.textColor} opacity-80 truncate mt-1`}>
|
||||||
@@ -263,7 +263,7 @@ const EventCard = ({ event }) => {
|
|||||||
|
|
||||||
{event.metric_id === METRIC_IDS.CANCELED_ORDER && (
|
{event.metric_id === METRIC_IDS.CANCELED_ORDER && (
|
||||||
<>
|
<>
|
||||||
<div className={`text-xl font-bold ${eventType.textColor}`}>
|
<div className={`text-xl truncate font-bold ${eventType.textColor}`}>
|
||||||
{details.ShippingName}
|
{details.ShippingName}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center justify-between mt-1">
|
<div className="flex items-center justify-between mt-1">
|
||||||
@@ -279,7 +279,7 @@ const EventCard = ({ event }) => {
|
|||||||
|
|
||||||
{event.metric_id === METRIC_IDS.PAYMENT_REFUNDED && (
|
{event.metric_id === METRIC_IDS.PAYMENT_REFUNDED && (
|
||||||
<>
|
<>
|
||||||
<div className={`text-xl font-bold ${eventType.textColor}`}>
|
<div className={`text-xl truncate font-bold ${eventType.textColor}`}>
|
||||||
{details.ShippingName}
|
{details.ShippingName}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center justify-between mt-1">
|
<div className="flex items-center justify-between mt-1">
|
||||||
@@ -295,7 +295,7 @@ const EventCard = ({ event }) => {
|
|||||||
|
|
||||||
{event.metric_id === METRIC_IDS.NEW_BLOG_POST && (
|
{event.metric_id === METRIC_IDS.NEW_BLOG_POST && (
|
||||||
<>
|
<>
|
||||||
<div className={`text-xl font-bold ${eventType.textColor}`}>
|
<div className={`text-lg truncate font-bold ${eventType.textColor}`}>
|
||||||
{details.title}
|
{details.title}
|
||||||
</div>
|
</div>
|
||||||
<div className={`text-sm font-semibold ${eventType.textColor} opacity-80 line-clamp-2 mt-1`}>
|
<div className={`text-sm font-semibold ${eventType.textColor} opacity-80 line-clamp-2 mt-1`}>
|
||||||
|
|||||||
@@ -134,6 +134,35 @@ const MiniStatCard = memo(({
|
|||||||
|
|
||||||
MiniStatCard.displayName = "MiniStatCard";
|
MiniStatCard.displayName = "MiniStatCard";
|
||||||
|
|
||||||
|
const SkeletonCard = ({ colorScheme = "emerald" }) => (
|
||||||
|
<Card className={`w-full h-[150px] bg-gradient-to-br from-slate-700 to-slate-600 backdrop-blur-sm`}>
|
||||||
|
<CardHeader className="flex flex-row items-center justify-between space-y-0 p-4 pb-2">
|
||||||
|
<CardTitle>
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Skeleton className={`h-4 w-24 bg-${colorScheme}-300/20`} />
|
||||||
|
</div>
|
||||||
|
</CardTitle>
|
||||||
|
<div className="relative p-2">
|
||||||
|
<div className={`absolute inset-0 rounded-full bg-${colorScheme}-300/20`} />
|
||||||
|
<div className="h-5 w-5 relative rounded-full bg-${colorScheme}-300/20" />
|
||||||
|
</div>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent className="p-4 pt-0">
|
||||||
|
<div className="space-y-4">
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Skeleton className={`h-8 w-32 bg-${colorScheme}-300/20`} />
|
||||||
|
<div className="flex justify-between items-center">
|
||||||
|
<div className="space-y-1">
|
||||||
|
<Skeleton className={`h-4 w-24 bg-${colorScheme}-300/20`} />
|
||||||
|
</div>
|
||||||
|
<Skeleton className={`h-6 w-16 bg-${colorScheme}-300/20 rounded-full`} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
|
||||||
const MiniSalesChart = ({ className = "" }) => {
|
const MiniSalesChart = ({ className = "" }) => {
|
||||||
const [data, setData] = useState([]);
|
const [data, setData] = useState([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
@@ -247,47 +276,8 @@ const MiniSalesChart = ({ className = "" }) => {
|
|||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
{/* Stat Cards */}
|
{/* Stat Cards */}
|
||||||
<div className="grid grid-cols-2 gap-2">
|
<div className="grid grid-cols-2 gap-2">
|
||||||
<Card className="h-[150px] bg-gradient-to-br from-rose-900 to-rose-800 backdrop-blur-sm">
|
<SkeletonCard colorScheme="emerald" />
|
||||||
<CardHeader className="flex flex-row items-center justify-between space-y-0 p-4 pb-2">
|
<SkeletonCard colorScheme="blue" />
|
||||||
<CardTitle className="text-rose-100 font-bold text-md">
|
|
||||||
<Skeleton className="h-4 w-24 bg-rose-700" />
|
|
||||||
</CardTitle>
|
|
||||||
<div className="relative p-2">
|
|
||||||
<div className="absolute inset-0 rounded-full bg-rose-300" />
|
|
||||||
<Skeleton className="h-5 w-5 bg-rose-700 relative rounded-full" />
|
|
||||||
</div>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent className="p-4 pt-0">
|
|
||||||
<div className="space-y-2">
|
|
||||||
<Skeleton className="h-8 w-20 bg-rose-700" />
|
|
||||||
<div className="flex justify-between items-center">
|
|
||||||
<Skeleton className="h-4 w-24 bg-rose-700" />
|
|
||||||
<Skeleton className="h-4 w-12 bg-rose-700 rounded-full" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
<Card className="h-[150px] bg-gradient-to-br from-indigo-900 to-indigo-800 backdrop-blur-sm">
|
|
||||||
<CardHeader className="flex flex-row items-center justify-between space-y-0 p-4 pb-2">
|
|
||||||
<CardTitle className="text-indigo-100 font-bold text-md">
|
|
||||||
<Skeleton className="h-4 w-24 bg-indigo-700" />
|
|
||||||
</CardTitle>
|
|
||||||
<div className="relative p-2">
|
|
||||||
<div className="absolute inset-0 rounded-full bg-indigo-300" />
|
|
||||||
<Skeleton className="h-5 w-5 bg-indigo-700 relative rounded-full" />
|
|
||||||
</div>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent className="p-4 pt-0">
|
|
||||||
<div className="space-y-2">
|
|
||||||
<Skeleton className="h-8 w-20 bg-indigo-700" />
|
|
||||||
<div className="flex justify-between items-center">
|
|
||||||
<Skeleton className="h-4 w-24 bg-indigo-700" />
|
|
||||||
<Skeleton className="h-4 w-12 bg-indigo-700 rounded-full" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Chart Card */}
|
{/* Chart Card */}
|
||||||
@@ -304,129 +294,175 @@ const MiniSalesChart = ({ className = "" }) => {
|
|||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
{/* Stat Cards */}
|
{/* Stat Cards */}
|
||||||
<div className="grid grid-cols-2 gap-2">
|
<div className="grid grid-cols-2 gap-2">
|
||||||
<MiniStatCard
|
{loading ? (
|
||||||
title="30 Days Revenue"
|
<>
|
||||||
value={formatCurrency(summaryStats.totalRevenue, false)}
|
<SkeletonCard colorScheme="emerald" />
|
||||||
previousValue={formatCurrency(summaryStats.prevRevenue, false)}
|
<SkeletonCard colorScheme="blue" />
|
||||||
trend={summaryStats.growth.revenue >= 0 ? "up" : "down"}
|
</>
|
||||||
trendValue={`${Math.abs(Math.round(summaryStats.growth.revenue))}%`}
|
) : (
|
||||||
colorClass="text-emerald-300"
|
<>
|
||||||
titleClass="text-emerald-300 font-bold text-md"
|
<MiniStatCard
|
||||||
descriptionClass="text-emerald-300 text-md font-semibold"
|
title="30 Days Revenue"
|
||||||
icon={PiggyBank}
|
value={formatCurrency(summaryStats.totalRevenue, false)}
|
||||||
iconColor="text-emerald-900"
|
previousValue={formatCurrency(summaryStats.prevRevenue, false)}
|
||||||
iconBackground="bg-emerald-300"
|
trend={summaryStats.growth.revenue >= 0 ? "up" : "down"}
|
||||||
onClick={() => toggleMetric('revenue')}
|
trendValue={`${Math.abs(Math.round(summaryStats.growth.revenue))}%`}
|
||||||
active={visibleMetrics.revenue}
|
colorClass="text-emerald-300"
|
||||||
/>
|
titleClass="text-emerald-300 font-bold text-md"
|
||||||
<MiniStatCard
|
descriptionClass="text-emerald-300 text-md font-semibold"
|
||||||
title="30 Days Orders"
|
icon={PiggyBank}
|
||||||
value={summaryStats.totalOrders.toLocaleString()}
|
iconColor="text-emerald-900"
|
||||||
previousValue={summaryStats.prevOrders.toLocaleString()}
|
iconBackground="bg-emerald-300"
|
||||||
trend={summaryStats.growth.orders >= 0 ? "up" : "down"}
|
onClick={() => toggleMetric('revenue')}
|
||||||
trendValue={`${Math.abs(Math.round(summaryStats.growth.orders))}%`}
|
active={visibleMetrics.revenue}
|
||||||
colorClass="text-blue-300"
|
/>
|
||||||
titleClass="text-blue-300 font-bold text-md"
|
<MiniStatCard
|
||||||
descriptionClass="text-blue-300 text-md font-semibold"
|
title="30 Days Orders"
|
||||||
icon={Truck}
|
value={summaryStats.totalOrders.toLocaleString()}
|
||||||
iconColor="text-blue-900"
|
previousValue={summaryStats.prevOrders.toLocaleString()}
|
||||||
iconBackground="bg-blue-300"
|
trend={summaryStats.growth.orders >= 0 ? "up" : "down"}
|
||||||
onClick={() => toggleMetric('orders')}
|
trendValue={`${Math.abs(Math.round(summaryStats.growth.orders))}%`}
|
||||||
active={visibleMetrics.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}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Chart Card */}
|
{/* Chart Card */}
|
||||||
<Card className="bg-gradient-to-br from-slate-700 to-slate-600 backdrop-blur-sm">
|
<Card className="bg-gradient-to-br from-slate-700 to-slate-600 backdrop-blur-sm">
|
||||||
<CardContent className="p-4">
|
<CardContent className="p-4">
|
||||||
<div className="h-[216px]">
|
<div className="h-[216px]">
|
||||||
<ResponsiveContainer width="100%" height="100%">
|
{loading ? (
|
||||||
<LineChart
|
<div className="h-full w-full relative">
|
||||||
data={data}
|
{/* Grid lines */}
|
||||||
margin={{ top: 0, right: -30, left: -5, bottom: -10 }}
|
{[...Array(5)].map((_, i) => (
|
||||||
>
|
<div
|
||||||
<CartesianGrid strokeDasharray="3 3" className="stroke-stone-700" />
|
key={i}
|
||||||
<XAxis
|
className="absolute w-full h-px bg-slate-600"
|
||||||
dataKey="timestamp"
|
style={{ top: `${(i + 1) * 20}%` }}
|
||||||
tickFormatter={formatXAxis}
|
/>
|
||||||
className="text-xs"
|
))}
|
||||||
tick={{ fill: "#f5f5f4" }}
|
{/* Y-axis labels */}
|
||||||
/>
|
<div className="absolute left-0 top-0 bottom-0 w-8 flex flex-col justify-between py-4">
|
||||||
{visibleMetrics.revenue && (
|
{[...Array(5)].map((_, i) => (
|
||||||
<YAxis
|
<Skeleton key={i} className="h-3 w-6 bg-slate-600 rounded-sm" />
|
||||||
yAxisId="revenue"
|
))}
|
||||||
tickFormatter={(value) => formatCurrency(value, false)}
|
</div>
|
||||||
|
{/* X-axis labels */}
|
||||||
|
<div className="absolute left-8 right-4 bottom-0 flex justify-between">
|
||||||
|
{[...Array(6)].map((_, i) => (
|
||||||
|
<Skeleton key={i} className="h-3 w-8 bg-slate-600 rounded-sm" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
{/* Chart lines */}
|
||||||
|
<div className="absolute inset-x-8 bottom-6 top-4">
|
||||||
|
<div className="h-full w-full relative">
|
||||||
|
<div
|
||||||
|
className="absolute inset-0 bg-slate-600 rounded-sm"
|
||||||
|
style={{
|
||||||
|
opacity: 0.5,
|
||||||
|
clipPath: "polygon(0 50%, 100% 20%, 100% 100%, 0 100%)",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<ResponsiveContainer width="100%" height="100%">
|
||||||
|
<LineChart
|
||||||
|
data={data}
|
||||||
|
margin={{ top: 0, right: -30, left: -5, bottom: -10 }}
|
||||||
|
>
|
||||||
|
<CartesianGrid strokeDasharray="3 3" className="stroke-stone-700" />
|
||||||
|
<XAxis
|
||||||
|
dataKey="timestamp"
|
||||||
|
tickFormatter={formatXAxis}
|
||||||
className="text-xs"
|
className="text-xs"
|
||||||
tick={{ fill: "#f5f5f4" }}
|
tick={{ fill: "#f5f5f4" }}
|
||||||
/>
|
/>
|
||||||
)}
|
{visibleMetrics.revenue && (
|
||||||
{visibleMetrics.orders && (
|
<YAxis
|
||||||
<YAxis
|
yAxisId="revenue"
|
||||||
yAxisId="orders"
|
tickFormatter={(value) => formatCurrency(value, false)}
|
||||||
orientation="right"
|
className="text-xs"
|
||||||
className="text-xs"
|
tick={{ fill: "#f5f5f4" }}
|
||||||
tick={{ fill: "#f5f5f4" }}
|
/>
|
||||||
|
)}
|
||||||
|
{visibleMetrics.orders && (
|
||||||
|
<YAxis
|
||||||
|
yAxisId="orders"
|
||||||
|
orientation="right"
|
||||||
|
className="text-xs"
|
||||||
|
tick={{ fill: "#f5f5f4" }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<Tooltip
|
||||||
|
content={({ active, payload }) => {
|
||||||
|
if (active && payload && payload.length) {
|
||||||
|
const timestamp = new Date(payload[0].payload.timestamp);
|
||||||
|
return (
|
||||||
|
<Card className="p-2 shadow-lg bg-stone-800 border-none">
|
||||||
|
<CardContent className="p-0 space-y-1">
|
||||||
|
<p className="font-medium text-sm text-stone-100 border-b border-stone-700 pb-1 mb-1">
|
||||||
|
{timestamp.toLocaleDateString([], {
|
||||||
|
weekday: "short",
|
||||||
|
month: "short",
|
||||||
|
day: "numeric"
|
||||||
|
})}
|
||||||
|
</p>
|
||||||
|
{payload
|
||||||
|
.filter(entry => visibleMetrics[entry.dataKey])
|
||||||
|
.map((entry, index) => (
|
||||||
|
<div key={index} className="flex justify-between items-center text-sm">
|
||||||
|
<span className="text-stone-200">
|
||||||
|
{entry.name}:
|
||||||
|
</span>
|
||||||
|
<span className="font-medium ml-4 text-stone-100">
|
||||||
|
{entry.dataKey === 'revenue'
|
||||||
|
? formatCurrency(entry.value)
|
||||||
|
: entry.value.toLocaleString()}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
{visibleMetrics.revenue && (
|
||||||
<Tooltip
|
<Line
|
||||||
content={({ active, payload }) => {
|
yAxisId="revenue"
|
||||||
if (active && payload && payload.length) {
|
type="monotone"
|
||||||
const timestamp = new Date(payload[0].payload.timestamp);
|
dataKey="revenue"
|
||||||
return (
|
name="Revenue"
|
||||||
<Card className="p-2 shadow-lg bg-stone-800 border-none">
|
stroke="#10b981"
|
||||||
<CardContent className="p-0 space-y-1">
|
strokeWidth={2}
|
||||||
<p className="font-medium text-sm text-stone-100 border-b border-stone-700 pb-1 mb-1">
|
dot={false}
|
||||||
{timestamp.toLocaleDateString([], {
|
/>
|
||||||
weekday: "short",
|
)}
|
||||||
month: "short",
|
{visibleMetrics.orders && (
|
||||||
day: "numeric"
|
<Line
|
||||||
})}
|
yAxisId="orders"
|
||||||
</p>
|
type="monotone"
|
||||||
{payload
|
dataKey="orders"
|
||||||
.filter(entry => visibleMetrics[entry.dataKey])
|
name="Orders"
|
||||||
.map((entry, index) => (
|
stroke="#3b82f6"
|
||||||
<div key={index} className="flex justify-between items-center text-sm">
|
strokeWidth={2}
|
||||||
<span className="text-stone-200">
|
dot={false}
|
||||||
{entry.name}:
|
/>
|
||||||
</span>
|
)}
|
||||||
<span className="font-medium ml-4 text-stone-100">
|
</LineChart>
|
||||||
{entry.dataKey === 'revenue'
|
</ResponsiveContainer>
|
||||||
? formatCurrency(entry.value)
|
)}
|
||||||
: entry.value.toLocaleString()}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{visibleMetrics.revenue && (
|
|
||||||
<Line
|
|
||||||
yAxisId="revenue"
|
|
||||||
type="monotone"
|
|
||||||
dataKey="revenue"
|
|
||||||
name="Revenue"
|
|
||||||
stroke="#10b981"
|
|
||||||
strokeWidth={2}
|
|
||||||
dot={false}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{visibleMetrics.orders && (
|
|
||||||
<Line
|
|
||||||
yAxisId="orders"
|
|
||||||
type="monotone"
|
|
||||||
dataKey="orders"
|
|
||||||
name="Orders"
|
|
||||||
stroke="#3b82f6"
|
|
||||||
strokeWidth={2}
|
|
||||||
dot={false}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</LineChart>
|
|
||||||
</ResponsiveContainer>
|
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
Reference in New Issue
Block a user