ぼざクリタグ広場 https://hub.nizika.monster
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

71 lines
1.9 KiB

  1. import axios from 'axios'
  2. import toCamel from 'camelcase-keys'
  3. import { useEffect, useState } from 'react'
  4. import { Helmet } from 'react-helmet-async'
  5. import { Link, useLocation } from 'react-router-dom'
  6. import MainArea from '@/components/layout/MainArea'
  7. import { API_BASE_URL, SITE_TITLE } from '@/config'
  8. import type { WikiPageChange } from '@/types'
  9. export default () => {
  10. const [changes, setChanges] = useState<WikiPageChange[]> ([])
  11. const location = useLocation ()
  12. const query = new URLSearchParams (location.search)
  13. const id = query.get ('id')
  14. useEffect (() => {
  15. void (async () => {
  16. const res = await axios.get (`${ API_BASE_URL }/wiki/changes`,
  17. { params: { ...(id ? { id } : { }) } })
  18. setChanges (toCamel (res.data as any, { deep: true }) as WikiPageChange[])
  19. }) ()
  20. }, [location.search])
  21. return (
  22. <MainArea>
  23. <Helmet>
  24. <title>{`Wiki 変更履歴 | ${ SITE_TITLE }`}</title>
  25. </Helmet>
  26. <table className="table-auto w-full border-collapse">
  27. <thead>
  28. <tr>
  29. <th></th>
  30. <th className="p-2 text-left">タイトル</th>
  31. <th className="p-2 text-left">変更</th>
  32. <th className="p-2 text-left">日時</th>
  33. </tr>
  34. </thead>
  35. <tbody>
  36. {changes.map (change => (
  37. <tr key={change.revisionId}>
  38. <td>
  39. {change.pred != null && (
  40. <Link to={`/wiki/${ change.wikiPage.id }/diff?from=${ change.pred }&to=${ change.revisionId }`}>
  41. 差分
  42. </Link>)}
  43. </td>
  44. <td className="p-2">
  45. <Link to={`/wiki/${ encodeURIComponent (change.wikiPage.title) }?version=${ change.revisionId }`}>
  46. {change.wikiPage.title}
  47. </Link>
  48. </td>
  49. <td className="p-2">
  50. {change.pred == null ? '新規' : '更新'}
  51. </td>
  52. <td className="p-2">
  53. <Link to={`/users/${ change.user.id }`}>
  54. {change.user.name}
  55. </Link>
  56. <br/>
  57. {change.timestamp}
  58. </td>
  59. </tr>))}
  60. </tbody>
  61. </table>
  62. </MainArea>)
  63. }