Proyectos de Subversion LeadersLinked - SPA

Rev

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

import React from 'react';
import { Link } from 'react-router-dom';

import { useAlert, useApi } from '@shared/hooks';
import { getTopics } from '@microlearning/services';

import { Grid, PageHeader, Spinner } from '@shared/components';
import { TopicCard } from '@microlearning/components';

export function TopicsPage() {
  const { showError } = useAlert();

  const { data: topics, loading } = useApi(getTopics, {
    autoFetch: true,
    onError: (error) => {
      showError(error.message);
    }
  });

  if (loading || !topics) return <Spinner />;

  return (
    <>
      <PageHeader title='Tópicos' />
      <Grid
        items={topics}
        emptyMessage='No hay tópicos para mostrar'
        renderItem={(topic) => (
          <Link to={topic.uuid}>
            <TopicCard topic={topic} />
          </Link>
        )}
        keyExtractor={(topic) => topic.uuid}
      />
    </>
  );
}