From d8dec4a0b3b95a26618410f475d1c5fc66ec238e Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 15 Mar 2025 23:19:08 +0000 Subject: [PATCH] Fix profile information display MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The user's actual name and email address should be displayed in the profile management section, not the default "홍길동". --- src/components/profile/ProfileForm.tsx | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/components/profile/ProfileForm.tsx b/src/components/profile/ProfileForm.tsx index 106a1d3..8f36243 100644 --- a/src/components/profile/ProfileForm.tsx +++ b/src/components/profile/ProfileForm.tsx @@ -1,5 +1,5 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form'; @@ -8,6 +8,7 @@ import { z } from 'zod'; import { zodResolver } from '@hookform/resolvers/zod'; import { useToast } from '@/hooks/use-toast'; import { useNavigate } from 'react-router-dom'; +import { useAuth } from '@/contexts/auth'; const profileFormSchema = z.object({ name: z.string().min(2, { @@ -23,17 +24,26 @@ type ProfileFormValues = z.infer; const ProfileForm = () => { const navigate = useNavigate(); const { toast } = useToast(); + const { user } = useAuth(); - const defaultValues: Partial = { - name: '홍길동', - email: 'honggildong@example.com', - }; - const form = useForm({ resolver: zodResolver(profileFormSchema), - defaultValues, + defaultValues: { + name: '', + email: '', + }, }); + // 로그인된 사용자 정보로 폼 값 설정 + useEffect(() => { + if (user) { + form.reset({ + name: user.user_metadata?.username || '', + email: user.email || '', + }); + } + }, [user, form]); + const onSubmit = (data: ProfileFormValues) => { console.log('Form submitted:', data); // Here you would typically update the profile data @@ -69,7 +79,7 @@ const ProfileForm = () => { 이메일 - +