Proyectos de Subversion LeadersLinked - SPA

Rev

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