import axios from 'axios' import toCamel from 'camelcase-keys' import { useEffect, useState } from 'react' import { Helmet } from 'react-helmet-async' import { Link, useLocation, useParams } from 'react-router-dom' import MainArea from '@/components/layout/MainArea' import { API_BASE_URL, SITE_TITLE } from '@/config' import type { WikiPageChange } from '@/types' export default () => { const [changes, setChanges] = useState ([]) 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 (toCamel (res.data, { deep: true })))) }, [location.search]) return ( {`Wiki 変更履歴 | ${ SITE_TITLE }`} {changes.map (change => ( ))}
タイトル 変更 日時
{change.changeType === 'update' && ( 差分 )} {change.wikiPage.title} {(() => { switch (change.changeType) { case 'create': return '新規' case 'update': return '更新' case 'delete': return '削除' } }) ()} {change.user.name}
{change.timestamp}
) }