Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 7218 | Ir a la última revisión | | 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'
6
import EditIcon from '@mui/icons-material/Edit'
7
import DeleteIcon from '@mui/icons-material/Delete'
8
 
9
import {
10
  QuestionActions,
11
  QuestionDetails,
12
  QuestionStats,
13
  QuestionUserInfo,
14
  StyledQuestionCard,
15
} from './QuestionCard'
16
import CommentSection from '../feed/CommentSection'
17
 
18
const AnswerCard = ({
19
  unique = '',
20
  uuid = '',
21
  question_uuid = '',
22
  user_image = '',
23
  user_url = '',
24
  user_name = '',
25
  time_elapsed = '',
26
  text = '',
27
  reaction = '',
28
  total_comments = 0,
29
  total_reactions = 0,
30
  comments = [
31
    {
32
      unique: '64de4a4714a45',
33
      answer_uuid: '0370dcb5-453c-4e6e-8fbf-c40b0488ca83',
34
      user_image:
35
        '/storage/type/user/code/e85129fa-18eb-4149-8640-fea9ae916cdc/filename/user-profile-64d514603a742.png/',
36
      user_url: '/profile/view/e85129fa-18eb-4149-8640-fea9ae916cdc',
37
      user_name: 'Santiago Olivera',
38
      time_elapsed: '2 meses',
39
      comment: 'weerwerwe',
40
      link_delete:
41
        '/my-coach/questions/comments/0370dcb5-453c-4e6e-8fbf-c40b0488ca83/delete/d2eda6ff-ca35-425c-b791-fe0e97aafc28',
42
    },
43
  ],
44
  link_edit = '',
45
  link_delete = '',
46
  link_reaction_delete = '',
47
  link_save_reaction = '',
48
  link_add_comment = '',
49
}) => {
50
  const labels = useSelector(({ intl }) => intl.labels)
51
 
52
  const onEdit = () => {}
53
 
54
  const onDelete = () => {}
55
 
56
  return (
57
    <>
58
      <StyledQuestionCard>
59
        <QuestionDetails>
60
          <QuestionUserInfo>
61
            <Link to={user_url}>
62
              <Avatar
63
                src={user_image}
64
                alt={`${user_name} profile image`}
65
                sx={{ width: '50px', height: '50px' }}
66
              />
67
            </Link>
68
            <p>{user_name}</p>
69
          </QuestionUserInfo>
70
 
71
          <QuestionStats className="mb-2">
72
            <span>{`${comments} ${labels.comments}`}</span>
73
          </QuestionStats>
74
        </QuestionDetails>
75
        {text && parse(text)}
76
 
77
        <QuestionActions>
78
          {link_edit && (
79
            <button
80
              className="btn feed__share-option"
81
              onClick={() => onEdit(link_edit)}
82
            >
83
              <EditIcon />
84
              {labels.edit}
85
            </button>
86
          )}
87
          {link_delete && (
88
            <button
89
              className="btn feed__share-option"
90
              onClick={() => onDelete(link_delete)}
91
            >
92
              <DeleteIcon />
93
              {labels.delete}
94
            </button>
95
          )}
96
        </QuestionActions>
97
        <CommentSection
98
          addUrl={link_add_comment}
99
          currentComments={comments}
100
          isShow
101
        />
102
      </StyledQuestionCard>
103
    </>
104
  )
105
}
106
 
107
export default AnswerCard