Skip to content

Commit 6bed916

Browse files
authored
Merge pull request #129 from imaginer-dev/11-reset-passwd
feat: ๋น„๋ฐ€๋ฒˆํ˜ธ ๋ณ€๊ฒฝ ํŽ˜์ด์ง€ ๊ตฌํ˜„
2 parents 3abaa2c + 59d45ef commit 6bed916

File tree

6 files changed

+40
-56
lines changed

6 files changed

+40
-56
lines changed

โ€Žsrc/apis/authApis.tsโ€Ž

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,11 @@ export const signIn = async ({ email, password }: SignInParams) => {
1515

1616
return data;
1717
};
18+
19+
export const recoveryPasswd = async (email: string) => {
20+
const { data, error } = await supabase.auth.resetPasswordForEmail(email);
21+
if (error) {
22+
throw error;
23+
}
24+
return data;
25+
};

โ€Žsrc/components/EditPw/EditPwButton.tsxโ€Ž

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import { useEditPwState } from '../../stores/editPwStore.ts';
2+
import { recoveryPasswd } from '../../apis/authApis.ts';
23

34
const EditPwButton = () => {
4-
const { email, name } = useEditPwState();
5+
const { email } = useEditPwState();
56

67
const onClick = () => {
78
console.log('email: ', email);
8-
console.log('name: ', name);
9+
const result = recoveryPasswd(email);
10+
result.then((value) => {
11+
console.log(value);
12+
});
913
};
1014

1115
return (

โ€Žsrc/components/EditPw/EmailInput.tsxโ€Ž

Lines changed: 0 additions & 20 deletions
This file was deleted.

โ€Žsrc/components/EditPw/NameInput.tsxโ€Ž

Lines changed: 0 additions & 20 deletions
This file was deleted.

โ€Žsrc/pages/EditPwPage.tsxโ€Ž

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,35 @@
11
import CenterPageLayout from '../layouts/CenterPageLayout.tsx';
2-
import LoginForm from '../components/login/LoginForm.tsx';
3-
import EmailInput from '../components/EditPw/EmailInput.tsx';
4-
import NameInput from '../components/EditPw/NameInput.tsx';
52
import LoginFormActions from '../components/login/LoginFormActions.tsx';
63
import EditPwButton from '../components/EditPw/EditPwButton.tsx';
4+
import InputForm from '../components/common/InputForm.tsx';
5+
import { useEditPwState } from '../stores/editPwStore.ts';
76

87
const EditPwPage = () => {
8+
const { email, emailHandler } = useEditPwState();
9+
910
return (
1011
<CenterPageLayout>
11-
<LoginForm>
12-
<NameInput />
13-
<EmailInput />
14-
</LoginForm>
12+
<form className={'flex w-full flex-col'}>
13+
<div className="card mb-10 w-96 bg-base-200 text-primary-content">
14+
<div className="card-body">
15+
<p>
16+
์ƒˆ๋กœ์šด ๋น„๋ฐ€๋ฒˆํ˜ธ ๋“ฑ๋ก์ด ๊ฐ€๋Šฅํ•œ ๋งํฌ๋ฅผ <br />
17+
์ด๋ฉ”์ผ๋กœ ๋ณด๋‚ด๋“œ๋ฆฝ๋‹ˆ๋‹ค.
18+
</p>
19+
<p>ํšŒ์›๊ฐ€์ž… ์‹œ ๋“ฑ๋กํ•œ ์ด๋ฉ”์ผ ์ฃผ์†Œ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.</p>
20+
</div>
21+
</div>
22+
23+
<InputForm
24+
defaultValue={email}
25+
title={'์ด๋ฉ”์ผ'}
26+
placeholder={'์ด๋ฉ”์ผ์„ ์ž…๋ ฅํ•˜์„ธ์š”'}
27+
hint={''}
28+
onChange={(e) => emailHandler(e.target.value)}
29+
type={'email'}
30+
name={'email'}
31+
/>
32+
</form>
1533
<LoginFormActions>
1634
<EditPwButton />
1735
</LoginFormActions>

โ€Žsrc/stores/editPwStore.tsโ€Ž

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,10 @@ import { create } from 'zustand';
22

33
interface EditPwState {
44
email: string;
5-
name: string;
6-
75
emailHandler: (email: string) => void;
8-
nameHandler: (name: string) => void;
96
}
107

118
export const useEditPwState = create<EditPwState>()((set) => ({
129
email: '',
13-
name: '',
14-
15-
emailHandler: (email: string) => set((state) => ({ email, name: state.name })),
16-
nameHandler: (name: string) => set((state) => ({ email: state.email, name })),
10+
emailHandler: (email: string) => set(() => ({ email })),
1711
}));

0 commit comments

Comments
ย (0)