3481 |
stevensc |
1 |
import React from 'react';
|
|
|
2 |
import { Avatar, Box, IconButton, styled, Typography } from '@mui/material';
|
|
|
3 |
import { DeleteOutline } from '@mui/icons-material';
|
|
|
4 |
|
|
|
5 |
import { parse } from '@utils';
|
|
|
6 |
import { formatDate } from '@utils/dates';
|
|
|
7 |
import { CapsuleRating } from './UI';
|
|
|
8 |
|
|
|
9 |
const CommentContainer = styled(Box)`
|
|
|
10 |
background-color: ${(props) => props.theme.background.color.primary};
|
|
|
11 |
padding: 0.5rem;
|
|
|
12 |
display: flex;
|
|
|
13 |
justify-content: space-between;
|
|
|
14 |
gap: 0.5rem;
|
|
|
15 |
`;
|
|
|
16 |
|
|
|
17 |
export const CapsuleComment = ({
|
|
|
18 |
comment: { image, fullname, comment: content, rating, date, link_delete },
|
|
|
19 |
onDelete
|
|
|
20 |
}) => {
|
|
|
21 |
return (
|
|
|
22 |
<CommentContainer>
|
|
|
23 |
<Box display='flex' gap={1} alignItems='center'>
|
|
|
24 |
<Avatar src={image} alt={fullname} sx={{ width: 60, height: 60 }} />
|
|
|
25 |
|
|
|
26 |
<Box display='flex' flexDirection='column'>
|
|
|
27 |
<Typography variant='h3'>{fullname}</Typography>
|
|
|
28 |
<Typography>{parse(content)}</Typography>
|
|
|
29 |
<CapsuleRating readOnly max={5} value={rating} size='small' />
|
|
|
30 |
</Box>
|
|
|
31 |
</Box>
|
|
|
32 |
|
|
|
33 |
<Box display='flex' flexDirection='column' justifyContent='space-between' alignItems='end'>
|
|
|
34 |
{link_delete && (
|
|
|
35 |
<IconButton onClick={() => onDelete(link_delete)}>
|
|
|
36 |
<DeleteOutline />
|
|
|
37 |
</IconButton>
|
|
|
38 |
)}
|
|
|
39 |
|
|
|
40 |
<span>{formatDate(date)}</span>
|
|
|
41 |
</Box>
|
|
|
42 |
</CommentContainer>
|
|
|
43 |
);
|
|
|
44 |
};
|