Proyectos de Subversion LeadersLinked - SPA

Rev

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

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