#52 完了
This commit is contained in:
@@ -1,13 +1,18 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { Dialog, DialogTrigger, DialogContent, DialogTitle, DialogDescription } from './ui/dialog'
|
||||
import { Switch } from './ui/switch'
|
||||
import { Button } from './ui/button'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { toast } from '@/components/ui/use-toast'
|
||||
import axios from 'axios'
|
||||
import toCamel from 'camelcase-keys'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { Link, useNavigate, useLocation } from 'react-router-dom'
|
||||
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogTitle,
|
||||
DialogTrigger } from '@/components/ui/dialog'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { Switch } from '@/components/ui/switch'
|
||||
import { toast } from '@/components/ui/use-toast'
|
||||
import { API_BASE_URL } from '@/config'
|
||||
import { camelizeKeys } from 'humps'
|
||||
|
||||
import type { Tag, User } from '@/types'
|
||||
|
||||
@@ -17,7 +22,10 @@ type Props = { visible: boolean
|
||||
setUser: (user: User) => void }
|
||||
|
||||
|
||||
const SettingsDialogue: React.FC = ({ visible, onVisibleChange, user, setUser }: Props) => {
|
||||
const SettingsDialogue: React.FC = ({ visible,
|
||||
onVisibleChange,
|
||||
user,
|
||||
setUser }: Props) => {
|
||||
const [inputCode, setInputCode] = useState ('')
|
||||
|
||||
const handleShowCode = () => {
|
||||
@@ -35,7 +43,7 @@ const SettingsDialogue: React.FC = ({ visible, onVisibleChange, user, setUser }:
|
||||
if (res.data.valid)
|
||||
{
|
||||
localStorage.setItem ('user_code', inputCode)
|
||||
setUser (camelizeKeys (res.data.user))
|
||||
setUser (toCamel (res.data.user, { deep: true }))
|
||||
toast ({ title: '引継ぎ成功!' })
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import axios from 'axios'
|
||||
import toCamel from 'camelcase-keys'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Helmet } from 'react-helmet'
|
||||
import ReactMarkdown from 'react-markdown'
|
||||
@@ -33,7 +34,7 @@ export default () => {
|
||||
|
||||
void (axios.get (`${ API_BASE_URL }/wiki/title/${ encodeURIComponent (title) }`, version && { params: { version } })
|
||||
.then (res => {
|
||||
setWikiPage (res.data)
|
||||
setWikiPage (toCamel (res.data, { deep: true }))
|
||||
WikiIdBus.set (res.data.id)
|
||||
})
|
||||
.catch (() => setWikiPage (null)))
|
||||
@@ -51,7 +52,7 @@ export default () => {
|
||||
< 古
|
||||
</Link>) : <>(最古)</>}
|
||||
|
||||
<span>{wikiPage.updated_at}</span>
|
||||
<span>{wikiPage.updatedAt}</span>
|
||||
|
||||
{wikiPage.succ ? (
|
||||
<Link to={`/wiki/${ title }?version=${ wikiPage.succ }`}>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import axios from 'axios'
|
||||
import toCamel from 'camelcase-keys'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Helmet } from 'react-helmet'
|
||||
import { Link, useLocation, useParams } from 'react-router-dom'
|
||||
@@ -23,7 +24,7 @@ export default () => {
|
||||
|
||||
useEffect (() => {
|
||||
void (axios.get (`${ API_BASE_URL }/wiki/${ id }/diff`, { params: { from, to } })
|
||||
.then (res => setDiff (res.data)))
|
||||
.then (res => setDiff (toCamel (res.data, { deep: true }))))
|
||||
}, [])
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import axios from 'axios'
|
||||
import toCamel from 'camelcase-keys'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Helmet } from 'react-helmet'
|
||||
import { Link, useLocation, useParams } from 'react-router-dom'
|
||||
@@ -18,7 +19,7 @@ export default () => {
|
||||
|
||||
useEffect (() => {
|
||||
void (axios.get (`${ API_BASE_URL }/wiki/changes`, id && { params: { id } })
|
||||
.then (res => setChanges (res.data)))
|
||||
.then (res => setChanges (toCamel (res.data, { deep: true }))))
|
||||
}, [location.search])
|
||||
|
||||
return (
|
||||
@@ -39,19 +40,19 @@ export default () => {
|
||||
{changes.map (change => (
|
||||
<tr key={change.sha}>
|
||||
<td>
|
||||
{change.change_type === 'update' && (
|
||||
<Link to={`/wiki/${ change.wiki_page.id }/diff?from=${ change.pred }&to=${ change.sha }`}>
|
||||
{change.changeType === 'update' && (
|
||||
<Link to={`/wiki/${ change.wikiPage.id }/diff?from=${ change.pred }&to=${ change.sha }`}>
|
||||
差分
|
||||
</Link>)}
|
||||
</td>
|
||||
<td className="p-2">
|
||||
<Link to={`/wiki/${ encodeURIComponent (change.wiki_page.title) }?version=${ change.sha }`}>
|
||||
{change.wiki_page.title}
|
||||
<Link to={`/wiki/${ encodeURIComponent (change.wikiPage.title) }?version=${ change.sha }`}>
|
||||
{change.wikiPage.title}
|
||||
</Link>
|
||||
</td>
|
||||
<td className="p-2">
|
||||
{(() => {
|
||||
switch (change.change_type)
|
||||
switch (change.changeType)
|
||||
{
|
||||
case 'create':
|
||||
return '新規'
|
||||
|
||||
+18
-18
@@ -23,28 +23,28 @@ export type User = {
|
||||
role: UserRole }
|
||||
|
||||
export type WikiPage = {
|
||||
id: number
|
||||
title: string
|
||||
sha: string
|
||||
pred?: string
|
||||
succ?: string
|
||||
updated_at?: string }
|
||||
id: number
|
||||
title: string
|
||||
sha: string
|
||||
pred?: string
|
||||
succ?: string
|
||||
updatedAt?: string }
|
||||
|
||||
export type WikiPageChange = {
|
||||
sha: string
|
||||
pred?: string
|
||||
succ?: string
|
||||
wiki_page: WikiPage
|
||||
user: User
|
||||
change_type: string
|
||||
timestamp: string }
|
||||
sha: string
|
||||
pred?: string
|
||||
succ?: string
|
||||
wikiPage: WikiPage
|
||||
user: User
|
||||
changeType: string
|
||||
timestamp: string }
|
||||
|
||||
export type WikiPageDiff = {
|
||||
wiki_page_id: number
|
||||
title: string
|
||||
older_sha: string
|
||||
newer_sha: string
|
||||
diff: WikiPageDiffDiff[] }
|
||||
wikiPageId: number
|
||||
title: string
|
||||
olderSha: string
|
||||
newerSha: string
|
||||
diff: WikiPageDiffDiff[] }
|
||||
|
||||
export type WikiPageDiffDiff = {
|
||||
type: 'context' | 'added' | 'removed'
|
||||
|
||||
Reference in New Issue
Block a user