Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3659 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
3719 stevensc 1
import React from 'react';
2
import { useParams } from 'react-router-dom';
3
import { Link } from 'react-router-dom';
4
 
5
import { useAlert, useApi } from '@shared/hooks';
6
import { getTopic } from '@microlearning/services';
7
 
8
import { Grid, PageHeader, Spinner } from '@shared/components';
9
import { CapsuleCard } from '@microlearning/components';
10
 
11
export function TopicPage() {
12
  const { uuid } = useParams();
13
 
14
  const { showError } = useAlert();
15
 
16
  const { data: topic, loading } = useApi(getTopic, {
17
    autoFetch: true,
18
    autoFetchArgs: [uuid],
19
    onError: (error) => {
20
      showError(error.message);
21
    }
22
  });
23
 
24
  if (loading || !topic) return <Spinner />;
25
 
26
  return (
27
    <>
28
      <PageHeader title={`${topic?.name} - Cápsulas`} goBack />
29
      <Grid
30
        items={topic.capsules}
31
        emptyMessage='No hay cápsulas para mostrar'
32
        renderItem={(capsule) => (
33
          <Link to={`/microlearning/capsules/${capsule.uuid}`}>
34
            <CapsuleCard capsule={capsule} />
35
          </Link>
36
        )}
37
        keyExtractor={(capsule) => capsule.uuid}
38
      />
39
    </>
40
  );
41
}