Skip to content

Commit

Permalink
add catalog skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
radekm2000 committed Apr 7, 2024
1 parent c87dba9 commit 95419b7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
30 changes: 30 additions & 0 deletions client/ecommerce/src/components/CatalogSkeleton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Box, Container, Divider, Skeleton } from "@mui/material";

export const CatalogSkeleton = () => {
return (
<Container>
<Box sx={{ display: "flex", flexDirection: "column", gap: "10px" }}>
<Skeleton
variant="text"
sx={{ width: "10%", height: "20px" }}
></Skeleton>
<Skeleton
variant="text"
sx={{ width: "15%", height: "20px" }}
></Skeleton>
<Divider />
<Box sx={{ display: "flex", gap: "20px" }}>
<Skeleton
variant="rectangular"
sx={{ width: "70px", height: "20px" }}
></Skeleton>
<Skeleton
variant="rectangular"
sx={{ width: "70px", height: "20px" }}
></Skeleton>
</Box>
<Divider />
</Box>
</Container>
);
};
3 changes: 2 additions & 1 deletion client/ecommerce/src/components/pages/MenCatalog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { BrandButton } from "../filter-buttons/BrandButton";
import { SortByPriceButton } from "../filter-buttons/SortByPriceButton";
import { useFilteredProducts } from "../../hooks/useFilteredProducts";
import { AccountCircle } from "@mui/icons-material";
import { CatalogSkeleton } from "../CatalogSkeleton";

export const MenCatalog = () => {
const below1200 = useMediaQuery(1200);
Expand Down Expand Up @@ -53,7 +54,7 @@ export const MenCatalog = () => {
);

if (isProductsLoading) {
return "isLoading...";
return <CatalogSkeleton />;
}
if (!products) {
return;
Expand Down
8 changes: 2 additions & 6 deletions client/ecommerce/src/components/pages/WomenCatalog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { BrandButton } from "../filter-buttons/BrandButton";
import { SortByPriceButton } from "../filter-buttons/SortByPriceButton";
import { useFilteredProducts } from "../../hooks/useFilteredProducts";
import { AccountCircle } from "@mui/icons-material";
import { CatalogSkeleton } from "../CatalogSkeleton";

export const WomenCatalog = () => {
const below1200 = useMediaQuery(1200);
Expand All @@ -30,11 +31,6 @@ export const WomenCatalog = () => {
const [order, setOrder] = useState("");
const { user } = useUserContext();
const [category] = useState<string>("Women");
console.log("chosen brand");
console.log(brand);

console.log(user);
console.log(order);
useEffect(() => {
const params = new URLSearchParams();
if (brand && order) {
Expand All @@ -57,7 +53,7 @@ export const WomenCatalog = () => {
);

if (isProductsLoading) {
return "isLoading...";
return <CatalogSkeleton />;
}
if (!products) {
return;
Expand Down

0 comments on commit 95419b7

Please sign in to comment.