ファイル
btrc-hub/frontend/src/pages/wiki/WikiHistoryPage.tsx
T
みてるぞ ec2b3d2254 タグ “廃止” 追加 (#378) (#379)
Reviewed-on: #379
Co-authored-by: miteruzo <miteruzo@naver.com>
Co-committed-by: miteruzo <miteruzo@naver.com>
2026-06-22 08:40:06 +09:00

81 行
2.3 KiB
TypeScript

import type { FC } from 'react'
import { useEffect, useState } from 'react'
import { Helmet } from 'react-helmet-async'
import { useLocation } from 'react-router-dom'
import PrefetchLink from '@/components/PrefetchLink'
import PageTitle from '@/components/common/PageTitle'
import MainArea from '@/components/layout/MainArea'
import { SITE_TITLE } from '@/config'
import { apiGet } from '@/lib/api'
import { dateString } from '@/lib/utils'
import type { WikiPageChange } from '@/types'
const WikiHistoryPage: FC = () => {
const [changes, setChanges] = useState<WikiPageChange[]> ([])
const location = useLocation ()
const query = new URLSearchParams (location.search)
const id = query.get ('id')
useEffect (() => {
void (async () => {
setChanges (await apiGet<WikiPageChange[]> ('/wiki/changes', { params: id ? { id } : { } }))
}) ()
}, [id, location.search])
return (
<MainArea>
<Helmet>
<title>{`Wiki 変更履歴 | ${ SITE_TITLE }`}</title>
</Helmet>
<PageTitle>Wiki </PageTitle>
<table className="table-auto w-full border-collapse">
<thead className="border-b-2 border-black dark:border-white">
<tr>
<th></th>
<th className="p-2 text-left"></th>
<th className="p-2 text-left"></th>
<th className="p-2 text-left"></th>
</tr>
</thead>
<tbody>
{changes.map (change => (
<tr key={change.revisionId} className="even:bg-gray-100 dark:even:bg-gray-700">
<td className="p-2">
{change.pred != null && (
<PrefetchLink
to={`/wiki/${ change.wikiPage.id }/diff?from=${ change.pred }&to=${ change.revisionId }`}>
</PrefetchLink>)}
</td>
<td className="p-2">
<PrefetchLink
to={`/wiki/${ encodeURIComponent (change.wikiPage.title) }?version=${ change.revisionId }`}>
{change.wikiPage.title}
</PrefetchLink>
{change.wikiPage.deprecatedAt != null && <span></span>}
</td>
<td className="p-2">
{change.pred == null ? '新規' : '更新'}
</td>
<td className="p-2">
<PrefetchLink to={`/users/${ change.user.id }`}>
{change.user.name}
</PrefetchLink>
<br/>
{dateString (change.timestamp)}
</td>
</tr>))}
</tbody>
</table>
</MainArea>)
}
export default WikiHistoryPage