From ebcc535cf114de8c0050ae48dce61eb8223bb30b Mon Sep 17 00:00:00 2001
From: miteruzo
Date: Mon, 7 Jul 2025 02:46:57 +0900
Subject: [PATCH] #32
---
frontend/src/components/SettingsDialogue.tsx | 86 -------------------
frontend/src/components/TopNav.tsx | 8 +-
.../src/components/users/InheritDialogue.tsx | 40 +++++++++
.../src/components/users/UserCodeDialogue.tsx | 31 ++++++-
frontend/src/pages/users/SettingPage.tsx | 74 ++++++++--------
5 files changed, 107 insertions(+), 132 deletions(-)
delete mode 100644 frontend/src/components/SettingsDialogue.tsx
diff --git a/frontend/src/components/SettingsDialogue.tsx b/frontend/src/components/SettingsDialogue.tsx
deleted file mode 100644
index 0a947af..0000000
--- a/frontend/src/components/SettingsDialogue.tsx
+++ /dev/null
@@ -1,86 +0,0 @@
-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 type { Tag, User } from '@/types'
-
-type Props = { visible: boolean
- onVisibleChange: (visible: boolean) => void
- user: User
- setUser: (user: User) => void }
-
-
-const SettingsDialogue: React.FC = ({ visible,
- onVisibleChange,
- user,
- setUser }: Props) => {
- const [inputCode, setInputCode] = useState ('')
-
- const handleShowCode = () => {
- if (user?.inheritanceCode)
- toast ({ title: 'あなたの引継ぎコード', description: user.inheritanceCode })
- else
- toast ({ title: '引継ぎコードが見つかりません.' })
- }
-
- const handleTransfer = async () => {
- try
- {
- void (axios.post (`${ API_BASE_URL }/users/verify`, { code: inputCode })
- .then (res => {
- if (res.data.valid)
- {
- localStorage.setItem ('user_code', inputCode)
- setUser (toCamel (res.data.user, { deep: true }))
- toast ({ title: '引継ぎ成功!' })
- }
- else
- toast ({ title: '認証失敗', description: 'そのコードは使へません.' })
- }))
- }
- catch (e)
- {
- toast ({ title: '通信エラー', description: 'またあとで試してね.' })
- }
- }
-
- return (
- )
-}
-
-
-export default SettingsDialogue
diff --git a/frontend/src/components/TopNav.tsx b/frontend/src/components/TopNav.tsx
index c4f5988..6ab44de 100644
--- a/frontend/src/components/TopNav.tsx
+++ b/frontend/src/components/TopNav.tsx
@@ -3,7 +3,6 @@ import toCamel from 'camelcase-keys'
import React, { useState, useEffect } from 'react'
import { Link, useLocation, useNavigate, useParams } from 'react-router-dom'
-import SettingsDialogue from '@/components/SettingsDialogue'
import { Button } from '@/components/ui/button'
import { API_BASE_URL } from '@/config'
import { WikiIdBus } from '@/lib/eventBus/WikiIdBus'
@@ -25,7 +24,6 @@ const TopNav: React.FC = ({ user, setUser }: Props) => {
const location = useLocation ()
const navigate = useNavigate ()
- const [settingsVsbl, setSettingsVsbl] = useState (false)
const [selectedMenu, setSelectedMenu] = useState
-
diff --git a/frontend/src/pages/users/SettingPage.tsx b/frontend/src/pages/users/SettingPage.tsx
index 6418ef0..35deb86 100644
--- a/frontend/src/pages/users/SettingPage.tsx
+++ b/frontend/src/pages/users/SettingPage.tsx
@@ -55,45 +55,49 @@ export default ({ user, setUser }: Props) => {
+ user={user}
+ setUser={setUser} />