import Spinner from '@components/Spinner/Spinner'; import { ExpandableWidget, List } from '@components/WidgetParts'; import { getAllTopics } from '@services/graphql/queries'; import { TitleLevel } from '@ts/types/app'; import Link from 'next/link'; import { useRouter } from 'next/router'; import { useIntl } from 'react-intl'; import useSWR from 'swr'; const TopicsList = ({ title, titleLevel, }: { title: string; titleLevel?: TitleLevel; }) => { const intl = useIntl(); const router = useRouter(); const isTopic = () => router.asPath.includes('/sujet/'); const currentTopicSlug = isTopic() ? router.asPath.replace('/sujet/', '') : ''; const { data, error } = useSWR('/api/topics', getAllTopics); const getList = () => { if (error) return ( ); if (!data) return ( ); const topics = data.map((topic) => { return currentTopicSlug !== topic.slug ? (
  • {topic.title}
  • ) : ( '' ); }); return ; }; return ( {getList()} ); }; export default TopicsList;