From af7f9b0a4183ba789435d0bd901c3970adaebea9 Mon Sep 17 00:00:00 2001 From: jtmst Date: Mon, 29 Jan 2024 09:33:00 -0500 Subject: [PATCH 1/3] Fix AudienceTopics styles and add types --- src/data/queries/audienceTopics.ts | 13 ++++++++++--- src/templates/components/audienceTopics/index.tsx | 5 +++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/data/queries/audienceTopics.ts b/src/data/queries/audienceTopics.ts index 43cae580c..f56c30c89 100644 --- a/src/data/queries/audienceTopics.ts +++ b/src/data/queries/audienceTopics.ts @@ -3,14 +3,21 @@ import { ParagraphAudienceTopics } from '@/types/drupal/paragraph' import { QueryFormatter } from 'next-drupal-query' import { AudienceTopic } from '@/types/formatted/audienceTopics' -const getTagsList = (fieldTags) => { - if (!fieldTags) return null +interface Tag { + id: string + href: string | undefined + name: string + categoryLabel: string +} + +const getTagsList = (entity: ParagraphAudienceTopics): Tag[] | null => { + if (!entity) return null const { field_topics: fieldTopics = [], field_audience_beneficiares: fieldAudienceBeneficiares, fieldNonBeneficiares: fieldNonBeneficiares, - } = fieldTags + } = entity const topics = fieldTopics.map((topic) => ({ id: topic.id, diff --git a/src/templates/components/audienceTopics/index.tsx b/src/templates/components/audienceTopics/index.tsx index 1f41efa2a..b70e59124 100644 --- a/src/templates/components/audienceTopics/index.tsx +++ b/src/templates/components/audienceTopics/index.tsx @@ -6,10 +6,11 @@ export function AudienceTopics({ tags }: FormattedAudienceTopics) { if (isEmpty(tags)) return null const tagsList = tags.map(({ id, href, name }) => (
-
+
{name} From 66aa81f0bdc40290b41707eac07cd9de2c6abd92 Mon Sep 17 00:00:00 2001 From: jtmst Date: Tue, 30 Jan 2024 11:52:44 -0500 Subject: [PATCH 2/3] pr feedback --- src/data/queries/audienceTopics.ts | 11 +++-------- src/templates/components/audienceTopics/index.tsx | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/data/queries/audienceTopics.ts b/src/data/queries/audienceTopics.ts index f56c30c89..9d89484b5 100644 --- a/src/data/queries/audienceTopics.ts +++ b/src/data/queries/audienceTopics.ts @@ -3,14 +3,9 @@ import { ParagraphAudienceTopics } from '@/types/drupal/paragraph' import { QueryFormatter } from 'next-drupal-query' import { AudienceTopic } from '@/types/formatted/audienceTopics' -interface Tag { - id: string - href: string | undefined - name: string - categoryLabel: string -} - -const getTagsList = (entity: ParagraphAudienceTopics): Tag[] | null => { +const getTagsList = ( + entity: ParagraphAudienceTopics +): AudienceTopic[] | null => { if (!entity) return null const { diff --git a/src/templates/components/audienceTopics/index.tsx b/src/templates/components/audienceTopics/index.tsx index b70e59124..5ba3fc9aa 100644 --- a/src/templates/components/audienceTopics/index.tsx +++ b/src/templates/components/audienceTopics/index.tsx @@ -8,7 +8,7 @@ export function AudienceTopics({ tags }: FormattedAudienceTopics) {
From cced14b0d69bb4e97d8b9292d22f019f39a809c9 Mon Sep 17 00:00:00 2001 From: jtmst Date: Tue, 30 Jan 2024 12:02:59 -0500 Subject: [PATCH 3/3] href fix --- src/templates/components/audienceTopics/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/components/audienceTopics/index.tsx b/src/templates/components/audienceTopics/index.tsx index 5ba3fc9aa..e66dee378 100644 --- a/src/templates/components/audienceTopics/index.tsx +++ b/src/templates/components/audienceTopics/index.tsx @@ -8,7 +8,7 @@ export function AudienceTopics({ tags }: FormattedAudienceTopics) {