Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 7068 | Rev 7081 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 7068 Rev 7080
Línea 14... Línea 14...
14
import parse from 'html-react-parser'
14
import parse from 'html-react-parser'
15
import styled from 'styled-components'
15
import styled from 'styled-components'
16
import FileDownloadIcon from '@mui/icons-material/FileDownload'
16
import FileDownloadIcon from '@mui/icons-material/FileDownload'
Línea 17... Línea 17...
17
 
17
 
-
 
18
import ReactionsButton from '../../components/UI/buttons/ReactionsButton'
Línea 18... Línea 19...
18
import ReactionsButton from '../../components/UI/buttons/ReactionsButton'
19
import FeedCommentSection from '../../components/feed/CommentSection'
19
 
20
 
20
const KnowledgeCard = styled(Card)`
21
const KnowledgeCard = styled(Card)`
21
  background-color: var(--bg-color);
22
  background-color: var(--bg-color);
Línea 35... Línea 36...
35
    max-width: calc(100% / 3);
36
    max-width: calc(100% / 3);
36
  }
37
  }
37
`
38
`
Línea 38... Línea 39...
38
 
39
 
-
 
40
const KnowledgeViewPage = () => {
39
const KnowledgeViewPage = () => {
41
  const [comments, setComments] = useState([])
40
  const [knowledge, setKnowledge] = useState({
42
  const [knowledge, setKnowledge] = useState({
41
    category: '',
43
    category: '',
42
    title: '',
44
    title: '',
43
    description: '',
45
    description: '',
Línea 53... Línea 55...
53
  const labels = useSelector(({ intl }) => intl.labels)
55
  const labels = useSelector(({ intl }) => intl.labels)
54
  const dispatch = useDispatch()
56
  const dispatch = useDispatch()
55
  const { uuid } = useParams()
57
  const { uuid } = useParams()
Línea 56... Línea 58...
56
 
58
 
57
  const changeReaction = (reaction) => {
59
  const changeReaction = (reaction) => {
58
    setKnowledge((prevKnowledge) => ({ ...prevKnowledge, reaction }))
60
    setKnowledge((prevKnowledge) => ({ ...prevKnowledge }))
Línea 59... Línea 61...
59
  }
61
  }
60
 
62
 
61
  useEffect(() => {
63
  useEffect(() => {
Línea 86... Línea 88...
86
        )
88
        )
87
        throw new Error(err)
89
        throw new Error(err)
88
      })
90
      })
89
  }, [uuid])
91
  }, [uuid])
Línea -... Línea 92...
-
 
92
 
-
 
93
  useEffect(() => {
-
 
94
    if (!knowledge.routeComments) return
-
 
95
 
-
 
96
    axios
-
 
97
      .get(knowledge.routeComments)
-
 
98
      .then((response) => {
-
 
99
        const { data, success } = response.data
-
 
100
 
-
 
101
        if (!success) {
-
 
102
          const errorMessage =
-
 
103
            typeof data === 'string' ? data : labels.error_there_was_an_error
-
 
104
 
-
 
105
          dispatch(addNotification({ style: 'danger', msg: errorMessage }))
-
 
106
          return
-
 
107
        }
-
 
108
 
-
 
109
        setComments(data)
-
 
110
      })
-
 
111
      .catch((err) => {
-
 
112
        dispatch(
-
 
113
          addNotification({
-
 
114
            style: 'danger',
-
 
115
            msg: labels.error_there_was_an_error,
-
 
116
          })
-
 
117
        )
-
 
118
        throw new Error(err)
-
 
119
      })
-
 
120
  }, [knowledge])
90
 
121
 
91
  return (
122
  return (
-
 
123
    <Container as="section">
92
    <Container as="section">
124
      <h2>{labels.knowledge_area_title}</h2>
93
      <Row>
125
      <Row>
94
        <Col className="mx-auto" md="8">
126
        <Col className="mx-auto" md="8">
95
          <KnowledgeCard>
127
          <KnowledgeCard>
96
            <CardMedia
128
            <CardMedia
Línea 139... Línea 171...
139
                  rel="noreferrer"
171
                  rel="noreferrer"
140
                >
172
                >
141
                  {labels.knowledge_area_go_to_link}
173
                  {labels.knowledge_area_go_to_link}
142
                </a>
174
                </a>
143
              )}
175
              )}
-
 
176
              <FeedCommentSection
-
 
177
                currentComments={comments}
-
 
178
                addUrl={knowledge.routeCommentAdd}
-
 
179
                isShow
-
 
180
              />
144
            </KnowledgeActions>
181
            </KnowledgeActions>
145
          </KnowledgeCard>
182
          </KnowledgeCard>
146
        </Col>
183
        </Col>
147
      </Row>
184
      </Row>
148
    </Container>
185
    </Container>