Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 2917 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
2854 stevensc 1
import React from 'react'
2844 stevensc 2
import { styled, Typography } from '@mui/material'
3
import { Link } from 'react-router-dom'
4
import Options from '@components/UI/Option'
5
 
6
const CommentContainer = styled('div')(({ theme }) => ({
7
  backgroundColor: '#ccc',
8
  borderRadius: theme.shape.borderRadius,
9
  display: 'flex',
10
  flexDirection: 'column',
11
  flexGrow: 1,
12
  gap: theme.spacing(0.5),
13
  padding: theme.spacing(0.5),
14
  position: 'relative'
15
}))
16
 
17
const CommentHeader = styled('div')(({ theme }) => ({
18
  display: 'flex',
19
  justifyContent: 'space-between',
20
  gap: theme.spacing(0.5)
21
}))
22
 
23
const CommentInfo = styled(Link)(() => ({
24
  display: 'flex',
25
  flexDirection: 'column'
26
}))
27
 
28
export default function CommentItem({ comment, onDelete, onReport }) {
29
  const {
30
    user_url,
31
    user_name,
32
    time_elapsed,
33
    comment: content,
34
    link_delete,
35
    link_abuse_report
36
  } = comment
37
 
38
  return (
39
    <CommentContainer>
40
      <CommentHeader>
41
        <CommentInfo to={user_url}>
42
          <Typography variant='h3'>{user_name}</Typography>
2917 stevensc 43
          <Typography variant='overline'>{time_elapsed}</Typography>
2844 stevensc 44
        </CommentInfo>
45
 
2854 stevensc 46
        <Options>
47
          {link_delete ? (
3185 stevensc 48
            <Options.Item onClick={() => onDelete(comment)}>
2889 stevensc 49
              Borrar
2854 stevensc 50
            </Options.Item>
51
          ) : null}
52
          {link_abuse_report ? (
3185 stevensc 53
            <Options.Item onClick={() => onReport(link_abuse_report)}>
2889 stevensc 54
              Reportar
2854 stevensc 55
            </Options.Item>
56
          ) : null}
57
        </Options>
2844 stevensc 58
      </CommentHeader>
59
 
60
      <Typography>{content}</Typography>
61
    </CommentContainer>
62
  )
63
}