Gennadysht 1 год назад
Родитель
Сommit
196bebe4e1
2 измененных файлов с 40 добавлено и 0 удалено
  1. 35 0
      src/Components/CategoryBreadcrumbs.js
  2. 5 0
      src/Components/LoadingState.js

+ 35 - 0
src/Components/CategoryBreadcrumbs.js

@@ -0,0 +1,35 @@
+import { Breadcrumbs } from "@mui/material";
+import { Typography } from "@mui/material";
+import { MyLink } from ".";
+
+export const CategoryBreadcrumbs = ({ category, showLeafAsLink = false }) => {
+    return (
+        <Breadcrumbs aria-label="breadcrumb">
+            <MyLink underline="hover" color="inherit" to="/">
+                Home
+            </MyLink>
+            {
+                category.parent?._id && (
+                    <MyLink
+                        underline="hover"
+                        color="inherit"
+                        to={`/category/${category.parent?._id}`}
+                    >
+                        {category.parent?.name}
+                    </MyLink>
+                )}
+            {
+                showLeafAsLink ?
+                        <MyLink
+                            underline="hover"
+                            color="inherit"
+                            to={`/category/${category._id}`}
+                        >
+                            {category.name}
+                        </MyLink>
+                    :
+                    <Typography color="text.primary">{category.name}</Typography>
+            }
+        </Breadcrumbs>
+    );
+};

+ 5 - 0
src/Components/LoadingState.js

@@ -0,0 +1,5 @@
+import { Typography } from "@mui/material";
+
+export const LoadingState = () =>{
+    return <Typography>Loading</Typography>;
+}