ぼざクリ タグ広場 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.
 
 
 
 
 
 

76 lines
2.5 KiB

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