category.js 785 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { Link } from 'react-router-dom';
  2. import { PieChartOutlined } from '@ant-design/icons';
  3. import { connect } from 'react-redux';
  4. import { Menu } from 'antd';
  5. import React from 'react';
  6. const CategoryListItem = ({ _id, name, auth }) => {
  7. return (
  8. < >
  9. <Menu.Item icon={<PieChartOutlined />}><Link to={`/category/${_id}`}>{name} </Link></Menu.Item>
  10. </>
  11. );
  12. };
  13. const CategoryList = ({ cats, auth }) => {
  14. console.log('cats', cats);
  15. return (
  16. <div >
  17. {cats.map((item) => <CategoryListItem key={item._id} {...item} auth={auth} />)}
  18. </div>
  19. );
  20. };
  21. const mapStateToProps = state => ({
  22. cats: state.promise.rootCats?.payload || [],
  23. auth: state.auth
  24. });
  25. const CCategoryList = connect(mapStateToProps)(CategoryList);
  26. export default CCategoryList;