Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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