Skip to content

Commit 2f2250e

Browse files
committed
202502270811
1 parent b07fe64 commit 2f2250e

File tree

5 files changed

+1528
-549
lines changed

5 files changed

+1528
-549
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"react": "^19.0.0",
2525
"react-dom": "^19.0.0",
2626
"react-hook-form": "^7.54.2",
27+
"react-loading-skeleton": "^3.5.0",
2728
"react-router-dom": "^7.1.5",
2829
"react-simple-captcha": "^9.3.1",
2930
"recharts": "^2.15.1",

src/components/CustomSkeleton.jsx

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';
2+
3+
const CustomSkeleton = ({ linecount }) => {
4+
return (
5+
<SkeletonTheme baseColor="#efefef" highlightColor="#aaa">
6+
<p>
7+
<Skeleton count={linecount} />
8+
</p>
9+
</SkeletonTheme>
10+
);
11+
};
12+
13+
export { CustomSkeleton };
14+

src/components/SkeletonLoader.jsx

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
const SkeletonLoader = ({ className }) => {
3+
return (
4+
<div className={`bg-gray-200 m-1 animate-pulse ${className}`} />
5+
);
6+
};
7+
8+
export { SkeletonLoader };
9+

src/pages/Dashboard.jsx

+36-13
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
import { Card, CardContent } from "../components/card";
22
import { BarChart, Bar, XAxis, YAxis, Tooltip, ResponsiveContainer, LineChart, Line, AreaChart, CartesianGrid, Area } from "recharts";
33
import { Users, HandHeart, Filter, ArrowUpRight, DollarSign, Calendar } from "lucide-react";
4-
import { useState } from "react";
4+
import { useEffect, useState } from "react";
55
import { toAbsolouteUrl } from "../helpers/absolouteUrl";
6+
import { SkeletonLoader } from "../components/SkeletonLoader";
7+
import Skeleton from 'react-loading-skeleton'
8+
import 'react-loading-skeleton/dist/skeleton.css'
9+
import { CustomSkeleton } from "../components/CustomSkeleton";
610

711
const Dashboard = () => {
812
const [searchTerm, setSearchTerm] = useState("");
913
const [selectedMonth, setSelectedMonth] = useState("");
14+
const [loading, setLoading] = useState(true);
15+
16+
useEffect(() => {
17+
setTimeout(() => {
18+
setLoading(false); // پس از ۲ ثانیه داده‌ها لود می‌شوند
19+
}, 2000);
20+
}, []);
1021

1122
const donationData = [
1223
// { name: "تیر", amount: 15000, donors: 35 },
@@ -90,21 +101,33 @@ const Dashboard = () => {
90101
return (
91102
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-12 gap-4 p-5">
92103
<Card className="col-span-3 shadow">
93-
<CardContent className="flex items-center p-4">
94-
<HandHeart size={32} className="text-red-500 p-1" />
95-
<div className="ml-3">
96-
<h3 className="text-lg font-bold">کمک‌های مالی</h3>
97-
<p className="text-gray-600">مجموع: 45,000,000 تومان</p>
98-
</div>
99-
</CardContent>
104+
{loading ? (
105+
<CustomSkeleton linecount={3} />
106+
) : (
107+
<CardContent className="flex items-center p-4">
108+
{loading ? (<CustomSkeleton linecount={1} />) : (
109+
<HandHeart size={32} className="text-red-500 p-1" />)
110+
}
111+
<div className="ml-3">
112+
<h3 className="text-lg font-bold">کمک‌های مالی</h3>
113+
<p className="text-gray-600">مجموع: 45,000,000 تومان</p>
114+
</div>
115+
</CardContent>
116+
)}
100117
</Card>
101118

119+
120+
102121
<Card className="col-span-3 shadow bg-blend-normal">
103122
<CardContent className="flex items-center p-4">
104-
<Users size={32} className="text-blue-500 p-1" />
123+
{loading ? (
124+
<SkeletonLoader className="w-10 h-10 rounded-full" />
125+
) : (
126+
<Users size={32} className="text-blue-500 p-1" />
127+
)}
105128
<div className="ml-3">
106-
<h3 className="text-lg font-bold">تعداد خیرین</h3>
107-
<p className="text-gray-600">۵۳۰ نفر</p>
129+
<h3 className="text-lg font-bold">{loading ? <SkeletonLoader className="w-24 h-5" /> : "تعداد خیرین"}</h3>
130+
<p className="text-gray-600">{loading ? <SkeletonLoader className="w-24 h-5" /> : "۵۳۰ نفر"}</p>
108131
</div>
109132
</CardContent>
110133
</Card>
@@ -129,7 +152,7 @@ const Dashboard = () => {
129152
</CardContent>
130153
</Card>
131154

132-
155+
133156

134157
<Card className="col-span-6 col-span-2 p-4 ">
135158
<h3 className="text-md font mb-2">نمودار کمک‌های مالی</h3>
@@ -275,7 +298,7 @@ const Dashboard = () => {
275298
</div>
276299
</div>
277300

278-
301+
279302

280303
</div>
281304
);

0 commit comments

Comments
 (0)