DrawerCartItem.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { Box, width } from '@mui/system';
  2. import { backendURL } from '../../../helpers';
  3. import defaultGoodImage from '../../../images/default-good-image.png';
  4. import { IoCloseOutline } from 'react-icons/io5';
  5. import { AiOutlinePlus, AiOutlineMinus } from 'react-icons/ai';
  6. import { actionCartChange } from '../../../reducers';
  7. import { useEffect, useState } from 'react';
  8. import { useDispatch } from 'react-redux';
  9. import {
  10. ListItem,
  11. Grid,
  12. Typography,
  13. Stack,
  14. Container,
  15. IconButton,
  16. TextField,
  17. ButtonGroup,
  18. Button,
  19. Input,
  20. TableCell,
  21. TableRow,
  22. Card,
  23. CardMedia,
  24. CardContent,
  25. } from '@mui/material';
  26. const DrawerCartItem = ({ order, onDeleteClick }) => {
  27. const {
  28. good: { _id, images = [], name = '', price = 0 },
  29. } = order || {};
  30. return (
  31. <Card className="DrawerCartItem">
  32. <CardMedia
  33. component="img"
  34. sx={{ width: 90 }}
  35. src={images && images[0]?.url ? `${images ? images[0]?.url : ''}` : defaultGoodImage}
  36. onError={({ currentTarget }) => {
  37. currentTarget.onerror = null; // prevents looping
  38. currentTarget.src = defaultGoodImage;
  39. }}
  40. />
  41. <Box sx={{ display: 'flex', width: '100%' }}>
  42. <CardContent className="content">
  43. <Typography component="div" variant="h5">
  44. {name.length > 20 ? `${name.slice(0, 15)}...` : name}
  45. </Typography>
  46. <Typography variant="subtitle1" color="text.secondary" component="div">
  47. {price} ₴
  48. </Typography>
  49. </CardContent>
  50. <Box className="buttons">
  51. <IconButton onClick={() => onDeleteClick({ _id, images, name, price })}>
  52. <IoCloseOutline />
  53. </IconButton>
  54. </Box>
  55. </Box>
  56. </Card>
  57. );
  58. };
  59. export { DrawerCartItem };