import { Button } from '@/components/ui/button' import { Dialog, DialogContent, DialogTitle } from '@/components/ui/dialog' import { toast } from '@/components/ui/use-toast' import { apiPost } from '@/lib/api' import type { User } from '@/types' type Props = { visible: boolean onVisibleChange: (visible: boolean) => void user: User | null setUser: React.Dispatch> } export default ({ visible, onVisibleChange, user, setUser }: Props) => { const handleChange = async () => { if (!(user)) return if (!(confirm ('引継ぎコードを再発行しますか?\n再発行するとほかのブラウザからはログアウトされます.'))) return const data = await apiPost<{ code: string }> ('/users/code/renew', { }, { headers: { 'Content-Type': 'multipart/form-data' } }) if (data.code) { localStorage.setItem ('user_code', data.code) setUser (user => ({ ...user, inheritanceCode: data.code } as User)) toast ({ title: '再発行しました.' }) } } return ( 引継ぎコード

あなたの引継ぎコードはこちらです:

{user?.inheritanceCode}

このコードはほかの人には教えないでください!

) }