-
+
setSuggestionsVsbl (true)}
+ onBlur={() => setSuggestionsVsbl (false)}
+ onKeyDown={handleKeyDown} />
検索
新規
全体履歴
diff --git a/frontend/src/consts.ts b/frontend/src/consts.ts
new file mode 100644
index 0000000..4b3e57b
--- /dev/null
+++ b/frontend/src/consts.ts
@@ -0,0 +1,9 @@
+export const CATEGORIES = ['general',
+ 'character',
+ 'deerjikist',
+ 'meme',
+ 'material',
+ 'nico',
+ 'meta'] as const
+
+export const USER_ROLES = ['admin', 'member', 'guest'] as const
diff --git a/frontend/src/pages/WikiDetailPage.tsx b/frontend/src/pages/WikiDetailPage.tsx
index a07e595..9a34762 100644
--- a/frontend/src/pages/WikiDetailPage.tsx
+++ b/frontend/src/pages/WikiDetailPage.tsx
@@ -27,18 +27,21 @@ export default () => {
setMarkdown (res.data.body)
WikiIdBus.set (res.data.id)
})
- .catch (() => setMarkdown (null)))
+ .catch (() => setMarkdown ('')))
}, [name])
return (
-
(['/', '.'].some (e => href?.startsWith (e))
- ? {children}
- : {children})) }}>
- {markdown || `このページは存在しません。[新規作成してください](/wiki/new?title=${ name })。`}
-
+ {markdown == null ? 'Loading...' : (
+ <>
+
(['/', '.'].some (e => href?.startsWith (e))
+ ? {children}
+ : {children})) }}>
+ {markdown || `このページは存在しません。[新規作成してください](/wiki/new?title=${ name })。`}
+
+ >)}
)
}
diff --git a/frontend/src/pages/WikiPage.tsx b/frontend/src/pages/WikiPage.tsx
new file mode 100644
index 0000000..f76af57
--- /dev/null
+++ b/frontend/src/pages/WikiPage.tsx
@@ -0,0 +1,88 @@
+import React, { useEffect, useState } from 'react'
+import { Link } from 'react-router-dom'
+import axios from 'axios'
+import MainArea from '@/components/layout/MainArea'
+import { API_BASE_URL } from '@/config'
+
+import type { Category, WikiPage } from '@/types'
+
+
+export default () => {
+ const [title, setTitle] = useState ('')
+ const [text, setText] = useState ('')
+ const [category, setCategory] = useState
(null)
+ const [results, setResults] = useState ([])
+
+ const search = () => {
+ void (axios.get (`${ API_BASE_URL }/wiki/search`, { params: { title } })
+ .then (res => setResults (res.data)))
+ }
+
+ const handleSearch = (e: React.FormEvent) => {
+ e.preventDefault ()
+ search ()
+ }
+
+ useEffect (() => {
+ search ()
+ }, [])
+
+ return (
+
+
+
+
+
+
+
+ タイトル |
+ 最終更新 |
+
+
+
+ {results.map (page => (
+
+
+
+ {page.title}
+
+ |
+
+ {page.updated_at}
+ |
+
))}
+
+
+
+ )
+}
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index 22c3069..dc685b7 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -1,3 +1,7 @@
+import { CATEGORIES, USER_ROLES } from '@/consts'
+
+export type Category = typeof CATEGORIES[number]
+
export type Post = {
id: number
url: string
@@ -9,11 +13,13 @@ export type Post = {
export type Tag = {
id: number
name: string
- category: string
+ category: Category
count?: number}
export type User = {
id: number
name: string | null
inheritanceCode: string
- role: string }
+ role: UserRole }
+
+export type UserRole = typeof USER_ROLES[number]