1
1
import { Card , CardContent } from "../components/card" ;
2
2
import { BarChart , Bar , XAxis , YAxis , Tooltip , ResponsiveContainer , LineChart , Line , AreaChart , CartesianGrid , Area } from "recharts" ;
3
3
import { Users , HandHeart , Filter , ArrowUpRight , DollarSign , Calendar } from "lucide-react" ;
4
- import { useState } from "react" ;
4
+ import { useEffect , useState } from "react" ;
5
5
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" ;
6
10
7
11
const Dashboard = ( ) => {
8
12
const [ searchTerm , setSearchTerm ] = useState ( "" ) ;
9
13
const [ selectedMonth , setSelectedMonth ] = useState ( "" ) ;
14
+ const [ loading , setLoading ] = useState ( true ) ;
15
+
16
+ useEffect ( ( ) => {
17
+ setTimeout ( ( ) => {
18
+ setLoading ( false ) ; // پس از ۲ ثانیه دادهها لود میشوند
19
+ } , 2000 ) ;
20
+ } , [ ] ) ;
10
21
11
22
const donationData = [
12
23
// { name: "تیر", amount: 15000, donors: 35 },
@@ -90,21 +101,33 @@ const Dashboard = () => {
90
101
return (
91
102
< div className = "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-12 gap-4 p-5" >
92
103
< 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
+ ) }
100
117
</ Card >
101
118
119
+
120
+
102
121
< Card className = "col-span-3 shadow bg-blend-normal" >
103
122
< 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
+ ) }
105
128
< 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 >
108
131
</ div >
109
132
</ CardContent >
110
133
</ Card >
@@ -129,7 +152,7 @@ const Dashboard = () => {
129
152
</ CardContent >
130
153
</ Card >
131
154
132
-
155
+
133
156
134
157
< Card className = "col-span-6 col-span-2 p-4 " >
135
158
< h3 className = "text-md font mb-2" > نمودار کمکهای مالی</ h3 >
@@ -275,7 +298,7 @@ const Dashboard = () => {
275
298
</ div >
276
299
</ div >
277
300
278
-
301
+
279
302
280
303
</ div >
281
304
) ;
0 commit comments