AdminGoodListHeader.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { connect } from 'react-redux';
  2. import { AddButton } from '../../common/AddButton';
  3. import { TableCell, TableRow, TableSortLabel } from '@mui/material';
  4. import { useNavigate } from 'react-router-dom';
  5. const AdminGoodListHeader = ({ onSortChange, sort }) => {
  6. const navigate = useNavigate();
  7. return (
  8. <TableRow className="AdminGoodListHeader">
  9. <TableCell scope="col">
  10. <TableSortLabel
  11. active={sort === '_id' || sort === '-_id'}
  12. direction={sort === '_id' ? 'asc' : 'desc'}
  13. onClick={() => onSortChange(sort === '_id' ? '-_id' : '_id')}
  14. >
  15. #
  16. </TableSortLabel>
  17. </TableCell>
  18. <TableCell scope="col">
  19. <TableSortLabel
  20. active={sort === 'name' || sort === '-name'}
  21. direction={sort === 'name' ? 'asc' : 'desc'}
  22. onClick={() => onSortChange(sort === 'name' ? '-name' : 'name')}
  23. >
  24. Назва
  25. </TableSortLabel>
  26. </TableCell>
  27. <TableCell scope="col">Зображення</TableCell>
  28. <TableCell scope="col">
  29. <TableSortLabel
  30. active={sort === 'price' || sort === '-price'}
  31. direction={sort === 'price' ? 'asc' : 'desc'}
  32. onClick={() => onSortChange(sort === 'price' ? '-price' : 'price')}
  33. >
  34. Ціна
  35. </TableSortLabel>
  36. </TableCell>
  37. <TableCell scope="col">
  38. <TableSortLabel
  39. active={sort === 'amount' || sort === '-amount'}
  40. direction={sort === 'amount' ? 'asc' : 'desc'}
  41. onClick={() => onSortChange(sort === 'amount' ? '-amount' : 'amount')}
  42. >
  43. Кількість
  44. </TableSortLabel>
  45. </TableCell>
  46. <TableCell scope="col">Категорії</TableCell>
  47. <TableCell scope="col">
  48. <AddButton
  49. onClick={() => {
  50. navigate('/admin/good/');
  51. }}
  52. />
  53. </TableCell>
  54. </TableRow>
  55. );
  56. };
  57. export { AdminGoodListHeader };