From bc1159f4f61c8c1139e007091b3abd7096259a64 Mon Sep 17 00:00:00 2001 From: Terje Karlsen Date: Tue, 4 Feb 2025 13:55:13 +0100 Subject: [PATCH 1/3] Implementerer bedre defauting og optional chaining --- src/components/_common/headers/sharedHeaderUtils.ts | 2 +- .../overview-filters/taxonomy-filter/OverviewTaxonomyFilter.tsx | 2 +- src/store/hooks/useOverviewFilters.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/_common/headers/sharedHeaderUtils.ts b/src/components/_common/headers/sharedHeaderUtils.ts index 27e60c98a..d503e510b 100644 --- a/src/components/_common/headers/sharedHeaderUtils.ts +++ b/src/components/_common/headers/sharedHeaderUtils.ts @@ -24,7 +24,7 @@ export const getContentTagline = (content: GetContentTaglineProps, currentLangua return (selectedAudience && situationTaglines(selectedAudience)) ?? ''; } - if (taxonomy.length > 0 || customCategory) { + if ((taxonomy && taxonomy.length > 0) || customCategory) { const taxonomyStrings = getTranslatedTaxonomies(taxonomy, language); if (customCategory && taxonomyStrings.length === 0) { diff --git a/src/components/_common/overview-filters/taxonomy-filter/OverviewTaxonomyFilter.tsx b/src/components/_common/overview-filters/taxonomy-filter/OverviewTaxonomyFilter.tsx index 276132d91..31405b8c2 100644 --- a/src/components/_common/overview-filters/taxonomy-filter/OverviewTaxonomyFilter.tsx +++ b/src/components/_common/overview-filters/taxonomy-filter/OverviewTaxonomyFilter.tsx @@ -54,7 +54,7 @@ export const OverviewTaxonomyFilter = ({ items }: Props) => { }; const taxonomiesPresent = orderedTaxonomies.filter((taxonomy) => - items.some((item) => item.taxonomy.some((itemTaxonomy) => itemTaxonomy === taxonomy)) + items.some((item) => item.taxonomy?.some((itemTaxonomy) => itemTaxonomy === taxonomy)) ); const listHasGuidePage = items.some((product) => product.type === 'no.nav.navno:guide-page'); diff --git a/src/store/hooks/useOverviewFilters.ts b/src/store/hooks/useOverviewFilters.ts index 1bbe5925d..f44c713b2 100644 --- a/src/store/hooks/useOverviewFilters.ts +++ b/src/store/hooks/useOverviewFilters.ts @@ -43,7 +43,7 @@ const _getFilteredList = async ({ const isTaxonomyMatching = (item: ItemType) => taxonomyFilter === ProductTaxonomy.ALL || - item.taxonomy.includes(taxonomyFilter) || + item.taxonomy?.includes(taxonomyFilter) || (taxonomyFilter === ProductTaxonomy.OTHER && item.type === 'no.nav.navno:guide-page'); const itemsMatchingToggleFilters = filterableItems.filter( From 844ea7d746a66b535a9bf597a91cbe31395d858f Mon Sep 17 00:00:00 2001 From: Terje Karlsen Date: Tue, 4 Feb 2025 13:57:31 +0100 Subject: [PATCH 2/3] Implementerer bedre defauting og optional chaining --- src/store/hooks/useOverviewFilters.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/hooks/useOverviewFilters.ts b/src/store/hooks/useOverviewFilters.ts index f44c713b2..5dfea71c6 100644 --- a/src/store/hooks/useOverviewFilters.ts +++ b/src/store/hooks/useOverviewFilters.ts @@ -16,7 +16,7 @@ import type Fuse from 'fuse.js'; export type OverviewFilterableItem = { area: Area[]; - taxonomy: ProductTaxonomy[]; + taxonomy?: ProductTaxonomy[]; type?: ContentType; }; From ed27b88d6b2d000ab9c122d79ae57e49af7270bb Mon Sep 17 00:00:00 2001 From: Terje Karlsen Date: Tue, 4 Feb 2025 14:17:27 +0100 Subject: [PATCH 3/3] Optional chaining for beliggenhet i kontorer. --- .../office-details/officeInformation/OfficeInformation.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/pages/office-page/office-details/officeInformation/OfficeInformation.tsx b/src/components/pages/office-page/office-details/officeInformation/OfficeInformation.tsx index 2397cee1a..dbf3ebc97 100644 --- a/src/components/pages/office-page/office-details/officeInformation/OfficeInformation.tsx +++ b/src/components/pages/office-page/office-details/officeInformation/OfficeInformation.tsx @@ -54,7 +54,7 @@ export const OfficeInformation = ({ officeData }: OfficeInformationProps) => { {getOfficeTranslations('location')} - {beliggenhet.adresseTilleggsnavn && ( + {beliggenhet?.adresseTilleggsnavn && ( {beliggenhet.adresseTilleggsnavn} )} {visitingAddress}