Skip to content

Commit

Permalink
Use values instead of key number 0
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnarvelle committed Nov 20, 2024
1 parent cf59f49 commit 1781a13
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/utils/apiHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 ?? "",
Expand Down

0 comments on commit 1781a13

Please sign in to comment.