Skip to content

Commit 9befd65

Browse files
authored
Merge pull request #103 from imaginer-dev/12-비밀번호-변경-페이지
비밀번호 변경 페이지 추가합니다.
2 parents 9964089 + fd73af6 commit 9befd65

File tree

8 files changed

+119
-17
lines changed

8 files changed

+119
-17
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { useEditPwState } from '../../stores/editPwStore.ts';
2+
3+
const EditPwButton = () => {
4+
const { email, name } = useEditPwState();
5+
6+
const onClick = () => {
7+
console.log('email: ', email);
8+
console.log('name: ', name);
9+
};
10+
11+
return (
12+
<button type={'submit'} onClick={onClick} className="btn btn-outline btn-primary w-full">
13+
비밀번호 변경
14+
</button>
15+
);
16+
};
17+
18+
export default EditPwButton;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import InputForm from '../common/InputForm.tsx';
2+
import { useEditPwState } from '../../stores/editPwStore.ts';
3+
4+
const EmailInput = () => {
5+
const { email, emailHandler } = useEditPwState();
6+
7+
return (
8+
<InputForm
9+
defaultValue={email}
10+
title={'이메일'}
11+
placeholder={'이메일을 입력하세요'}
12+
hint={'Hint Text'}
13+
onChange={(e) => emailHandler(e.target.value)}
14+
type={'email'}
15+
name={'email'}
16+
/>
17+
);
18+
};
19+
20+
export default EmailInput;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import InputForm from '../common/InputForm.tsx';
2+
import { useEditPwState } from '../../stores/editPwStore.ts';
3+
4+
const NameInput = () => {
5+
const { name, nameHandler } = useEditPwState();
6+
7+
return (
8+
<InputForm
9+
defaultValue={name}
10+
title={'이름'}
11+
placeholder={'이름을 입력하세요'}
12+
hint={'Hint Text'}
13+
onChange={(e) => nameHandler(e.target.value)}
14+
type={'name'}
15+
name={'name'}
16+
/>
17+
);
18+
};
19+
20+
export default NameInput;

src/layouts/CenterPageLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ interface Props {
44
children: ReactNode;
55
}
66

7-
const LoginPageLayout: FC<Props> = ({ children }) => {
7+
const CenterPageLayout: FC<Props> = ({ children }) => {
88
return (
99
<main className={'flex h-screen w-screen items-center justify-center'}>
1010
<div className={'flex h-full w-full max-w-md flex-col items-center justify-around overflow-hidden px-8 py-8'}>
@@ -14,4 +14,4 @@ const LoginPageLayout: FC<Props> = ({ children }) => {
1414
);
1515
};
1616

17-
export default LoginPageLayout;
17+
export default CenterPageLayout;

src/main.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,25 @@ import { NotFound } from './pages/Notfound.tsx';
99
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
1010
import JoinPage from './pages/JoinPage.tsx';
1111
import LoginPage from './pages/LoginPage.tsx';
12+
import EditPwPage from './pages/EditPwPage.tsx';
1213

1314
const router = createBrowserRouter([
1415
{
1516
path: '/',
1617
element: <App />,
1718
},
19+
{
20+
path: '/login',
21+
element: <LoginPage />,
22+
},
23+
{
24+
path: '/join',
25+
element: <JoinPage />,
26+
},
27+
{
28+
path: '/editPw',
29+
element: <EditPwPage />,
30+
},
1831
{
1932
path: '*',
2033
element: <NotFound />,
@@ -28,14 +41,6 @@ const router = createBrowserRouter([
2841
},
2942
],
3043
},
31-
{
32-
path: 'login',
33-
element: <LoginPage />,
34-
},
35-
{
36-
path: 'join',
37-
element: <JoinPage />,
38-
},
3944
]);
4045
const queryClient = new QueryClient();
4146

src/pages/EditPwPage.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
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';
5+
import LoginFormActions from '../components/login/LoginFormActions.tsx';
6+
import EditPwButton from '../components/EditPw/EditPwButton.tsx';
7+
8+
const EditPwPage = () => {
9+
return (
10+
<CenterPageLayout>
11+
<LoginForm>
12+
<NameInput />
13+
<EmailInput />
14+
</LoginForm>
15+
<LoginFormActions>
16+
<EditPwButton />
17+
</LoginFormActions>
18+
</CenterPageLayout>
19+
);
20+
};
21+
22+
export default EditPwPage;

src/pages/LoginPage.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
import LoginPageLayout from '../layouts/CenterPageLayout.tsx';
1+
import CenterPageLayout from '../layouts/CenterPageLayout.tsx';
22
import VerticalLogo from '../components/common/VerticalLogo.tsx';
33
import LoginForm from '../components/login/LoginForm.tsx';
44
import EmailInput from '../components/login/EmailInput.tsx';
5-
import PasswordInput from '../components/login/PasswordInput.tsx';
65
import LoginFormActions from '../components/login/LoginFormActions.tsx';
76
import LoginButton from '../components/login/LoginButton.tsx';
87
import LoginNavigation from '../components/login/LoginNavigation.tsx';
98
import LoginNavigationLink from '../components/login/LoginNavigationLink.tsx';
9+
import NameInput from '../components/Join/NameInput.tsx';
1010

1111
const LoginPage = () => {
1212
return (
13-
<LoginPageLayout>
13+
<CenterPageLayout>
1414
<VerticalLogo />
1515
<LoginForm>
16+
<NameInput />
1617
<EmailInput />
17-
<PasswordInput />
1818
</LoginForm>
1919
<LoginFormActions>
2020
<LoginButton />
2121
<LoginNavigation>
22-
<LoginNavigationLink text={'비밀번호 찾기'} to={'/'} />
23-
<LoginNavigationLink text={'회원가입'} to={'/'} />
22+
<LoginNavigationLink text={'비밀번호 찾기'} to={'/editPw'} />
23+
<LoginNavigationLink text={'회원가입'} to={'/join'} />
2424
</LoginNavigation>
2525
</LoginFormActions>
26-
</LoginPageLayout>
26+
</CenterPageLayout>
2727
);
2828
};
2929

src/stores/editPwStore.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { create } from 'zustand';
2+
3+
interface EditPwState {
4+
email: string;
5+
name: string;
6+
7+
emailHandler: (email: string) => void;
8+
nameHandler: (name: string) => void;
9+
}
10+
11+
export const useEditPwState = create<EditPwState>()((set) => ({
12+
email: '',
13+
name: '',
14+
15+
emailHandler: (email: string) => set((state) => ({ email, name: state.name })),
16+
nameHandler: (name: string) => set((state) => ({ email: state.email, name })),
17+
}));

0 commit comments

Comments
 (0)