Skip to content

Commit

Permalink
Merge pull request #129 from imaginer-dev/11-reset-passwd
Browse files Browse the repository at this point in the history
feat: ๋น„๋ฐ€๋ฒˆํ˜ธ ๋ณ€๊ฒฝ ํŽ˜์ด์ง€ ๊ตฌํ˜„
  • Loading branch information
gihwan-dev authored May 3, 2024
2 parents 3abaa2c + 59d45ef commit 6bed916
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 56 deletions.
8 changes: 8 additions & 0 deletions src/apis/authApis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@ export const signIn = async ({ email, password }: SignInParams) => {

return data;
};

export const recoveryPasswd = async (email: string) => {
const { data, error } = await supabase.auth.resetPasswordForEmail(email);
if (error) {
throw error;
}
return data;
};
8 changes: 6 additions & 2 deletions src/components/EditPw/EditPwButton.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { useEditPwState } from '../../stores/editPwStore.ts';
import { recoveryPasswd } from '../../apis/authApis.ts';

const EditPwButton = () => {
const { email, name } = useEditPwState();
const { email } = useEditPwState();

const onClick = () => {
console.log('email: ', email);
console.log('name: ', name);
const result = recoveryPasswd(email);
result.then((value) => {
console.log(value);
});
};

return (
Expand Down
20 changes: 0 additions & 20 deletions src/components/EditPw/EmailInput.tsx

This file was deleted.

20 changes: 0 additions & 20 deletions src/components/EditPw/NameInput.tsx

This file was deleted.

32 changes: 25 additions & 7 deletions src/pages/EditPwPage.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
import CenterPageLayout from '../layouts/CenterPageLayout.tsx';
import LoginForm from '../components/login/LoginForm.tsx';
import EmailInput from '../components/EditPw/EmailInput.tsx';
import NameInput from '../components/EditPw/NameInput.tsx';
import LoginFormActions from '../components/login/LoginFormActions.tsx';
import EditPwButton from '../components/EditPw/EditPwButton.tsx';
import InputForm from '../components/common/InputForm.tsx';
import { useEditPwState } from '../stores/editPwStore.ts';

const EditPwPage = () => {
const { email, emailHandler } = useEditPwState();

return (
<CenterPageLayout>
<LoginForm>
<NameInput />
<EmailInput />
</LoginForm>
<form className={'flex w-full flex-col'}>
<div className="card mb-10 w-96 bg-base-200 text-primary-content">
<div className="card-body">
<p>
์ƒˆ๋กœ์šด ๋น„๋ฐ€๋ฒˆํ˜ธ ๋“ฑ๋ก์ด ๊ฐ€๋Šฅํ•œ ๋งํฌ๋ฅผ <br />
์ด๋ฉ”์ผ๋กœ ๋ณด๋‚ด๋“œ๋ฆฝ๋‹ˆ๋‹ค.
</p>
<p>ํšŒ์›๊ฐ€์ž… ์‹œ ๋“ฑ๋กํ•œ ์ด๋ฉ”์ผ ์ฃผ์†Œ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.</p>
</div>
</div>

<InputForm
defaultValue={email}
title={'์ด๋ฉ”์ผ'}
placeholder={'์ด๋ฉ”์ผ์„ ์ž…๋ ฅํ•˜์„ธ์š”'}
hint={''}
onChange={(e) => emailHandler(e.target.value)}
type={'email'}
name={'email'}
/>
</form>
<LoginFormActions>
<EditPwButton />
</LoginFormActions>
Expand Down
8 changes: 1 addition & 7 deletions src/stores/editPwStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@ import { create } from 'zustand';

interface EditPwState {
email: string;
name: string;

emailHandler: (email: string) => void;
nameHandler: (name: string) => void;
}

export const useEditPwState = create<EditPwState>()((set) => ({
email: '',
name: '',

emailHandler: (email: string) => set((state) => ({ email, name: state.name })),
nameHandler: (name: string) => set((state) => ({ email: state.email, name })),
emailHandler: (email: string) => set(() => ({ email })),
}));

0 comments on commit 6bed916

Please sign in to comment.