Skip to content

Commit 682081b

Browse files
committed
fix: 로그인 버튼 연속 클릭 방지 및 텍스트 조건부로 추가
1 parent 30f6e99 commit 682081b

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

components/auth/Button.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ type ButtonProps = {
77
className?: string;
88
type?: 'button' | 'submit';
99
onClick?: () => void;
10+
disabled?: boolean;
1011
};
1112

1213
const Button = ({
@@ -15,11 +16,13 @@ const Button = ({
1516
className,
1617
type = 'button',
1718
onClick,
19+
disabled,
1820
}: ButtonProps) => {
1921
return (
2022
<button
2123
type={type}
2224
onClick={onClick}
25+
disabled={disabled}
2326
className={clsx(
2427
'h-12 w-full cursor-pointer rounded-lg text-base font-medium transition-all duration-150 active:scale-[0.98]',
2528

components/auth/LoginForm.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const LoginForm = ({ handleOpenModal }: LoginFormProps) => {
2222
const [email, setEmail] = useState('');
2323
const [password, setPassword] = useState('');
2424
const [error, setError] = useState('');
25+
const [isLoading, setIsLoading] = useState(false);
2526

2627
const router = useRouter();
2728

@@ -48,9 +49,13 @@ const LoginForm = ({ handleOpenModal }: LoginFormProps) => {
4849
e.preventDefault();
4950
setError('');
5051

52+
if (isLoading) return;
53+
setIsLoading(true);
54+
5155
// 유효성 검사
5256
if (!email || !password) {
5357
setError('이메일과 비밀번호를 모두 입력해주세요.');
58+
setIsLoading(false);
5459
return;
5560
}
5661

@@ -65,6 +70,7 @@ const LoginForm = ({ handleOpenModal }: LoginFormProps) => {
6570
} catch (err) {
6671
console.error('로그인 에러:', err);
6772
setError('이메일 또는 비밀번호가 잘못되었습니다.');
73+
setIsLoading(false);
6874
}
6975
};
7076

@@ -99,7 +105,7 @@ const LoginForm = ({ handleOpenModal }: LoginFormProps) => {
99105
비밀번호를 잊으셨나요?
100106
</button>
101107
<Button className="mt-6" type="submit">
102-
이메일로 로그인하기
108+
{isLoading ? '로그인 중...' : '이메일로 로그인하기'}
103109
</Button>
104110

105111
<p className="text-text-sub mt-4 text-center text-sm">
@@ -117,7 +123,12 @@ const LoginForm = ({ handleOpenModal }: LoginFormProps) => {
117123
<div className="bg-border h-px flex-1" />
118124
</div>
119125

120-
<Button variant="github" onClick={handleGithubLogin} type="button">
126+
<Button
127+
variant="github"
128+
onClick={handleGithubLogin}
129+
type="button"
130+
disabled={isLoading}
131+
>
121132
<FaGithub className="text-xl" />
122133
<span>Github로 로그인</span>
123134
</Button>

0 commit comments

Comments
 (0)