@@ -5,20 +5,27 @@ import Alert from "../../../../components/Alert/Alert";
55import Title from "../../../../components/Title" ;
66import InfoRow from "../InfoRow" ;
77import useRequest from "../../../../services/Hooks/useRequest" ;
8- import { ScaleLoader } from "react-spinners " ;
8+ import { Skeleton } from "../../../../components/Skeleton " ;
99import Container from "../../../../components/Common/Container" ;
10- import { useParams } from "react-router-dom" ;
1110import { useLocation } from "react-router-dom" ;
1211import { tools } from "../data" ;
1312
1413const Wrapper = styled . div `
1514 display: flex;
16-
1715 flex-direction: column;
1816 gap: 20px;
1917 margin-top: 20px;
20- justify-content: ${ ( { loading } ) => ( loading ? "center" : "flex-start" ) } ;
21- align-items: ${ ( { loading } ) => ( loading ? "center" : "stretch" ) } ;
18+ ` ;
19+
20+ // اسکلتون کارت ساده
21+ const SkeletonCard = styled . div `
22+ background-color: ${ ( props ) =>
23+ props . theme . colors . newColors . otherColors . inputBg } ;
24+ border-radius: 10px;
25+ padding: 20px;
26+ display: flex;
27+ justify-content:space-between;
28+ gap: 15px;
2229` ;
2330
2431const ToolsContent = ( ) => {
@@ -46,6 +53,10 @@ const ToolsContent = () => {
4653 . then ( ( response ) => {
4754 setassets ( response . data . data ) ;
4855 } )
56+ . catch ( ( error ) => {
57+ console . error ( "Error fetching tools:" , error ) ;
58+ setassets ( [ ] ) ;
59+ } )
4960 . finally ( ( ) => {
5061 setLoading ( false ) ;
5162 } ) ;
@@ -55,15 +66,28 @@ const ToolsContent = () => {
5566 < Container >
5667 { alert && < Alert type = "success" text = "خرید شما با موفقیت انجام شد" /> }
5768 < Title title = "ابزارها" />
58- < Wrapper loading = { loading } >
69+ < Wrapper >
5970 { loading ? (
60- < ScaleLoader
61- color = "orange"
62- loading = { true }
63- height = "100"
64- width = "10"
65- margin = "5"
66- />
71+ Array . from ( { length : 3 } ) . map ( ( _ , index ) => (
72+ < SkeletonCard key = { index } >
73+ < div style = { { display : "flex" , alignItems : "center" , gap : "20px" , } } >
74+ < Skeleton width = "50px" height = "60px" radius = "8px" />
75+ < div style = { { display : "flex" , flexDirection :"column" , gap : "14px" , } } >
76+ < Skeleton width = "70px" height = "18px" radius = "4px" />
77+ < Skeleton width = "70px" height = "18px" radius = "4px" />
78+ </ div >
79+ </ div >
80+ < div style = { { display : "flex" , flexDirection :"column" , gap : "14px" , } } >
81+ < Skeleton width = "70px" height = "18px" radius = "4px" />
82+ < Skeleton width = "70px" height = "18px" radius = "4px" />
83+ </ div >
84+ < div style = { { display : "flex" , flexDirection :"column" , gap : "14px" , } } >
85+ < Skeleton width = "70px" height = "18px" radius = "4px" />
86+ < Skeleton width = "70px" height = "18px" radius = "4px" />
87+ </ div >
88+ < Skeleton width = "76px" height = "50px" radius = "8px" />
89+ </ SkeletonCard >
90+ ) )
6791 ) : (
6892 assets . map ( ( item ) => (
6993 < InfoRow shop type = "ابزار" key = { item . id } data = { item } />
@@ -74,4 +98,4 @@ const ToolsContent = () => {
7498 ) ;
7599} ;
76100
77- export default ToolsContent ;
101+ export default ToolsContent ;
0 commit comments