import { useEffect } from 'react';
import { useParams } from 'react-router-dom';
import { connect } from 'react-redux';

import { actionFindPostOne } from '../redux/action';
import Grid2 from '@mui/material/Unstable_Grid2/Grid2';
import { Paper, Box, Card, CardHeader, Avatar } from '@mui/material';
import { styled } from '@mui/material/styles';

import { MyCarouselPost } from './carousel_post';

import { url } from '../../App';
import { CardPost } from './card_post';


const Item = styled(Paper)(() => ({
    borderRadius: 0,
    boxShadow: 'none',
}))


function Comments({ post = {}, loadPost }) {
    // console.log('start')
    // console.log('post: ', post)

    const { postId } = useParams()
    useEffect(() => { loadPost(postId) }, [postId])

    return (
        <Box>
            <Grid2 container sx={{
                height: '80vh',
                backgroundColor: "blue"
            }}>
                <Grid2 xs={8}>
                    <Item sx={{
                        backgroundColor: "black",
                        width: '100%',
                        height: '100%',
                        display: 'flex',
                        alignItems: 'center'
                    }}>
                        <MyCarouselPost />
                    </Item>
                </Grid2>
                <Grid2 xs={4}>
                    <Item >
                        <div style={{ backgroundColor: "yellow" }}>
                            <CardPost postData={post} />
                        </div>
                    </Item>
                </Grid2>
            </Grid2>
        </Box>


    )
}

export const CComments = connect(state => ({ post: state?.promise?.PostFindOne?.payload }), { loadPost: actionFindPostOne })(Comments)

