Skip to content

Commit e7b1f7f

Browse files
committed
asiasanahaku -> asiasanat, ä oikeaan paikkaan listauksessa
1 parent 4d9d769 commit e7b1f7f

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

frontend/src/components/KeywordListBase.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import axios from 'axios'
2-
import { useEffect, useState } from 'react'
2+
import { useEffect, useMemo, useState } from 'react'
33
import { Helmet } from 'react-helmet'
44
import TopMenu from './TopMenu'
55
import type { KeysType, KeywordPageType } from '../types'
@@ -53,6 +53,18 @@ const KeywordListBase = ({ language, apiBasePath, routeBasePath }: KeywordListBa
5353
getKeywords(path)
5454
}, [path])
5555

56+
57+
const sortedKeywords = useMemo(() => {
58+
const collator = new Intl.Collator('fi', {
59+
usage: 'sort',
60+
sensitivity: 'base',
61+
ignorePunctuation: true,
62+
numeric: false
63+
})
64+
65+
return [...keywords].sort((a, b) => collator.compare(a.keyword, b.keyword))
66+
}, [keywords])
67+
5668
function prepareLink(keyword_id: string) {
5769
return `${routeBasePath}/${encodeURIComponent(keyword_id)}`
5870
}
@@ -77,8 +89,8 @@ const KeywordListBase = ({ language, apiBasePath, routeBasePath }: KeywordListBa
7789
<div style={contentStyle} id="contentdiv">
7890
<div id="contentDiv" style={contentContainerStyle}>
7991
<h1>{title}</h1>
80-
{Array.isArray(keywords) && keywords.map(keyword => {
81-
const firstLetter = keyword.keyword.charAt(0).toUpperCase()
92+
{Array.isArray(sortedKeywords) && sortedKeywords.map(keyword => {
93+
const firstLetter = keyword.keyword.charAt(0).toLocaleUpperCase('fi')
8294
const letterChanged = firstLetter !== letter
8395
letter = firstLetter
8496
return (
@@ -96,4 +108,4 @@ const KeywordListBase = ({ language, apiBasePath, routeBasePath }: KeywordListBa
96108
)
97109
}
98110

99-
export default KeywordListBase
111+
export default KeywordListBase

frontend/src/components/ListDocumentPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,12 @@ const ListDocumentPage = ({language, setLanguage, buttonetext, placeholdertext,
174174
/>
175175
{apisection === 'statute' && (
176176
<a href="/lainsaadanto/asiasanat" style={keywordLinkStyle}>
177-
{language === 'fin' ? 'Asiasanahaku' : 'Ämnesordssökning'}
177+
{language === 'fin' ? 'Asiasanat' : 'Ämnesords'}
178178
</a>
179179
)}
180180
{apisection === 'judgment' && (
181181
<a href="/oikeuskaytanto/asiasanat" style={keywordLinkStyle}>
182-
{language === 'fin' ? 'Asiasanahaku' : 'Ämnesordssökning'}
182+
{language === 'fin' ? 'Asiasanat' : 'Ämnesords'}
183183
</a>
184184
)}
185185
<div id="errorblock">

0 commit comments

Comments
 (0)