diff --git a/frontend/src/pages/help/HelpListPage.tsx b/frontend/src/pages/help/HelpListPage.tsx index 2a3a91d..60acb6d 100644 --- a/frontend/src/pages/help/HelpListPage.tsx +++ b/frontend/src/pages/help/HelpListPage.tsx @@ -13,7 +13,6 @@ import type { FormEvent, FC } from 'react' import type { HelpSearchEntry } from '@/lib/help' - type SearchConditions = { title: string; text: string } @@ -28,19 +27,23 @@ const HelpSearchPage: FC = () => { useEffect (() => { let active = true - void getHelpSearchEntries ('ja') - .then (data => { + void (async () => { + try + { if (active) - setEntries (data) - }) - .catch (err => { + setEntries (await getHelpSearchEntries ('ja')) + } + catch (err) + { if (active) setError (err instanceof Error ? err.message : '取得に失敗しました.') - }) - .finally (() => { + } + finally + { if (active) setLoading (false) - }) + } + }) () return () => { active = false } }, []) @@ -49,10 +52,13 @@ const HelpSearchPage: FC = () => { const titleQuery = conditions.title.trim ().normalize ('NFKC').toLowerCase () const textQuery = conditions.text.trim ().normalize ('NFKC').toLowerCase () - return entries.filter (entry => ( - (!(titleQuery) || entry.title.normalize ('NFKC').toLowerCase ().includes (titleQuery)) - && (!(textQuery) || entry.body.normalize ('NFKC').toLowerCase ().includes (textQuery)))) - .sort ((a, b) => a.title.localeCompare (b.title, 'ja')) + return ( + entries.filter (entry => ( + (!(titleQuery) + || entry.title.normalize ('NFKC').toLowerCase ().includes (titleQuery)) + && (!(textQuery) + || entry.body.normalize ('NFKC').toLowerCase ().includes (textQuery)))) + .sort ((a, b) => a.title.localeCompare (b.title, 'ja'))) }, [entries, conditions]) const handleSearch = (ev: FormEvent) => { @@ -63,7 +69,7 @@ const HelpSearchPage: FC = () => { return ( - {`ヘルプ | ${SITE_TITLE}`} + {`ヘルプ | ${ SITE_TITLE }`}