Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev Autor Línea Nro. Línea
7160 stevensc 1
import React from 'react'
2
import { Avatar, Card } from '@mui/material'
3
import { useSelector } from 'react-redux'
4
import styled from 'styled-components'
5
import OpenInNewIcon from '@mui/icons-material/OpenInNew'
6
import EditIcon from '@mui/icons-material/Edit'
7
import DeleteIcon from '@mui/icons-material/Delete'
8
 
9
const StyledQuestionCard = styled(Card)`
10
  background: var(--bg-color);
11
  border: 1px solid var(--border-primary);
12
  border-radius: var(--border-radius);
13
  height: fit-content;
14
  & > * {
15
    padding-right: 1rem;
16
    padding-left: 1rem;
17
  }
18
  & > h2 {
19
    font-size: 2rem;
20
    line-height: 1.2;
21
  }
22
  p {
23
    color: var(--font-color);
24
    font-size: 1rem;
25
    font-weight: 400;
26
    text-align: justify;
27
    margin-bottom: 0.5rem;
28
  }
29
  span {
30
    color: var(--subtitle-color);
31
    font-weight: 600;
32
    font-size: 0.9rem;
33
  }
34
`
35
 
36
const QuestionDetails = styled.div`
37
  display: flex;
38
  align-items: center;
39
  flex-wrap: wrap;
40
  gap: 1rem;
41
  justify-content: space-between;
42
  margin-bottom: 0.5rem;
43
  padding-bottom: 0.5rem;
44
  border-bottom: 1px solid var(--border-primary);
45
`
46
 
47
const QuestionUserInfo = styled.div`
48
  align-items: center;
49
  background: var(--chat-send);
50
  border-radius: var(--border-radius);
51
  color: var(--font-color);
52
  display: inline-flex;
53
  font-weight: 600;
54
  gap: 0.5rem;
55
  padding: 0.5rem;
56
  width: fit-content;
57
`
58
 
7162 stevensc 59
const QuestionActions = styled.div`
60
  display: flex;
61
  align-items: center;
62
  gap: 0.5rem;
63
  justify-content: space-around;
64
  padding-top: 0.5rem;
65
  border-top: 1px solid var(--border-primary);
66
 
67
  & > * {
68
    flex-grow: 1;
69
  }
70
`
71
 
7160 stevensc 72
const QuestionCard = ({
73
  uuid = '',
74
  user_name = '',
75
  user_image = '',
76
  title = '',
77
  description = '',
78
  categories = [],
79
  views = 0,
80
  answers = 0,
81
  reactions = 0,
82
  comments = 0,
83
  added_on = '',
84
  updated_on = '',
85
  link_add_comment = '',
86
  link_view = '',
87
  link_edit = '',
88
  link_delete = '',
89
}) => {
90
  const labels = useSelector(({ intl }) => intl.labels)
91
 
92
  return (
93
    <StyledQuestionCard>
94
      <QuestionDetails>
95
        <QuestionUserInfo>
96
          <Avatar
97
            src={user_image}
98
            alt={`${user_name} profile image`}
99
            sx={{ width: '50px', height: '50px' }}
100
          />
101
          <p>{user_name}</p>
102
        </QuestionUserInfo>
103
        <ul className="question-categories">
7161 stevensc 104
          {categories.map(({ category }) => (
7160 stevensc 105
            <li key={category}>{category}</li>
106
          ))}
107
        </ul>
108
      </QuestionDetails>
109
 
110
      <h2>{title}</h2>
111
      <span>{`${labels.my_coach_question} ${added_on}`}</span>
112
      <p className="my-3">{description}</p>
113
 
114
      <div className="my-coach-record-card-info mb-2">
115
        <span>{`${answers} ${labels.my_coach_answers}`}</span>
116
        <span>{`${reactions} ${labels.my_coach_reactions}`}</span>
117
        <span>{`${views} ${labels.my_coach_views}`}</span>
118
        <span>{`${comments} ${labels.comments}`}</span>
119
      </div>
120
 
7162 stevensc 121
      <QuestionActions>
7160 stevensc 122
        {link_view && (
123
          <button className="btn feed__share-option">
124
            <OpenInNewIcon />
125
            {labels.view}
126
          </button>
127
        )}
128
        {link_edit && (
129
          <button className="btn feed__share-option">
130
            <EditIcon />
131
            {labels.edit}
132
          </button>
133
        )}
134
        {link_delete && (
135
          <button className="btn feed__share-option">
136
            <DeleteIcon />
137
            {labels.delete}
138
          </button>
139
        )}
7162 stevensc 140
      </QuestionActions>
7160 stevensc 141
    </StyledQuestionCard>
142
  )
143
}
144
 
145
export default QuestionCard