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 4964194 commit c4c7a03
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/pages/findId.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { useState } from 'react';
import { findId } from '../api/userApi';

const FindId = () => {
const [email, setEmail] = useState('');
const [nickname, setNickname] = useState('');
const [foundUserId, setFoundUserId] = useState(null);
const [error, setError] = useState(null);

const handleFindUserId = async (e) => {
e.preventDefault();
try {
const userId = await findId(email, nickname);
setFoundUserId(userId);
setError(null);
} catch (err) {
setFoundUserId(null);
setError('사용자를 찾을 수 없습니다.');
}
};

console.log(foundUserId);

return (
<div>
<h4>임시로 맹든 아이디 찾기</h4>
<form onSubmit={handleFindUserId}>
<input
type="email"
placeholder="이메일"
value={email}
onChange={(e) => setEmail(e.target.value)}
required
/>
<input
type="text"
placeholder="닉네임"
value={nickname}
onChange={(e) => setNickname(e.target.value)}
required
/>
<button type="submit">아이디 찾기</button>
</form>
{foundUserId && <div>찾은 아이디: {foundUserId}</div>}
{error && <div style={{ color: 'red' }}>{error}</div>}
</div>
);
};

export default FindId;

0 comments on commit c4c7a03

Please sign in to comment.