Skip to content

Commit e3edbea

Browse files
authored
Merge branch 'dev' into 9-회원가입-클릭시-회원가입을-할-수-있어야-한다
2 parents b0ca267 + 6bed916 commit e3edbea

File tree

6 files changed

+37
-56
lines changed

6 files changed

+37
-56
lines changed

src/apis/authApis.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,10 @@ export const signUp = async ({ name, nickName, phone, email, password }: SignUpP
4444
throw error;
4545
}
4646

47+
export const recoveryPasswd = async (email: string) => {
48+
const { data, error } = await supabase.auth.resetPasswordForEmail(email);
49+
if (error) {
50+
throw error;
51+
}
4752
return data;
4853
};

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)