3505 |
stevensc |
1 |
import React, { useState } from 'react';
|
|
|
2 |
import { useParams } from 'react-router-dom';
|
|
|
3 |
import { Button, styled, Tab, Tabs } from '@mui/material';
|
|
|
4 |
|
|
|
5 |
import { useCapsule } from '@microlearning/hooks';
|
|
|
6 |
|
|
|
7 |
import { CommentForm, CommentsList, Spinner } from '@shared/components';
|
|
|
8 |
import CapsuleDetails from '@microlearning/components/CapsuleDetails';
|
|
|
9 |
|
|
|
10 |
const Picture = styled('img')`
|
|
|
11 |
width: 100%;
|
|
|
12 |
height: 250px;
|
|
|
13 |
border-radius: 10px;
|
|
|
14 |
background-color: #858585;
|
|
|
15 |
margin-bottom: 1rem;
|
|
|
16 |
`;
|
|
|
17 |
|
|
|
18 |
export function CapsulePage() {
|
|
|
19 |
const [section, setSection] = useState('');
|
|
|
20 |
const { uuid } = useParams();
|
|
|
21 |
|
|
|
22 |
const { capsule, loading } = useCapsule(uuid);
|
|
|
23 |
|
|
|
24 |
/* const getSlides = async () => {
|
|
|
25 |
try {
|
|
|
26 |
const slides = await getSlide(capsule.link_first_slide);
|
|
|
27 |
} catch (error) {
|
|
|
28 |
addNotification({ style: 'danger', msg: error.message });
|
|
|
29 |
}
|
|
|
30 |
};
|
|
|
31 |
|
|
|
32 |
const handleStart = async () => {
|
|
|
33 |
capsule?.total_slides === 1 && capsule?.type_first_slide === 'video'
|
|
|
34 |
? getSlides()
|
|
|
35 |
: navigate('slides');
|
|
|
36 |
}; */
|
|
|
37 |
|
|
|
38 |
const handleChange = (event, newValue) => {
|
|
|
39 |
setSection(newValue);
|
|
|
40 |
};
|
|
|
41 |
|
|
|
42 |
if (loading) return <Spinner />;
|
|
|
43 |
|
|
|
44 |
return (
|
|
|
45 |
<>
|
|
|
46 |
<Picture src={capsule.image} alt={`${capsule.name} capsule`} />
|
|
|
47 |
|
|
|
48 |
<Tabs value={section} onChange={handleChange}>
|
|
|
49 |
<Tab label='Información' value='details' />
|
|
|
50 |
<Tab label='Contenido' value='comments' />
|
|
|
51 |
<Tab label='Contenido' value='comment' />
|
|
|
52 |
</Tabs>
|
|
|
53 |
|
|
|
54 |
{section === 'details' && <CapsuleDetails />}
|
|
|
55 |
|
|
|
56 |
{section === 'comments' && <CommentsList comments={capsule.comments} />}
|
|
|
57 |
|
|
|
58 |
{section === 'comment' && <CommentForm />}
|
|
|
59 |
|
|
|
60 |
<Button color='primary'>Comenzar</Button>
|
|
|
61 |
</>
|
|
|
62 |
);
|
|
|
63 |
}
|