| 3481 |
stevensc |
1 |
import React from 'react'
|
|
|
2 |
import { Link } from 'react-router-dom'
|
|
|
3 |
import { useSelector } from 'react-redux'
|
|
|
4 |
import { Typography } from '@mui/material'
|
|
|
5 |
|
|
|
6 |
import { TopicContainer, TopicProgress, TopicsGrid } from './UI'
|
|
|
7 |
import EmptySection from 'components/UI/EmptySection'
|
|
|
8 |
|
|
|
9 |
const Topics = () => {
|
|
|
10 |
const topics = useSelector(({ microlearning }) =>
|
|
|
11 |
microlearning.topicsAllIds.map(
|
|
|
12 |
(topicId) => microlearning.topicById[topicId]
|
|
|
13 |
)
|
|
|
14 |
)
|
|
|
15 |
const labels = useSelector(({ intl }) => intl.labels)
|
|
|
16 |
|
|
|
17 |
return (
|
|
|
18 |
<TopicsGrid>
|
|
|
19 |
{topics.length ? (
|
|
|
20 |
topics.map((topic) => <Topic key={topic.uuid} topic={topic} />)
|
|
|
21 |
) : (
|
|
|
22 |
<EmptySection message={labels.datatable_szerorecords} />
|
|
|
23 |
)}
|
|
|
24 |
</TopicsGrid>
|
|
|
25 |
)
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
const Topic = ({ topic }) => {
|
|
|
29 |
const { name, image, progress, uuid } = topic
|
|
|
30 |
|
|
|
31 |
return (
|
|
|
32 |
<Link to={`${uuid}/capsules`}>
|
|
|
33 |
<TopicContainer>
|
|
|
34 |
<div className='c-header'>
|
|
|
35 |
<Typography variant='h3'>{name}</Typography>
|
|
|
36 |
</div>
|
|
|
37 |
|
|
|
38 |
<img src={image} alt='' loading='lazy' />
|
|
|
39 |
|
|
|
40 |
<div className='c-footer'>
|
|
|
41 |
<TopicProgress variant='determinate' value={progress} />
|
|
|
42 |
|
|
|
43 |
<span>{`${progress}%`}</span>
|
|
|
44 |
</div>
|
|
|
45 |
</TopicContainer>
|
|
|
46 |
</Link>
|
|
|
47 |
)
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
export default Topics
|