Create profile management page
This commit creates a profile management page within the settings section.
This commit is contained in:
142
src/pages/ProfileManagement.tsx
Normal file
142
src/pages/ProfileManagement.tsx
Normal file
@@ -0,0 +1,142 @@
|
||||
|
||||
import React from 'react';
|
||||
import { ArrowLeft, User, Camera, Mail, Phone } from 'lucide-react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
||||
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { z } from 'zod';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
|
||||
const profileFormSchema = z.object({
|
||||
name: z.string().min(2, {
|
||||
message: '이름은 2글자 이상이어야 합니다.',
|
||||
}),
|
||||
email: z.string().email({
|
||||
message: '유효한 이메일 주소를 입력해주세요.',
|
||||
}),
|
||||
phone: z.string().optional(),
|
||||
});
|
||||
|
||||
type ProfileFormValues = z.infer<typeof profileFormSchema>;
|
||||
|
||||
const ProfileManagement = () => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const defaultValues: Partial<ProfileFormValues> = {
|
||||
name: '홍길동',
|
||||
email: 'honggildong@example.com',
|
||||
phone: '010-1234-5678',
|
||||
};
|
||||
|
||||
const form = useForm<ProfileFormValues>({
|
||||
resolver: zodResolver(profileFormSchema),
|
||||
defaultValues,
|
||||
});
|
||||
|
||||
const onSubmit = (data: ProfileFormValues) => {
|
||||
console.log('Form submitted:', data);
|
||||
// Here you would typically update the profile data
|
||||
// Show success message
|
||||
navigate('/settings');
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-neuro-background pb-24">
|
||||
<div className="max-w-md mx-auto px-6">
|
||||
{/* Header */}
|
||||
<header className="py-8">
|
||||
<div className="flex items-center mb-6">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={() => navigate('/settings')}
|
||||
className="mr-2"
|
||||
>
|
||||
<ArrowLeft size={20} />
|
||||
</Button>
|
||||
<h1 className="text-2xl font-bold neuro-text">프로필 관리</h1>
|
||||
</div>
|
||||
|
||||
{/* User Profile Picture */}
|
||||
<div className="flex flex-col items-center mb-8">
|
||||
<div className="relative mb-4">
|
||||
<Avatar className="h-24 w-24 neuro-flat">
|
||||
<AvatarImage src="" alt="Profile" />
|
||||
<AvatarFallback className="text-2xl bg-neuro-income text-white">
|
||||
<User size={40} />
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<Button
|
||||
size="sm"
|
||||
className="absolute bottom-0 right-0 rounded-full bg-neuro-income"
|
||||
>
|
||||
<Camera size={14} />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{/* Profile Form */}
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6 neuro-flat p-6">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="name"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>이름</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="이름을 입력하세요" {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="email"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>이메일</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="이메일을 입력하세요" {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="phone"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>전화번호</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="전화번호를 입력하세요" {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<div className="pt-4">
|
||||
<Button
|
||||
type="submit"
|
||||
className="w-full bg-neuro-income text-white hover:bg-neuro-income/90"
|
||||
>
|
||||
저장하기
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</Form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ProfileManagement;
|
||||
Reference in New Issue
Block a user