import { List, ListItem, ListItemButton, ListItemText, Breadcrumbs } from "@mui/material" import { Typography } from "@mui/material" import { Box, Container } from "@mui/system" import { useEffect } from "react" import { connect } from "react-redux" import { useParams } from "react-router-dom" import { MyLink } from "." import { actionCategoryFindOne } from "../reducers" import { GoodsList } from "./GoodsList" import { CatsList } from "./RootCats" const CSubCategories = connect(state => ({ cats: state.category.catFindOne?.payload?.subCategories }), { loadData: actionCategoryFindOne })(CatsList); const Category = (props) => { let { loadData, cat = { name: 'loading', goods: [] } } = props; const { _id } = useParams(); useEffect(() => { loadData(_id) }, [_id, loadData]); let csubCats = false; return ( <> Home {cat.parent?._id && ( {cat.parent?.name} )} {cat.name} {cat.name} {csubCats && } {!csubCats && cat.subCategories?.length > 0 && ( {cat.subCategories.map(scat => ( ))} ) } ) } const CCategory = connect(state => ({ cat: state.category.catFindOne?.payload }), { loadData: actionCategoryFindOne })(Category); export { CCategory };