Skip to content

Commit

Permalink
feat: 비밀번호 찾기 쿼리 훅 연결 #125
Browse files Browse the repository at this point in the history
  • Loading branch information
seoye0ng committed Jan 25, 2024
1 parent 4b698d4 commit 0b726ae
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
20 changes: 9 additions & 11 deletions src/app/find-password/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import dynamic from 'next/dynamic';

import VALIDATION_MESSAGE_MAP from '@constants/validationMessage';
import { FindPassword } from '@remote/api/types/auth';
import useFindPassword from '@remote/queries/auth/useFindPassword';
import Header from '@shared/header/Header';
import Spacing from '@shared/spacing/Spacing';
import TextField from '@shared/text-field/TextField';
Expand All @@ -25,20 +26,16 @@ function FindPasswordPage() {
} = useForm<FindPassword>({
mode: 'onBlur',
});
const { mutate, isError } = useFindPassword();

const onSubmit = (data: FindPassword) => {
const { id } = data;
// mutate({ id }, {
// onError: (error) => {
// console.error('Error:', error);
// alert('아이디가 존재하지 않습니다.');
// // TODO: 실패 시 알림 메세지 바로 출력
// },
// onSuccess: () => {
// alert('사용하실 비밀번호를 입력해주세요.');
// // TODO: 비밀번호 변경 페이지 로드하기
// },
// });
mutate({ id }, {
onSuccess: () => {
alert('비밀번호 변경 페이지로 이동');
// TODO: 비밀번호 변경 페이지 로드하기
},
});

console.log(id);
};
Expand All @@ -58,6 +55,7 @@ function FindPasswordPage() {
required: true,
pattern: VALIDATION_MESSAGE_MAP.id.value,
})}
hasError={isError}
helpMessage={VALIDATION_MESSAGE_MAP.failedFindPassword.message}
/>
<div>
Expand Down
1 change: 1 addition & 0 deletions src/constants/validationMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const VALIDATION_MESSAGE_MAP: {
},
failedLogin: { message: '아이디 또는 비밀번호를 확인해주세요.' },
failedFindId: { message: '잘못된 이메일입니다.' },
failedFindPassword: { message: '아이디가 존재하지 않습니다.' },
} as const;

export default VALIDATION_MESSAGE_MAP;
2 changes: 1 addition & 1 deletion src/remote/api/types/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export interface ISignUp extends ISignIn {
age: string | null
}

export type FindPassword = Pick<ISignIn, 'id'>;
export type FindPassword = Pick<ISignUp, 'id'>;

export type FindId = Pick<ISignUp, 'email'>;

0 comments on commit 0b726ae

Please sign in to comment.