#45 差分表示以外完了

This commit is contained in:
2025-06-18 23:44:33 +09:00
parent c6f7e8a696
commit 0c4ee9744e
4 changed files with 83 additions and 10 deletions
+57
View File
@@ -1,8 +1,65 @@
import { useEffect, useState } from 'react'
import { Link, useLocation, useParams } from 'react-router-dom'
import MainArea from '@/components/layout/MainArea'
import axios from 'axios'
import { API_BASE_URL } from '@/config'
import type { WikiPageChange } from '@/types'
export default () => {
const [changes, setChanges] = useState<WikiPageChange[]> ([])
const location = useLocation ()
const query = new URLSearchParams (location.search)
const id = query.get ('id')
useEffect (() => {
void (axios.get (`${ API_BASE_URL }/wiki/changes`, id && { params: { id } })
.then (res => setChanges (res.data)))
}, [location.search])
return (
<MainArea>
<table className="table-auto w-full border-collapse">
<thead>
<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.sha}>
<td></td>
<td className="p-2">
<Link to={`/wiki/${ encodeURIComponent (change.wiki_page.title) }`}
className="text-blue-400 hover:underline">
{change.wiki_page.title}
</Link>
</td>
<td className="p-2">
{(() => {
switch (change.change_type)
{
case 'create': return '新規'
case 'update': return '更新'
case 'delete': return '削除'
}
}) ()}
</td>
<td className="p-2">
<Link to={`/users/${ change.user.id }`}
className="text-blue-400 hover:underline">
{change.user.name}
</Link>
<br />
{change.timestamp}
</td>
</tr>))}
</tbody>
</table>
</MainArea>)
}
+12
View File
@@ -22,4 +22,16 @@ export type User = {
inheritanceCode: string
role: UserRole }
export type WikiPage = {
id: number
title: string
updated_at?: string }
export type WikiPageChange = {
sha: string
wiki_page: WikiPage
user: User
change_type: string
timestamp: string }
export type UserRole = typeof USER_ROLES[number]