diff options
Diffstat (limited to 'src/components/Widgets')
4 files changed, 14 insertions, 26 deletions
diff --git a/src/components/Widgets/RelatedThematics/RelatedThematics.tsx b/src/components/Widgets/RelatedThematics/RelatedThematics.tsx index e89d887..74325bb 100644 --- a/src/components/Widgets/RelatedThematics/RelatedThematics.tsx +++ b/src/components/Widgets/RelatedThematics/RelatedThematics.tsx @@ -21,6 +21,7 @@ const RelatedThematics = ({ thematics }: { thematics: ThematicPreview[] }) => { return ( <ExpandableWidget + expand={true} title={intl.formatMessage( { defaultMessage: @@ -31,12 +32,6 @@ const RelatedThematics = ({ thematics }: { thematics: ThematicPreview[] }) => { )} withBorders={true} > - <noscript> - {intl.formatMessage({ - defaultMessage: 'Javascript is required to load the thematics.', - description: 'RelatedThematics: noscript tag', - })} - </noscript> <List items={thematicsList} /> </ExpandableWidget> ); diff --git a/src/components/Widgets/RelatedTopics/RelatedTopics.tsx b/src/components/Widgets/RelatedTopics/RelatedTopics.tsx index e225608..1702e82 100644 --- a/src/components/Widgets/RelatedTopics/RelatedTopics.tsx +++ b/src/components/Widgets/RelatedTopics/RelatedTopics.tsx @@ -21,6 +21,7 @@ const RelatedTopics = ({ topics }: { topics: TopicPreview[] }) => { return ( <ExpandableWidget + expand={true} title={intl.formatMessage( { defaultMessage: @@ -31,12 +32,6 @@ const RelatedTopics = ({ topics }: { topics: TopicPreview[] }) => { )} withBorders={true} > - <noscript> - {intl.formatMessage({ - defaultMessage: 'Javascript is required to load the topics.', - description: 'RelatedTopics: noscript tag', - })} - </noscript> <List items={topicsList} /> </ExpandableWidget> ); diff --git a/src/components/Widgets/ThematicsList/ThematicsList.tsx b/src/components/Widgets/ThematicsList/ThematicsList.tsx index f175e80..f50a069 100644 --- a/src/components/Widgets/ThematicsList/ThematicsList.tsx +++ b/src/components/Widgets/ThematicsList/ThematicsList.tsx @@ -2,6 +2,7 @@ import Spinner from '@components/Spinner/Spinner'; import { ExpandableWidget, List } from '@components/WidgetParts'; import { getAllThematics } from '@services/graphql/queries'; import { TitleLevel } from '@ts/types/app'; +import { ThematicPreview } from '@ts/types/taxonomies'; import Link from 'next/link'; import { useRouter } from 'next/router'; import { useIntl } from 'react-intl'; @@ -10,9 +11,11 @@ import useSWR from 'swr'; const ThematicsList = ({ title, titleLevel, + initialData, }: { title: string; titleLevel?: TitleLevel; + initialData?: ThematicPreview[]; }) => { const intl = useIntl(); const router = useRouter(); @@ -21,7 +24,9 @@ const ThematicsList = ({ ? router.asPath.replace('/thematique/', '') : ''; - const { data, error } = useSWR('/api/thematics', getAllThematics); + const { data, error } = useSWR('/api/thematics', getAllThematics, { + fallbackData: initialData, + }); const getList = () => { if (error) @@ -62,12 +67,6 @@ const ThematicsList = ({ withBorders={true} expand={true} > - <noscript> - {intl.formatMessage({ - defaultMessage: 'Javascript is required to load the thematics.', - description: 'ThematicsList: noscript tag', - })} - </noscript> {getList()} </ExpandableWidget> ); diff --git a/src/components/Widgets/TopicsList/TopicsList.tsx b/src/components/Widgets/TopicsList/TopicsList.tsx index e79d1a8..55bf5af 100644 --- a/src/components/Widgets/TopicsList/TopicsList.tsx +++ b/src/components/Widgets/TopicsList/TopicsList.tsx @@ -2,6 +2,7 @@ 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 { TopicPreview } from '@ts/types/taxonomies'; import Link from 'next/link'; import { useRouter } from 'next/router'; import { useIntl } from 'react-intl'; @@ -10,9 +11,11 @@ import useSWR from 'swr'; const TopicsList = ({ title, titleLevel, + initialData, }: { title: string; titleLevel?: TitleLevel; + initialData?: TopicPreview[]; }) => { const intl = useIntl(); const router = useRouter(); @@ -21,7 +24,9 @@ const TopicsList = ({ ? router.asPath.replace('/sujet/', '') : ''; - const { data, error } = useSWR('/api/topics', getAllTopics); + const { data, error } = useSWR('/api/topics', getAllTopics, { + fallbackData: initialData, + }); const getList = () => { if (error) @@ -62,12 +67,6 @@ const TopicsList = ({ withBorders={true} expand={true} > - <noscript> - {intl.formatMessage({ - defaultMessage: 'Javascript is required to load the topics.', - description: 'TopicsList: noscript tag', - })} - </noscript> {getList()} </ExpandableWidget> ); |
