import { t } from '@lingui/macro'; import { getAllSubjects } from '@services/graphql/queries'; import Link from 'next/link'; import useSWR from 'swr'; import styles from '../Widget.module.scss'; const TopicsList = () => { const { data, error } = useSWR('/api/subjects', getAllSubjects); if (error) return
{t`Failed to load.`}
; if (!data) return
{t`Loading...`}
; const sortedSubjects = [...data].sort((a, b) => a.title.localeCompare(b.title) ); const subjects = sortedSubjects.map((subject) => { return (
  • {subject.title}
  • ); }); return (

    {t`Topics`}

    ); }; export default TopicsList;