Skip to content

Commit 7f38971

Browse files
committed
feat: add loading to the categories page
1 parent 116b687 commit 7f38971

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Skeleton, Stack } from '@mui/material';
2+
import React from 'react';
3+
4+
const Loading = () => {
5+
return (
6+
<Stack direction="row" alignItems="flex-start">
7+
<Skeleton width={115} height="100%" />
8+
<Stack px={1.5} gap={1} flexWrap="wrap" direction="row" flexGrow={1}>
9+
{new Array(6).fill(1).map((item) => {
10+
return <Skeleton width="30%" height={100} />;
11+
})}
12+
</Stack>
13+
</Stack>
14+
);
15+
};
16+
17+
export default Loading;

src/app/[locale]/(main)/categories/page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Stack } from '@mui/material';
77
import { useEffect, useState } from 'react';
88
import MenuCategoryItem from './components/MenuCategoryItem';
99
import SubCategories from './components/SubCategories';
10+
import Loading from './loading';
1011

1112
const page = () => {
1213
const { data, loading } = useQuery<CategoriesQuery>(
@@ -28,8 +29,8 @@ const page = () => {
2829
}
2930
}, [loading]);
3031

31-
if (loading || !selected) {
32-
return <>Loading</>;
32+
if (!loading || !selected) {
33+
return <Loading />;
3334
}
3435

3536
return (

0 commit comments

Comments
 (0)