Skip to content

Commit

Permalink
fix: try Finnish resource name if the desired language is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
timwessman committed Mar 11, 2024
1 parent 4157bd1 commit 3cfaf7e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/components/resource-title/ResourceTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const ResourceTitle = ({
const title = useRef<HTMLHeadingElement>(null);
const name =
resource?.name[language] ||
resource?.name?.fi ||
displayLangVersionNotFound({
language,
label: `${
Expand Down
4 changes: 2 additions & 2 deletions src/pages/ResourceBatchUpdatePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
4 changes: 3 additions & 1 deletion src/pages/ResourcePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
Expand Down Expand Up @@ -244,6 +244,7 @@ const ResourcePage = ({
href={`/resource/${parentResource.id}`}
text={
parentResource?.name[language] ||
parentResource?.name?.fi ||
displayLangVersionNotFound({
language,
label: 'toimipisteen nimi',
Expand Down Expand Up @@ -279,6 +280,7 @@ const ResourcePage = ({
language={language}
heading={
childResource?.name[language] ||
childResource?.name?.fi ||
displayLangVersionNotFound({
language,
label: 'alakohteen nimi',
Expand Down

0 comments on commit 3cfaf7e

Please sign in to comment.