From 1781a13339318b001c969cb9d0ca391fc6f0d14b Mon Sep 17 00:00:00 2001 From: Gunnar Velle Date: Wed, 20 Nov 2024 09:54:22 +0100 Subject: [PATCH] Use values instead of key number 0 --- src/utils/apiHelpers.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/utils/apiHelpers.ts b/src/utils/apiHelpers.ts index 05cd3bbd..7378017c 100644 --- a/src/utils/apiHelpers.ts +++ b/src/utils/apiHelpers.ts @@ -196,8 +196,10 @@ export const nodeToTaxonomyEntity = (node: Node, context: ContextWithLoaders): G }; const toGQLTaxonomyContext = (ctx: TaxonomyContext, name: string, context: ContextWithLoaders): GQLTaxonomyContext => { - const breadcrumbs = ctx.breadcrumbs[context.language] || ctx.breadcrumbs[defaultLanguage] || ctx.breadcrumbs[0]; - const relevance = ctx.relevance[context.language] || ctx.relevance[defaultLanguage] || ctx.relevance[0]; + const breadcrumbs = + ctx.breadcrumbs[context.language] || ctx.breadcrumbs[defaultLanguage] || Object.values(ctx.breadcrumbs)[0]; + const relevance = + ctx.relevance[context.language] || ctx.relevance[defaultLanguage] || Object.values(ctx.relevance)[0]; const url = ctx.url || ctx.path; const parents = ctx.parents.map((parent) => toGQLTaxonomyCrumb(parent, context)); return { @@ -211,7 +213,7 @@ const toGQLTaxonomyContext = (ctx: TaxonomyContext, name: string, context: Conte }; const toGQLTaxonomyCrumb = (crumb: TaxonomyCrumb, context: ContextWithLoaders): GQLTaxonomyCrumb => { - const name = crumb.name[context.language] || crumb.name[defaultLanguage] || crumb.name[0]; + const name = crumb.name[context.language] || crumb.name[defaultLanguage] || Object.values(crumb.name)[0]; return { ...crumb, name: name ?? "",