Skip to content

Commit 70b191b

Browse files
committed
add skeleton store
1 parent bb32287 commit 70b191b

2 files changed

Lines changed: 70 additions & 24 deletions

File tree

src/pages/Store/shop/currency-tab/CurrenciesContent.jsx

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { ScaleLoader } from "react-spinners";
99
import Container from "../../../../components/Common/Container";
1010
import { useLocation } from "react-router-dom";
1111
import { currencies } from "../data";
12-
12+
import { Skeleton } from "../../../../components/Skeleton";
1313
const Wrapper = styled.div`
1414
display: flex;
1515
flex-direction: column;
@@ -19,6 +19,15 @@ const Wrapper = styled.div`
1919
margin-top: 20px;
2020
overflow-y: auto;
2121
`;
22+
const SkeletonCard = styled.div`
23+
background-color: ${(props) =>
24+
props.theme.colors.newColors.otherColors.inputBg};
25+
border-radius: 10px;
26+
padding: 20px;
27+
display: flex;
28+
justify-content:space-between;
29+
gap: 15px;
30+
`;
2231

2332
const CurrenciesContent = () => {
2433
const { alert } = useContext(AlertContext);
@@ -57,18 +66,31 @@ const CurrenciesContent = () => {
5766
<Container>
5867
{alert && <Alert type="success" text="خرید شما با موفقیت انجام شد!" />}
5968
<Title title="ارزها" />
60-
<Wrapper loading={loading}>
69+
<Wrapper>
6170
{loading ? (
62-
<ScaleLoader
63-
color="orange"
64-
loading={true}
65-
height="100"
66-
width="10"
67-
margin="5"
68-
/>
71+
Array.from({ length: 2 }).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+
))
6991
) : (
7092
assets.map((item) => (
71-
<InfoRow shop type="ارز" key={item.id} data={item} />
93+
<InfoRow shop type="ابزار" key={item.id} data={item} />
7294
))
7395
)}
7496
</Wrapper>

src/pages/Store/shop/tool-tab/ToolsContent.jsx

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,27 @@ import Alert from "../../../../components/Alert/Alert";
55
import Title from "../../../../components/Title";
66
import InfoRow from "../InfoRow";
77
import useRequest from "../../../../services/Hooks/useRequest";
8-
import { ScaleLoader } from "react-spinners";
8+
import { Skeleton } from "../../../../components/Skeleton";
99
import Container from "../../../../components/Common/Container";
10-
import { useParams } from "react-router-dom";
1110
import { useLocation } from "react-router-dom";
1211
import { tools } from "../data";
1312

1413
const 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

2431
const 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

Comments
 (0)