Skip to content

Commit

Permalink
Merge pull request #215 from bsideproject/feature/user
Browse files Browse the repository at this point in the history
[feat] resetPassword API 추가
  • Loading branch information
KinDDoGGang authored Nov 22, 2023
2 parents 279c6e8 + 4e33dd1 commit d6eb433
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
12 changes: 11 additions & 1 deletion api/signup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const postPassword = async (payload: ProfilePayload) => {
export const postProfile = async (payload: ProfilePayload) => {
const { firstName, lastName, genderCode, birthDate, description, email } = payload;

return fetchData(`/api/v1/auth/profile?email=${email ? encodeURIComponent(email) : ''}`, {
return fetchData(`/api/v1/auth/reset-password=${email ? encodeURIComponent(email) : ''}`, {
method: 'POST',
body: JSON.stringify({
firstName,
Expand All @@ -54,3 +54,13 @@ export const login = async (payload: { email: string; password: string }) => {
},
});
};

export const postResetPassword = async (email: string) => {
return fetchData('/api/v1/auth/reset-password', {
method: 'POST',
body: JSON.stringify({ email }),
headers: {
'Content-Type': 'application/json',
},
});
};
9 changes: 6 additions & 3 deletions pages/resetPassword/step1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { isValidEmail } from '@/utils/validCheck.ts';
import { useTranslation as UseTranslation } from 'next-i18next';
import type { GetStaticPropsContext } from 'next';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { postResetPassword } from '@/api/signup';

export const getStaticProps = async ({ locale }: GetStaticPropsContext) => ({
props: {
Expand All @@ -25,9 +26,11 @@ export default function step1() {
formState: { errors },
} = UseForm({ mode: 'onChange' });

const fnAuthEmail = () => {
console.log('error is ??', errors);
return !errors.email?.message && setAuthEmail(true);
const fnAuthEmail = async () => {
if (!errors.email?.message) {
setAuthEmail(true);
await postResetPassword(watch('email'));
}
};

return (
Expand Down

0 comments on commit d6eb433

Please sign in to comment.