AdminGoodItem.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { actionPopupOpen } from '../../../reducers';
  2. import { connect } from 'react-redux';
  3. import { Link } from 'react-router-dom';
  4. import defaultGoodImage from '../../../images/default-good-image.png';
  5. import { FaEdit } from 'react-icons/fa';
  6. import { Box, Button, TableCell, TableRow } from '@mui/material';
  7. import { backendURL } from '../../../helpers';
  8. const AdminGoodItem = ({ good }) => (
  9. <TableRow className="AdminGoodItem">
  10. <TableCell scope="row">{good._id}</TableCell>
  11. <TableCell>{good.name ? good.name : '-'}</TableCell>
  12. <TableCell>
  13. {
  14. <Box
  15. component="img"
  16. src={good.images?.length ? `${good.images ? good.images[0]?.url : ''}` : defaultGoodImage}
  17. />
  18. }
  19. </TableCell>
  20. <TableCell>{good.price ? good.price : '-'}</TableCell>
  21. <TableCell>{good.amount ? good.amount : '-'}</TableCell>
  22. <TableCell>
  23. {good.categories
  24. ? (good.categories || []).map((category) => <div key={category._id}>{category?.name}</div>)
  25. : '-'}
  26. </TableCell>
  27. <TableCell className="edit">
  28. <Button component={Link} className="Link" to={`/admin/good/${good._id}/`} variant="contained">
  29. Редагувати
  30. </Button>
  31. </TableCell>
  32. </TableRow>
  33. );
  34. export { AdminGoodItem };