3452 |
stevensc |
1 |
import React from 'react';
|
|
|
2 |
import { useSelector } from 'react-redux';
|
|
|
3 |
import { useParams } from 'react-router-dom';
|
|
|
4 |
import { Grid, Typography } from '@mui/material';
|
|
|
5 |
import { FileDownload } from '@mui/icons-material';
|
|
|
6 |
|
|
|
7 |
import { useKnowledge } from '../hooks';
|
|
|
8 |
import { parse } from '@utils';
|
|
|
9 |
import { withReactions } from '@hocs';
|
|
|
10 |
|
|
|
11 |
import WidgetWrapper from 'components/widgets/WidgetLayout';
|
|
|
12 |
import CommentForm from '@app/components/dashboard/linkedin/comments/comment-form';
|
|
|
13 |
import CommentsList from '@app/components/dashboard/linkedin/comments/comment-list';
|
|
|
14 |
import Button from '@app/components/UI/buttons/Buttons';
|
|
|
15 |
import { PageHeader } from '@app/modules/shared/components';
|
|
|
16 |
|
|
|
17 |
export default function KnowledgePage() {
|
|
|
18 |
const { uuid } = useParams();
|
|
|
19 |
const labels = useSelector(({ intl }) => intl.labels);
|
|
|
20 |
|
|
|
21 |
const { knowledge, comments, addComment, deleteComment } = useKnowledge(uuid);
|
|
|
22 |
|
|
|
23 |
const ReactionsButton = withReactions(Button);
|
|
|
24 |
|
|
|
25 |
return (
|
|
|
26 |
<>
|
|
|
27 |
<PageHeader title={labels.knowledge_area_title} />
|
|
|
28 |
|
|
|
29 |
<Grid container mt={1}>
|
|
|
30 |
<Grid xs={12} md={8} mx='auto'>
|
|
|
31 |
<WidgetWrapper>
|
|
|
32 |
<img
|
|
|
33 |
src={knowledge.image}
|
|
|
34 |
alt={`${knowledge.title} image`}
|
|
|
35 |
style={{ width: '100%', maxHeight: '400px' }}
|
|
|
36 |
/>
|
|
|
37 |
|
|
|
38 |
<WidgetWrapper.Body>
|
|
|
39 |
<h2>{knowledge.title}</h2>
|
|
|
40 |
<span>{knowledge.category}</span>
|
|
|
41 |
<Typography>{parse(knowledge.description)}</Typography>
|
|
|
42 |
</WidgetWrapper.Body>
|
|
|
43 |
|
|
|
44 |
<WidgetWrapper.Actions>
|
|
|
45 |
<ReactionsButton
|
|
|
46 |
currentReactionType={knowledge.reaction}
|
|
|
47 |
deleteUrl={knowledge.routeDeleteReaction}
|
|
|
48 |
saveUrl={knowledge.routeSaveReaction}
|
|
|
49 |
onReaction={() => {}}
|
|
|
50 |
/>
|
|
|
51 |
|
|
|
52 |
{knowledge.attachment && (
|
|
|
53 |
<a href={knowledge.attachment} download>
|
|
|
54 |
<FileDownload />
|
|
|
55 |
{labels.knowledge_area_download_attachment}
|
|
|
56 |
</a>
|
|
|
57 |
)}
|
|
|
58 |
{knowledge.link && (
|
|
|
59 |
<a href={knowledge.link} target='_blank' rel='noreferrer'>
|
|
|
60 |
{labels.knowledge_area_go_to_link}
|
|
|
61 |
</a>
|
|
|
62 |
)}
|
|
|
63 |
</WidgetWrapper.Actions>
|
|
|
64 |
|
|
|
65 |
<div className='px-3 pb-2'>
|
|
|
66 |
<CommentForm onSubmit={addComment} />
|
|
|
67 |
<CommentsList comments={comments} onDelete={deleteComment} />
|
|
|
68 |
</div>
|
|
|
69 |
</WidgetWrapper>
|
|
|
70 |
</Grid>
|
|
|
71 |
</Grid>
|
|
|
72 |
</>
|
|
|
73 |
);
|
|
|
74 |
}
|