SearchGoodResultItem.js 1.3 KB

1234567891011121314151617181920212223242526272829
  1. import { backendURL } from 'helpers';
  2. import { Link } from 'react-router-dom';
  3. import defaultGoodImage from 'images/defaultGoodImage.png';
  4. import { Grid, Box, Stack, Typography } from '@mui/material';
  5. const SearchGoodResultItem = ({ good, onClick, link = '' } = {}) => {
  6. const { _id = 0, images = [], name = '', description = '', price = '' } = good || {};
  7. return (
  8. <Link className="Link" to={`${link}${_id}/`}>
  9. <Stack direction="row" className="SearchGoodResultItem" onClick={() => onClick && onClick()}>
  10. <Box component="img" src={images[0]?.url ? `/${images ? images[0]?.url : ''}` : defaultGoodImage} />
  11. <Box sx={{ p: 1, flexGrow: 1 }}>
  12. <Typography variant="body1" sx={{ flexGrow: 1 }}>
  13. {name.length > 30 ? `${name.substring(0, 30)}...` : name}
  14. </Typography>
  15. <Typography variant="body2">
  16. {description.length > 70 ? `${description.substring(0, 70)}...` : description}
  17. </Typography>
  18. </Box>
  19. <Typography variant="body1" sx={{ display: 'flex', alignItems: 'center' }}>
  20. {price}
  21. </Typography>
  22. </Stack>
  23. </Link>
  24. );
  25. };
  26. export default SearchGoodResultItem;