index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { useEffect, useState } from 'react';
  2. import { CBuyButton } from '../common/BuyButton';
  3. import { useSelector } from 'react-redux';
  4. import defaultGoodImage from '../../images/default-good-image.png';
  5. import { Divider, Grid, Paper, Stack, Table, TableBody, TableCell, TableRow, Typography } from '@mui/material';
  6. import { Box } from '@mui/system';
  7. import { Carousel } from 'react-responsive-carousel';
  8. import { backendURL } from '../../helpers';
  9. export const GoodPage = () => {
  10. const good = useSelector((state) => state.promise?.goodById?.payload || {});
  11. const { _id = '', name = '', price = '', description = '', images = [] } = good || {};
  12. return (
  13. <Box className="GoodPage">
  14. <Grid container spacing={4} className="images">
  15. <Grid item xs={12} md={4}>
  16. <Carousel showIndicators={false} showStatus={false} showArrows={true}>
  17. {(good.images || [{ url: defaultGoodImage }]).map((image) => (
  18. <img src={image?.url ? `${image?.url}` : defaultGoodImage} />
  19. ))}
  20. </Carousel>
  21. </Grid>
  22. <Grid item xs={12} md={8} className="content">
  23. <Stack spacing={2}>
  24. <Stack direction="row" alignItems="center" spacing={2}>
  25. <Typography variant="body1" color="#1C1B1F">
  26. <b>Ціна:</b> {price}
  27. </Typography>
  28. <CBuyButton good={good} />
  29. </Stack>
  30. <Divider />
  31. <Typography variant="h5">
  32. <b>Назва: {name}</b>
  33. </Typography>
  34. <Typography variant="body1">
  35. Опис:
  36. <br />
  37. {description}
  38. </Typography>
  39. </Stack>
  40. </Grid>
  41. </Grid>
  42. </Box>
  43. );
  44. };