Fix statcards layouts + related app changes
This commit is contained in:
@@ -89,25 +89,25 @@ const DashboardLayout = () => {
|
|||||||
<Navigation />
|
<Navigation />
|
||||||
<div className="p-4 space-y-4">
|
<div className="p-4 space-y-4">
|
||||||
<div className="grid grid-cols-1 xl:grid-cols-6 gap-4">
|
<div className="grid grid-cols-1 xl:grid-cols-6 gap-4">
|
||||||
<div className="2xl:col-span-4 col-span-6">
|
<div className="xl:col-span-4 col-span-6">
|
||||||
<div className="space-y-4 h-full w-full">
|
<div className="space-y-4 h-full w-full">
|
||||||
<StatCards />
|
<StatCards />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="xl:col-span-2 col-span-6 h-[530px] 2xl:block hidden">
|
<div className="xl:col-span-2 col-span-6 h-[500px] xl:h-[643px] 2xl:h-[510px] lg:hidden xl:block">
|
||||||
<div className="h-full">
|
<div className="h-full">
|
||||||
<div className="h-full"><EventFeed /></div>
|
<div className="h-full"><EventFeed /></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-12 gap-4">
|
<div className="grid grid-cols-12 gap-4">
|
||||||
<div className="col-span-12 lg:col-span-6 xl:col-span-6 2xl:hidden h-[740px]">
|
<div className="hidden lg:col-span-6 lg:block xl:hidden h-[740px]">
|
||||||
<EventFeed />
|
<EventFeed />
|
||||||
</div>
|
</div>
|
||||||
<div className="col-span-12 lg:col-span-6 xl:col-span-6 2xl:col-span-4 h-[740px]">
|
<div className="col-span-12 lg:col-span-6 xl:col-span-4 h-[740px]">
|
||||||
<ProductGrid />
|
<ProductGrid />
|
||||||
</div>
|
</div>
|
||||||
<div className="col-span-12 2xl:col-span-8 h-full w-full flex">
|
<div className="col-span-12 xl:col-span-8 h-full w-full flex">
|
||||||
<SalesChart className="w-full h-full"/>
|
<SalesChart className="w-full h-full"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ import {
|
|||||||
import { Skeleton } from "@/components/ui/skeleton";
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Progress } from "@/components/ui/progress";
|
||||||
|
|
||||||
const formatCurrency = (value, minimumFractionDigits = 0) => {
|
const formatCurrency = (value, minimumFractionDigits = 0) => {
|
||||||
if (!value || isNaN(value)) return "$0";
|
if (!value || isNaN(value)) return "$0";
|
||||||
@@ -939,7 +940,8 @@ const StatCard = ({
|
|||||||
onClick,
|
onClick,
|
||||||
info,
|
info,
|
||||||
onDetailsClick,
|
onDetailsClick,
|
||||||
isLoading = false
|
isLoading = false,
|
||||||
|
progress
|
||||||
}) => (
|
}) => (
|
||||||
<Card
|
<Card
|
||||||
className={`${className} ${onClick || onDetailsClick ? "cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors" : ""}`}
|
className={`${className} ${onClick || onDetailsClick ? "cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors" : ""}`}
|
||||||
@@ -966,7 +968,8 @@ const StatCard = ({
|
|||||||
<Skeleton className="h-4 w-24" />
|
<Skeleton className="h-4 w-24" />
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<div className="space-y-2">
|
||||||
|
<div>
|
||||||
<div className={`text-2xl font-bold ${colorClass}`}>
|
<div className={`text-2xl font-bold ${colorClass}`}>
|
||||||
{valuePrefix}{value}{valueSuffix}
|
{valuePrefix}{value}{valueSuffix}
|
||||||
</div>
|
</div>
|
||||||
@@ -981,7 +984,9 @@ const StatCard = ({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</>
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
@@ -1229,6 +1234,7 @@ const StatCards = ({
|
|||||||
setDetailDataLoading(prev => ({ ...prev, [metric]: false }));
|
setDetailDataLoading(prev => ({ ...prev, [metric]: false }));
|
||||||
}
|
}
|
||||||
}, [timeRange, startDate, endDate, shouldUseLast30Days, setCacheData, getCacheData]);
|
}, [timeRange, startDate, endDate, shouldUseLast30Days, setCacheData, getCacheData]);
|
||||||
|
|
||||||
// Corrected preloadDetailData function
|
// Corrected preloadDetailData function
|
||||||
const preloadDetailData = useCallback(() => {
|
const preloadDetailData = useCallback(() => {
|
||||||
const metrics = [
|
const metrics = [
|
||||||
@@ -1595,15 +1601,16 @@ const StatCards = ({
|
|||||||
</div>
|
</div>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="p-6 pt-0">
|
<CardContent className="p-6 pt-0">
|
||||||
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
|
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-3 2xl:grid-cols-4 gap-2 md:gap-3">
|
||||||
<StatCard
|
<StatCard
|
||||||
title="Total Revenue"
|
title="Total Revenue"
|
||||||
value={formatCurrency(stats?.revenue || 0)}
|
value={formatCurrency(stats?.revenue || 0)}
|
||||||
description={
|
description={
|
||||||
stats?.periodProgress < 100
|
stats?.periodProgress < 100
|
||||||
? `${stats.periodProgress.toFixed(1)}% complete • Projected: ${formatCurrency(stats.projectedRevenue)}`
|
? <span><span className="md:hidden">Proj: </span><span className="hidden md:inline">Projected: </span>{formatCurrency(stats.projectedRevenue)}</span>
|
||||||
: `Previous: ${formatCurrency(stats.prevPeriodRevenue)}`
|
: `Previous: ${formatCurrency(stats.prevPeriodRevenue)}`
|
||||||
}
|
}
|
||||||
|
progress={stats?.periodProgress < 100 ? stats.periodProgress : undefined}
|
||||||
trend={revenueTrend?.trend}
|
trend={revenueTrend?.trend}
|
||||||
trendValue={revenueTrend?.value ? formatPercentage(revenueTrend.value) : null}
|
trendValue={revenueTrend?.value ? formatPercentage(revenueTrend.value) : null}
|
||||||
colorClass="text-green-600 dark:text-green-400"
|
colorClass="text-green-600 dark:text-green-400"
|
||||||
|
|||||||
Reference in New Issue
Block a user