RootCats.js 809 B

12345678910111213141516171819202122232425262728
  1. import { List, ListItem, ListItemButton, ListItemText } from "@mui/material";
  2. import { connect } from "react-redux";
  3. import { MyLink } from ".";
  4. import { actionCategoryFindOne } from "../reducers";
  5. export const CatsList = ({ cats = [] }) => {
  6. return (
  7. <List>
  8. {cats.map(cat => (
  9. <CatItem cat={cat} />
  10. ))}
  11. </List>
  12. )
  13. };
  14. const CRootCats = connect(state => ({ cats: state.promise.rootCats?.payload }))(CatsList)
  15. const CatItem = ({ cat }) => {
  16. return (
  17. <ListItem key={cat._id} disablePadding>
  18. <ListItemButton>
  19. <MyLink to={`/category/${cat._id}`}>
  20. <ListItemText primary={cat.name} />
  21. </MyLink>
  22. </ListItemButton>
  23. </ListItem>
  24. )
  25. };
  26. export { CRootCats };