Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3661 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 3661 Rev 3719
Línea 1... Línea 1...
1
import React from 'react';
1
import React from 'react';
2
import { Link } from 'react-router-dom';
2
import { Link } from 'react-router-dom';
3
 
3
 
4
import { useAlert, useApi } from '@shared/hooks';
4
import { useAlert, useApi } from '@shared/hooks';
5
import { getCompanies } from '@microlearning/services';
5
import { getCompanies } from '@microlearning/services';
6
 
6
 
7
import { PageHeader, Spinner, Grid } from '@shared/components';
7
import { PageHeader, Spinner, Grid } from '@shared/components';
8
import { CompanyItem } from '@microlearning/components';
8
import { CompanyItem } from '@microlearning/components';
9
 
9
 
10
export function CompaniesPage() {
10
export function CompaniesPage() {
11
  const { showError } = useAlert();
11
  const { showError } = useAlert();
12
 
12
 
13
  const { data: companies, loading } = useApi(getCompanies, {
13
  const { data: companies, loading } = useApi(getCompanies, {
14
    autoFetch: true,
14
    autoFetch: true,
15
    onError: (error) => {
15
    onError: (error) => {
16
      showError(error.message);
16
      showError(error.message);
17
    }
17
    }
18
  });
18
  });
19
 
19
 
20
  if (loading) return <Spinner />;
20
  if (loading) return <Spinner />;
21
 
21
 
22
  return (
22
  return (
23
    <>
23
    <>
24
      <PageHeader title='Compañias' />
24
      <PageHeader title='Compañias' />
25
      <Grid
25
      <Grid
26
        items={companies}
26
        items={companies}
27
        renderItem={(company) => (
27
        renderItem={(company) => (
28
          <Link to={company.uuid}>
28
          <Link to={company.uuid}>
29
            <CompanyItem company={company} />
29
            <CompanyItem company={company} />
30
          </Link>
30
          </Link>
31
        )}
31
        )}
32
        keyExtractor={(company) => company.uuid}
32
        keyExtractor={(company) => company.uuid}
33
        emptyMessage='No hay compañias para mostrar'
33
        emptyMessage='No hay compañias para mostrar'
34
      />
34
      />
35
    </>
35
    </>
36
  );
36
  );
37
}
37
}