From 141b39d33e5fbc62305e86dddf126bd5fbaa3728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=ED=98=84=EC=A1=B0?= Date: Thu, 29 Aug 2024 13:22:25 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20MemberAdd=20=EC=BB=B4=ED=8F=AC=EB=84=8C?= =?UTF-8?q?=ED=8A=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/MemberAdd/MemberAddForm.tsx | 81 +++++++++++++++++++ .../components/MemberAdd/index.stories.tsx | 20 +++++ frontend/src/components/MemberAdd/index.tsx | 27 +++++++ 3 files changed, 128 insertions(+) create mode 100644 frontend/src/components/MemberAdd/MemberAddForm.tsx create mode 100644 frontend/src/components/MemberAdd/index.stories.tsx create mode 100644 frontend/src/components/MemberAdd/index.tsx diff --git a/frontend/src/components/MemberAdd/MemberAddForm.tsx b/frontend/src/components/MemberAdd/MemberAddForm.tsx new file mode 100644 index 0000000..c98ce7f --- /dev/null +++ b/frontend/src/components/MemberAdd/MemberAddForm.tsx @@ -0,0 +1,81 @@ +import { zodResolver } from '@hookform/resolvers/zod'; +import { useForm } from 'react-hook-form'; +import { z } from 'zod'; +import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '../ui/form'; +import { Input } from '../ui/input'; +import { Button } from '../ui/button'; +import { Select } from '../ui/select'; + +const formSchema = z.object({ + email: z.string().email({ message: '올바른 이메일 형식을 입력해주세요.' }), + role: z.string().min(1, { message: '역할을 선택해주세요.' }), +}); + +export type MemberAddFormValues = z.infer; + +const defaultValues: Partial = { + email: '', + role: '', +}; + +const roleOptions = [ + { value: 'admin', label: '관리자' }, + { value: 'viewer', label: '뷰어' }, + { value: 'editor', label: '에디터' }, +]; + +export default function MemberAddForm({ onSubmit }: { onSubmit: (data: MemberAddFormValues) => void }) { + const form = useForm({ + resolver: zodResolver(formSchema), + defaultValues, + }); + + return ( +
+ + ( + + 이메일 + + + + + + )} + /> + ( + + 역할 + +