Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 7219 | Rev 7221 | 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 = () => {},
7217 stevensc 43
}) => {
44
  const labels = useSelector(({ intl }) => intl.labels)
45
 
46
  const onDelete = () => {}
47
 
48
  return (
49
    <>
50
      <StyledQuestionCard>
51
        <QuestionDetails>
52
          <QuestionUserInfo>
53
            <Link to={user_url}>
54
              <Avatar
55
                src={user_image}
56
                alt={`${user_name} profile image`}
57
                sx={{ width: '50px', height: '50px' }}
58
              />
59
            </Link>
60
            <p>{user_name}</p>
61
          </QuestionUserInfo>
62
 
63
          <QuestionStats className="mb-2">
7218 stevensc 64
            <span>{`${labels.published} ${time_elapsed}`}</span>
65
            <span>{`${total_reactions} ${labels.reactions}`}</span>
66
            <span>{`${total_comments} ${labels.comments}`}</span>
7217 stevensc 67
          </QuestionStats>
68
        </QuestionDetails>
69
        {text && parse(text)}
70
 
7218 stevensc 71
        <AnswerActions>
7217 stevensc 72
          {link_edit && (
73
            <button
74
              className="btn feed__share-option"
7220 stevensc 75
              onClick={() => onEdit(link_edit, text)}
7217 stevensc 76
            >
77
              <EditIcon />
78
              {labels.edit}
79
            </button>
80
          )}
81
          {link_delete && (
82
            <button
83
              className="btn feed__share-option"
84
              onClick={() => onDelete(link_delete)}
85
            >
86
              <DeleteIcon />
87
              {labels.delete}
88
            </button>
89
          )}
7218 stevensc 90
          {link_save_reaction && (
91
            <ReactionsButton
7219 stevensc 92
              className="btn feed__share-option"
7218 stevensc 93
              currentReaction={reaction}
94
              saveUrl={link_save_reaction}
95
              deleteUrl={link_reaction_delete}
96
              withLabel
97
            />
98
          )}
99
        </AnswerActions>
7217 stevensc 100
        <CommentSection
101
          addUrl={link_add_comment}
102
          currentComments={comments}
103
          isShow
104
        />
105
      </StyledQuestionCard>
106
    </>
107
  )
108
}
109
 
110
export default AnswerCard