Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3527 | Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
3481 stevensc 1
import React from 'react'
2
import { useSelector } from 'react-redux'
3
import { Link } from 'react-router-dom'
4
import { Typography } from '@mui/material'
5
 
6
import { useMicroLearning, useFetch } from '@hooks'
7
 
8
import { TopicContainer, TopicsGrid } from './UI'
9
import Spinner from '@components/UI/Spinner'
10
import EmptySection from '@components/UI/EmptySection'
11
 
12
const Companies = () => {
13
  const { link_companies: linkCompanies } = useMicroLearning()
14
  const { data: companies, isLoading } = useFetch(linkCompanies, [])
15
  const labels = useSelector(({ intl }) => intl.labels)
16
 
17
  if (isLoading) {
18
    return <Spinner />
19
  }
20
 
21
  return (
22
    <TopicsGrid>
23
      {companies.length ? (
24
        companies.map((company) => (
25
          <Company key={company.uuid} company={company} />
26
        ))
27
      ) : (
28
        <EmptySection message={labels.datatable_szerorecords} />
29
      )}
30
    </TopicsGrid>
31
  )
32
}
33
 
34
const Company = ({ company }) => {
35
  const { name, image, uuid } = company
36
 
37
  return (
38
    <Link to={uuid}>
39
      <TopicContainer>
40
        <div className='c-header'>
41
          <Typography variant='h3'>{name}</Typography>
42
        </div>
43
        <div className='c-body'>
44
          <img src={image} alt='' />
45
        </div>
46
      </TopicContainer>
47
    </Link>
48
  )
49
}
50
 
51
export default Companies