Initial import of 1407 block sources under blocks/
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,225 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
Area,
|
||||
AreaChart,
|
||||
Bar,
|
||||
BarChart,
|
||||
CartesianGrid,
|
||||
XAxis,
|
||||
YAxis,
|
||||
} from "recharts";
|
||||
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import {
|
||||
type ChartConfig,
|
||||
ChartContainer,
|
||||
ChartTooltip,
|
||||
ChartTooltipContent,
|
||||
} from "@/components/ui/chart";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
interface ChartGroup1Props {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const monthLabel = (monthIndex: number) =>
|
||||
new Intl.DateTimeFormat("fa-IR", { month: "short" }).format(
|
||||
new Date(2025, monthIndex, 1),
|
||||
);
|
||||
|
||||
const currencyFormatter = new Intl.NumberFormat("fa-IR", {
|
||||
style: "currency",
|
||||
currency: "IRR",
|
||||
minimumFractionDigits: 0,
|
||||
maximumFractionDigits: 0,
|
||||
});
|
||||
|
||||
const compactCurrencyFormatter = new Intl.NumberFormat("fa-IR", {
|
||||
style: "currency",
|
||||
currency: "IRR",
|
||||
notation: "compact",
|
||||
minimumFractionDigits: 0,
|
||||
maximumFractionDigits: 1,
|
||||
});
|
||||
|
||||
const numberFormatter = new Intl.NumberFormat("fa-IR", {
|
||||
maximumFractionDigits: 0,
|
||||
});
|
||||
|
||||
const compactNumberFormatter = new Intl.NumberFormat("fa-IR", {
|
||||
notation: "compact",
|
||||
maximumFractionDigits: 1,
|
||||
});
|
||||
|
||||
const revenueData = [
|
||||
{ month: monthLabel(0), value: 18600 },
|
||||
{ month: monthLabel(1), value: 30500 },
|
||||
{ month: monthLabel(2), value: 23700 },
|
||||
{ month: monthLabel(3), value: 27300 },
|
||||
{ month: monthLabel(4), value: 20900 },
|
||||
{ month: monthLabel(5), value: 31400 },
|
||||
];
|
||||
|
||||
const ordersData = [
|
||||
{ month: monthLabel(0), value: 186 },
|
||||
{ month: monthLabel(1), value: 305 },
|
||||
{ month: monthLabel(2), value: 237 },
|
||||
{ month: monthLabel(3), value: 273 },
|
||||
{ month: monthLabel(4), value: 209 },
|
||||
{ month: monthLabel(5), value: 314 },
|
||||
];
|
||||
|
||||
const revenueConfig = {
|
||||
value: {
|
||||
label: "درآمد",
|
||||
color: "var(--chart-1)",
|
||||
},
|
||||
} satisfies ChartConfig;
|
||||
|
||||
const ordersConfig = {
|
||||
value: {
|
||||
label: "سفارشها",
|
||||
color: "var(--chart-2)",
|
||||
},
|
||||
} satisfies ChartConfig;
|
||||
|
||||
const ChartGroup1 = ({ className }: ChartGroup1Props) => {
|
||||
return (
|
||||
<section
|
||||
dir="rtl"
|
||||
lang="fa"
|
||||
className={cn("py-32 text-start", className)}
|
||||
>
|
||||
<div className="container grid gap-4 md:grid-cols-2">
|
||||
<Card className="text-start">
|
||||
<CardHeader>
|
||||
<CardTitle>درآمد</CardTitle>
|
||||
<CardDescription>روند درآمد ماهانه</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<ChartContainer config={revenueConfig} className="h-64 w-full">
|
||||
<AreaChart
|
||||
data={revenueData}
|
||||
margin={{ top: 10, right: 10, left: 0, bottom: 0 }}
|
||||
>
|
||||
<defs>
|
||||
<linearGradient
|
||||
id="revenueGradient1"
|
||||
x1="0"
|
||||
y1="0"
|
||||
x2="0"
|
||||
y2="1"
|
||||
>
|
||||
<stop
|
||||
offset="0%"
|
||||
stopColor="var(--color-value)"
|
||||
stopOpacity={0.3}
|
||||
/>
|
||||
<stop
|
||||
offset="100%"
|
||||
stopColor="var(--color-value)"
|
||||
stopOpacity={0}
|
||||
/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<CartesianGrid strokeDasharray="3 3" vertical={false} />
|
||||
<XAxis
|
||||
dataKey="month"
|
||||
axisLine={false}
|
||||
tickLine={false}
|
||||
tickMargin={8}
|
||||
fontSize={12}
|
||||
/>
|
||||
<YAxis
|
||||
axisLine={false}
|
||||
tickLine={false}
|
||||
tickMargin={8}
|
||||
fontSize={10}
|
||||
width={52}
|
||||
tickFormatter={(v) =>
|
||||
compactCurrencyFormatter.format(Number(v))
|
||||
}
|
||||
/>
|
||||
<ChartTooltip
|
||||
content={
|
||||
<ChartTooltipContent
|
||||
formatter={(value) =>
|
||||
currencyFormatter.format(Number(value))
|
||||
}
|
||||
/>
|
||||
}
|
||||
cursor={{ stroke: "var(--border)", strokeDasharray: "4 4" }}
|
||||
/>
|
||||
<Area
|
||||
type="monotone"
|
||||
dataKey="value"
|
||||
stroke="var(--color-value)"
|
||||
strokeWidth={2}
|
||||
fill="url(#revenueGradient1)"
|
||||
/>
|
||||
</AreaChart>
|
||||
</ChartContainer>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card className="text-start">
|
||||
<CardHeader>
|
||||
<CardTitle>سفارشها</CardTitle>
|
||||
<CardDescription>حجم سفارش ماهانه</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<ChartContainer config={ordersConfig} className="h-64 w-full">
|
||||
<BarChart
|
||||
data={ordersData}
|
||||
margin={{ top: 10, right: 10, left: 0, bottom: 0 }}
|
||||
>
|
||||
<CartesianGrid strokeDasharray="3 3" vertical={false} />
|
||||
<XAxis
|
||||
dataKey="month"
|
||||
axisLine={false}
|
||||
tickLine={false}
|
||||
tickMargin={8}
|
||||
fontSize={12}
|
||||
/>
|
||||
<YAxis
|
||||
axisLine={false}
|
||||
tickLine={false}
|
||||
tickMargin={8}
|
||||
fontSize={10}
|
||||
width={40}
|
||||
tickFormatter={(v) =>
|
||||
compactNumberFormatter.format(Number(v))
|
||||
}
|
||||
/>
|
||||
<ChartTooltip
|
||||
content={
|
||||
<ChartTooltipContent
|
||||
formatter={(value) =>
|
||||
numberFormatter.format(Number(value))
|
||||
}
|
||||
/>
|
||||
}
|
||||
cursor={{ fillOpacity: 0.05 }}
|
||||
/>
|
||||
<Bar
|
||||
dataKey="value"
|
||||
fill="var(--color-value)"
|
||||
radius={[4, 4, 0, 0]}
|
||||
/>
|
||||
</BarChart>
|
||||
</ChartContainer>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
};
|
||||
|
||||
export { ChartGroup1 };
|
||||
Reference in New Issue
Block a user