Skip to content

Commit c7d368a

Browse files
committed
feat: 비밀번호 변경 인풋 개발
1 parent 59e4481 commit c7d368a

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { useChangePasswordState } from '@/stores/changePasswordStore';
2+
import { LooseValidation, ValidateProcessor } from '@/utils/authUtils';
3+
import InputForm from '../common/InputForm';
4+
5+
const ChangePasswordInput = () => {
6+
const { password, passwordHandler } = useChangePasswordState();
7+
const validator = new ValidateProcessor(new LooseValidation());
8+
return (
9+
<InputForm
10+
defaultValue={password}
11+
title={'비밀번호'}
12+
placeholder={'변경할 비밀번호를 입력해 주세요.'}
13+
hint={''}
14+
onChange={(e) => passwordHandler(e.target.value)}
15+
name={'password'}
16+
type={'password'}
17+
id={'change-password-input'}
18+
aria-label={'change-password-input'}
19+
error={!validator.isValidPassword(password)}
20+
errorText={'비밀번호는 6자리 이상이어야 합니다.'}
21+
/>
22+
);
23+
};
24+
25+
export default ChangePasswordInput;

src/stores/changePasswordStore.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { create } from 'zustand';
2+
3+
interface ChangePasswordState {
4+
password: string;
5+
6+
passwordHandler: (password: string) => void;
7+
}
8+
9+
export const useChangePasswordState = create<ChangePasswordState>()((set) => ({
10+
password: '',
11+
12+
passwordHandler: (password: string) => set(() => ({ password })),
13+
}));

0 commit comments

Comments
 (0)