Skip to content

Commit

Permalink
✨ Feat: 임시 비밀번호찾기 페이지 구현 #90
Browse files Browse the repository at this point in the history
  • Loading branch information
gd06070 committed Dec 17, 2024
1 parent c4c7a03 commit b2e1ac3
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/pages/findPw.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { useState } from 'react';
import { findPassword } from '../api/userApi';

const FindPw = () => {
const [email, setEmail] = useState('');
const [userId, setUserId] = useState('');
const [isSuccess, setIsSuccess] = useState(false);
const [error, setError] = useState(null);

const handleFindPassword = async (e) => {
e.preventDefault();
try {
await findPassword(email, userId);
setIsSuccess(true);
setError(null);
} catch (err) {
setIsSuccess(false);
setError('입력한 아이디와 일치하는 정보가 없습니다.');
}
};

return (
<div>
<h4>임시로 맹든 비밀번호 찾기</h4>
<form onSubmit={handleFindPassword}>
<input
type="email"
placeholder="이메일"
value={email}
onChange={(e) => setEmail(e.target.value)}
required
/>
<input
type="text"
placeholder="아이디"
value={userId}
onChange={(e) => setUserId(e.target.value)}
required
/>
<button type="submit">비밀번호 찾기</button>
</form>
{isSuccess && (
<div>입력하신 이메일로 임시비밀번호를 보냈습니다!</div>
)}
{error && <div style={{ color: 'red' }}>{error}</div>}
</div>
);
};

export default FindPw;

0 comments on commit b2e1ac3

Please sign in to comment.