|
| 1 | +import { FormProvider, useForm } from "react-hook-form"; |
| 2 | +import Button from "../../../components/ui/button/Button"; |
| 3 | +import Input from "../../../components/ui/input/Input"; |
| 4 | +import * as S from "./updateMyPageStyle"; |
| 5 | +import { schema, UpdateMyPageType } from "./schema"; |
| 6 | +import { zodResolver } from "@hookform/resolvers/zod"; |
| 7 | + |
| 8 | +export default function UpdateMyPage() { |
| 9 | + const methods = useForm<UpdateMyPageType>({ |
| 10 | + resolver: zodResolver(schema), |
| 11 | + mode: "onChange", |
| 12 | + }); |
| 13 | + const onClickSubmit = (data: UpdateMyPageType) => { |
| 14 | + console.log(data); |
| 15 | + }; |
| 16 | + |
| 17 | + return ( |
| 18 | + <FormProvider {...methods}> |
| 19 | + <S.container> |
| 20 | + <S.contentsBox onSubmit={methods.handleSubmit(onClickSubmit)}> |
| 21 | + <S.imgBox> |
| 22 | + <S.title>내 정보 수정</S.title> |
| 23 | + <S.img></S.img> |
| 24 | + <Button type="button" bgcolor="blue" textcolor="black" size="sm"> |
| 25 | + 프로필 사진 수정 |
| 26 | + </Button> |
| 27 | + </S.imgBox> |
| 28 | + <S.inputBox> |
| 29 | + <S.label>이메일</S.label> |
| 30 | + <Input |
| 31 | + type="text" |
| 32 | + keyname="email" |
| 33 | + defaultValue="abc@sample.com" |
| 34 | + disable={true} |
| 35 | + /> |
| 36 | + </S.inputBox> |
| 37 | + <S.inputBox> |
| 38 | + <S.label>비밀번호</S.label> |
| 39 | + <Input<UpdateMyPageType> type="password" keyname="password" /> |
| 40 | + <S.errorMessage> |
| 41 | + {methods.formState.errors.password?.message} |
| 42 | + </S.errorMessage> |
| 43 | + </S.inputBox> |
| 44 | + <S.inputBox> |
| 45 | + <S.label>비밀번호 확인</S.label> |
| 46 | + <Input<UpdateMyPageType> type="password" keyname="checkPassword" /> |
| 47 | + <S.errorMessage> |
| 48 | + {methods.formState.errors.checkPassword?.message} |
| 49 | + </S.errorMessage> |
| 50 | + </S.inputBox> |
| 51 | + <S.inputBox> |
| 52 | + <S.label>닉네임</S.label> |
| 53 | + <Input<UpdateMyPageType> type="text" keyname="nickname" /> |
| 54 | + <S.errorMessage> |
| 55 | + {methods.formState.errors.nickname?.message} |
| 56 | + </S.errorMessage> |
| 57 | + </S.inputBox> |
| 58 | + <S.buttonBox> |
| 59 | + <Button type="button" bgcolor="black" textcolor="white" size="sm"> |
| 60 | + 이전 |
| 61 | + </Button> |
| 62 | + <Button type="submit" bgcolor="green" textcolor="black" size="sm"> |
| 63 | + 다음 |
| 64 | + </Button> |
| 65 | + </S.buttonBox> |
| 66 | + </S.contentsBox> |
| 67 | + </S.container> |
| 68 | + </FormProvider> |
| 69 | + ); |
| 70 | +} |
0 commit comments