diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 99b75d6..0660f32 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -13,6 +13,7 @@ "@radix-ui/react-switch": "^1.2.5", "@radix-ui/react-toast": "^1.2.14", "axios": "^1.9.0", + "camelcase-keys": "^9.1.3", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "humps": "^2.0.1", @@ -2591,6 +2592,18 @@ "node": ">=6" } }, + "node_modules/camelcase": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-8.0.0.tgz", + "integrity": "sha512-8WB3Jcas3swSvjIeA2yvCJ+Miyz5l1ZmB6HFb9R1317dt9LCQoswg/BGrmAmkWVEszSrrg4RwmO46qIm2OEnSA==", + "license": "MIT", + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/camelcase-css": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/camelcase-css/-/camelcase-css-2.0.1.tgz", @@ -2601,6 +2614,24 @@ "node": ">= 6" } }, + "node_modules/camelcase-keys": { + "version": "9.1.3", + "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-9.1.3.tgz", + "integrity": "sha512-Rircqi9ch8AnZscQcsA1C47NFdaO3wukpmIRzYcDOrmvgt78hM/sj5pZhZNec2NM12uk5vTwRHZ4anGcrC4ZTg==", + "license": "MIT", + "dependencies": { + "camelcase": "^8.0.0", + "map-obj": "5.0.0", + "quick-lru": "^6.1.1", + "type-fest": "^4.3.2" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/caniuse-lite": { "version": "1.0.30001718", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001718.tgz", @@ -4151,6 +4182,18 @@ "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, + "node_modules/map-obj": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-5.0.0.tgz", + "integrity": "sha512-2L3MIgJynYrZ3TYMriLDLWocz15okFakV6J12HXvMXDHui2x/zgChzg1u9mFFGbbGWE+GsLpQByt4POb9Or+uA==", + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/markdown-it": { "version": "14.1.0", "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", @@ -5362,6 +5405,18 @@ ], "license": "MIT" }, + "node_modules/quick-lru": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-6.1.2.tgz", + "integrity": "sha512-AAFUA5O1d83pIHEhJwWCq/RQcRukCkn/NSm2QsTEMle5f2hP0ChI2+3Xb051PZCkLryI/Ir1MVKviT2FIloaTQ==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/react": { "version": "19.1.0", "resolved": "https://registry.npmjs.org/react/-/react-19.1.0.tgz", @@ -6192,6 +6247,18 @@ "node": ">= 0.8.0" } }, + "node_modules/type-fest": { + "version": "4.41.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.41.0.tgz", + "integrity": "sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==", + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/typescript": { "version": "5.8.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", diff --git a/frontend/package.json b/frontend/package.json index ebeed51..eebd11e 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -14,6 +14,7 @@ "@radix-ui/react-switch": "^1.2.5", "@radix-ui/react-toast": "^1.2.14", "axios": "^1.9.0", + "camelcase-keys": "^9.1.3", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "humps": "^2.0.1", diff --git a/frontend/src/components/SettingsDialogue.tsx b/frontend/src/components/SettingsDialogue.tsx index b3267c2..0a947af 100644 --- a/frontend/src/components/SettingsDialogue.tsx +++ b/frontend/src/components/SettingsDialogue.tsx @@ -1,13 +1,18 @@ +import axios from 'axios' +import toCamel from 'camelcase-keys' 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 { 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 axios from 'axios' -import { Link, useNavigate, useLocation } from 'react-router-dom' 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 diff --git a/frontend/src/pages/wiki/WikiDetailPage.tsx b/frontend/src/pages/wiki/WikiDetailPage.tsx index 9b08b8f..a3cff73 100644 --- a/frontend/src/pages/wiki/WikiDetailPage.tsx +++ b/frontend/src/pages/wiki/WikiDetailPage.tsx @@ -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 () => { < 古 ) : <>(最古)>} - {wikiPage.updated_at} + {wikiPage.updatedAt} {wikiPage.succ ? ( diff --git a/frontend/src/pages/wiki/WikiDiffPage.tsx b/frontend/src/pages/wiki/WikiDiffPage.tsx index 70eee6a..0d8160f 100644 --- a/frontend/src/pages/wiki/WikiDiffPage.tsx +++ b/frontend/src/pages/wiki/WikiDiffPage.tsx @@ -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 ( diff --git a/frontend/src/pages/wiki/WikiHistoryPage.tsx b/frontend/src/pages/wiki/WikiHistoryPage.tsx index 1eb0402..409de81 100644 --- a/frontend/src/pages/wiki/WikiHistoryPage.tsx +++ b/frontend/src/pages/wiki/WikiHistoryPage.tsx @@ -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 => (