From 3cfaf7eb8510a816c24502d656cd5cb974add3ad Mon Sep 17 00:00:00 2001 From: timwessman Date: Mon, 11 Mar 2024 14:36:59 +0200 Subject: [PATCH] fix: try Finnish resource name if the desired language is not available --- src/components/resource-title/ResourceTitle.tsx | 1 + src/pages/ResourceBatchUpdatePage.tsx | 4 ++-- src/pages/ResourcePage.tsx | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/resource-title/ResourceTitle.tsx b/src/components/resource-title/ResourceTitle.tsx index 45eb3259..5815dbd1 100644 --- a/src/components/resource-title/ResourceTitle.tsx +++ b/src/components/resource-title/ResourceTitle.tsx @@ -25,6 +25,7 @@ const ResourceTitle = ({ const title = useRef(null); const name = resource?.name[language] || + resource?.name?.fi || displayLangVersionNotFound({ language, label: `${ diff --git a/src/pages/ResourceBatchUpdatePage.tsx b/src/pages/ResourceBatchUpdatePage.tsx index ded0c6ec..161a9e87 100644 --- a/src/pages/ResourceBatchUpdatePage.tsx +++ b/src/pages/ResourceBatchUpdatePage.tsx @@ -274,12 +274,12 @@ const ResourceBatchUpdatePage = ({ .filter((r) => r.resource) .map((r) => ({ id: r.id, - name: r?.resource?.name[language], + name: r?.resource?.name[language] || r?.resource?.name?.fi, })); const newData = { mainResourceId: resource.id, - mainResourceName: resource?.name[language], + mainResourceName: resource?.name[language] || resource?.name.fi, targetResources, }; diff --git a/src/pages/ResourcePage.tsx b/src/pages/ResourcePage.tsx index ca31525b..950077c8 100644 --- a/src/pages/ResourcePage.tsx +++ b/src/pages/ResourcePage.tsx @@ -97,7 +97,7 @@ const ResourcePage = ({ const targetResourceIDs = targetResourcesString.split(','); const newData = { mainResourceId: resource.id, - mainResourceName: resource?.name[language], + mainResourceName: resource?.name[language] || resource?.name?.fi, targetResources: targetResourceIDs.map((id) => ({ id, name: '', @@ -244,6 +244,7 @@ const ResourcePage = ({ href={`/resource/${parentResource.id}`} text={ parentResource?.name[language] || + parentResource?.name?.fi || displayLangVersionNotFound({ language, label: 'toimipisteen nimi', @@ -279,6 +280,7 @@ const ResourcePage = ({ language={language} heading={ childResource?.name[language] || + childResource?.name?.fi || displayLangVersionNotFound({ language, label: 'alakohteen nimi',