Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev Autor Línea Nro. Línea
3452 stevensc 1
import React from 'react';
2
import { useSelector } from 'react-redux';
3
import { useParams } from 'react-router-dom';
3510 stevensc 4
import { Button, Typography } from '@mui/material';
3452 stevensc 5
import { FileDownload } from '@mui/icons-material';
6
 
7
import { withReactions } from '@hocs';
3510 stevensc 8
import { useKnowledge } from '@knowledges/hooks';
9
import { parse } from '@shared/utils';
3452 stevensc 10
 
3510 stevensc 11
import {
12
  Card,
13
  CardActions,
14
  CardContent,
15
  CardMedia,
16
  CommentForm,
17
  CommentsList,
18
  PageHeader
19
} from '@shared/components';
3452 stevensc 20
 
21
export default function KnowledgePage() {
3510 stevensc 22
  const labels = useSelector(({ intl }) => intl.labels);
3452 stevensc 23
  const { uuid } = useParams();
24
 
25
  const { knowledge, comments, addComment, deleteComment } = useKnowledge(uuid);
26
 
27
  const ReactionsButton = withReactions(Button);
28
 
29
  return (
30
    <>
3510 stevensc 31
      <PageHeader title={labels.knowledge_area_title} goBack />
3452 stevensc 32
 
3510 stevensc 33
      <Card>
34
        <CardMedia
35
          src={knowledge.image}
36
          alt={`${knowledge.title} image`}
37
          styles={{ width: '100%', maxHeight: '400px' }}
38
        />
39
        <CardContent>
40
          <Typography variant='h2'>{knowledge.title}</Typography>
41
          <Typography variant='caption'>{knowledge.category}</Typography>
42
          <Typography>{parse(knowledge.description)}</Typography>
43
        </CardContent>
3452 stevensc 44
 
3510 stevensc 45
        <CardActions>
46
          <ReactionsButton
47
            currentReactionType={knowledge.reaction}
48
            deleteUrl={knowledge.routeDeleteReaction}
49
            saveUrl={knowledge.routeSaveReaction}
50
            onReaction={() => {}}
51
          />
3452 stevensc 52
 
3510 stevensc 53
          {knowledge.attachment && (
54
            <a href={knowledge.attachment} download>
55
              <FileDownload />
56
              {labels.knowledge_area_download_attachment}
57
            </a>
58
          )}
59
          {knowledge.link && (
60
            <a href={knowledge.link} target='_blank' rel='noreferrer'>
61
              {labels.knowledge_area_go_to_link}
62
            </a>
63
          )}
64
        </CardActions>
3452 stevensc 65
 
3510 stevensc 66
        <CardContent>
67
          <CommentForm onSubmit={addComment} />
68
          <CommentsList comments={comments} onDelete={deleteComment} />
69
        </CardContent>
70
      </Card>
3452 stevensc 71
    </>
72
  );
73
}