diff options
Diffstat (limited to 'src/components/Widgets/ThematicsList')
| -rw-r--r-- | src/components/Widgets/ThematicsList/ThematicsList.tsx | 38 | 
1 files changed, 24 insertions, 14 deletions
| diff --git a/src/components/Widgets/ThematicsList/ThematicsList.tsx b/src/components/Widgets/ThematicsList/ThematicsList.tsx index 8523bd1..e5162b4 100644 --- a/src/components/Widgets/ThematicsList/ThematicsList.tsx +++ b/src/components/Widgets/ThematicsList/ThematicsList.tsx @@ -1,3 +1,4 @@ +import Spinner from '@components/Spinner/Spinner';  import { ExpandableWidget, List } from '@components/WidgetParts';  import { t } from '@lingui/macro';  import { getAllThematics } from '@services/graphql/queries'; @@ -21,24 +22,33 @@ const ThematicsList = ({    const { data, error } = useSWR('/api/thematics', getAllThematics); -  if (error) return <div>{t`Failed to load.`}</div>; -  if (!data) return <div>{t`Loading...`}</div>; +  const getList = () => { +    if (error) return <ul>{t`Failed to load.`}</ul>; +    if (!data) +      return ( +        <ul> +          <Spinner /> +        </ul> +      ); -  const thematics = data.map((thematic) => { -    return currentThematicSlug !== thematic.slug ? ( -      <li key={thematic.databaseId}> -        <Link href={`/thematique/${thematic.slug}`}> -          <a>{thematic.title}</a> -        </Link> -      </li> -    ) : ( -      '' -    ); -  }); +    const thematics = data.map((thematic) => { +      return currentThematicSlug !== thematic.slug ? ( +        <li key={thematic.databaseId}> +          <Link href={`/thematique/${thematic.slug}`}> +            <a>{thematic.title}</a> +          </Link> +        </li> +      ) : ( +        '' +      ); +    }); + +    return <List items={thematics} />; +  };    return (      <ExpandableWidget title={title} titleLevel={titleLevel} withBorders={true}> -      <List items={thematics} /> +      {getList()}      </ExpandableWidget>    );  }; | 
