Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev Autor Línea Nro. Línea
7217 stevensc 1
import React from 'react'
2
import { Avatar } from '@mui/material'
3
import { Link } from 'react-router-dom'
4
import parse from 'html-react-parser'
5
import { useSelector } from 'react-redux'
7218 stevensc 6
import styled from 'styled-components'
7217 stevensc 7
import EditIcon from '@mui/icons-material/Edit'
8
import DeleteIcon from '@mui/icons-material/Delete'
9
 
10
import {
11
  QuestionActions,
12
  QuestionDetails,
13
  QuestionStats,
14
  QuestionUserInfo,
15
  StyledQuestionCard,
16
} from './QuestionCard'
17
import CommentSection from '../feed/CommentSection'
7218 stevensc 18
import ReactionsButton from '../UI/buttons/ReactionsButton'
7217 stevensc 19
 
7218 stevensc 20
const AnswerActions = styled(QuestionActions)`
21
  margin-bottom: 0.5rem;
22
`
23
 
7217 stevensc 24
const AnswerCard = ({
7218 stevensc 25
  // unique = '',
26
  // uuid = '',
27
  // question_uuid = '',
28
  time_elapsed = '',
7217 stevensc 29
  user_image = '',
30
  user_url = '',
31
  user_name = '',
32
  text = '',
33
  reaction = '',
34
  total_comments = 0,
35
  total_reactions = 0,
7218 stevensc 36
  comments = [],
7217 stevensc 37
  link_edit = '',
38
  link_delete = '',
39
  link_reaction_delete = '',
40
  link_save_reaction = '',
41
  link_add_comment = '',
7220 stevensc 42
  onEdit = () => {},
7221 stevensc 43
  onDelete = () => {},
7217 stevensc 44
}) => {
45
  const labels = useSelector(({ intl }) => intl.labels)
46
 
47
  return (
48
    <>
49
      <StyledQuestionCard>
50
        <QuestionDetails>
51
          <QuestionUserInfo>
52
            <Link to={user_url}>
53
              <Avatar
54
                src={user_image}
55
                alt={`${user_name} profile image`}
56
                sx={{ width: '50px', height: '50px' }}
57
              />
58
            </Link>
59
            <p>{user_name}</p>
60
          </QuestionUserInfo>
61
 
62
          <QuestionStats className="mb-2">
7218 stevensc 63
            <span>{`${labels.published} ${time_elapsed}`}</span>
64
            <span>{`${total_reactions} ${labels.reactions}`}</span>
65
            <span>{`${total_comments} ${labels.comments}`}</span>
7217 stevensc 66
          </QuestionStats>
67
        </QuestionDetails>
68
        {text && parse(text)}
69
 
7218 stevensc 70
        <AnswerActions>
7217 stevensc 71
          {link_edit && (
72
            <button
73
              className="btn feed__share-option"
7220 stevensc 74
              onClick={() => onEdit(link_edit, text)}
7217 stevensc 75
            >
76
              <EditIcon />
77
              {labels.edit}
78
            </button>
79
          )}
80
          {link_delete && (
81
            <button
82
              className="btn feed__share-option"
83
              onClick={() => onDelete(link_delete)}
84
            >
85
              <DeleteIcon />
86
              {labels.delete}
87
            </button>
88
          )}
7218 stevensc 89
          {link_save_reaction && (
90
            <ReactionsButton
7219 stevensc 91
              className="btn feed__share-option"
7218 stevensc 92
              currentReaction={reaction}
93
              saveUrl={link_save_reaction}
94
              deleteUrl={link_reaction_delete}
95
              withLabel
96
            />
97
          )}
98
        </AnswerActions>
7217 stevensc 99
        <CommentSection
100
          addUrl={link_add_comment}
101
          currentComments={comments}
102
          isShow
103
        />
104
      </StyledQuestionCard>
105
    </>
106
  )
107
}
108
 
109
export default AnswerCard