index.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { useEffect } from 'react';
  2. import { useParams } from 'react-router-dom';
  3. import { connect } from 'react-redux';
  4. import Grid2 from '@mui/material/Unstable_Grid2/Grid2';
  5. import { Paper, Box } from '@mui/material';
  6. import { styled } from '@mui/material/styles';
  7. import { actionFindPostOne } from '../../redux/action';
  8. import { MyCarouselPost } from './carousel';
  9. import { CardPost } from './comments';
  10. const Item = styled(Paper)(() => ({
  11. borderRadius: 0,
  12. boxShadow: 'none',
  13. }))
  14. function Comments({ post = {}, loadPost }) {
  15. // console.log('post: ', post)
  16. const { postId } = useParams()
  17. useEffect(() => { loadPost(postId) }, [postId])
  18. return (
  19. <Box>
  20. <Grid2 container sx={{
  21. height: '80vh',
  22. }}>
  23. <Grid2 xs={7.5}>
  24. <Item sx={{
  25. backgroundColor: "black",
  26. width: '100%',
  27. height: '100%',
  28. display: 'flex',
  29. alignItems: 'center'
  30. }}>
  31. <MyCarouselPost postImages={post?.images} />
  32. </Item>
  33. </Grid2>
  34. <Grid2 xs={4.5}>
  35. <Item >
  36. <div style={{ backgroundColor: "yellow" }}>
  37. <CardPost postData={post} />
  38. </div>
  39. </Item>
  40. </Grid2>
  41. </Grid2>
  42. </Box>
  43. )
  44. }
  45. export const CComments = connect(state => ({ post: state?.promise?.PostFindOne?.payload }), { loadPost: actionFindPostOne })(Comments)