SearchGoodResultItem.js 1.5 KB

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