| 3481 |
stevensc |
1 |
import React, { useEffect } from 'react';
|
|
|
2 |
import { useDispatch } from 'react-redux';
|
|
|
3 |
import { Typography } from '@mui/material';
|
|
|
4 |
|
|
|
5 |
import { useMicroLearning, useFetch } from '@hooks';
|
|
|
6 |
import { addTopic } from '../../../redux/micro-learning/topics.actions';
|
|
|
7 |
|
|
|
8 |
import Spinner from 'components/UI/Spinner';
|
|
|
9 |
import Topics from 'components/micro-learning/Topics';
|
|
|
10 |
|
|
|
11 |
const TopicsPage = () => {
|
|
|
12 |
const { link_topics: linkTopics } = useMicroLearning();
|
|
|
13 |
const { data: topics, isLoading } = useFetch(linkTopics, []);
|
|
|
14 |
const dispatch = useDispatch();
|
|
|
15 |
|
|
|
16 |
useEffect(() => {
|
|
|
17 |
topics.forEach((topic) => dispatch(addTopic(topic)));
|
|
|
18 |
}, [topics]);
|
|
|
19 |
|
|
|
20 |
return (
|
|
|
21 |
<>
|
|
|
22 |
<Typography variant='h1'>Topicos</Typography>
|
|
|
23 |
|
|
|
24 |
{isLoading ? <Spinner /> : <Topics />}
|
|
|
25 |
</>
|
|
|
26 |
);
|
|
|
27 |
};
|
|
|
28 |
|
|
|
29 |
export default TopicsPage;
|