Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3694 | | Comparar con el anterior | Ultima modificación | Ver Log |

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