Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion apps/web/src/pages/auth/hooks/useSocialLogin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback } from 'react';
import { useCallback, useRef } from 'react';

import { useKakaoLogin } from '@/features/auth/model';

Expand Down Expand Up @@ -28,7 +28,24 @@ export const useSocialLogin = () => {
}
};

const isDisabledRef = useRef(false);
const timeoutRef = useRef<number | null>(null);

const preventMultipleClicks = (ms: number) => {
if (timeoutRef.current) {
window.clearTimeout(timeoutRef.current);
}

isDisabledRef.current = true;
timeoutRef.current = window.setTimeout(() => {
isDisabledRef.current = false;
timeoutRef.current = null;
}, ms);
};

const loginWithApple = () => {
if (isDisabledRef.current) return;
preventMultipleClicks(2000);
window.location.href = `${APPLE_AUTHORIZE_URL}&state=${window.location.origin}`;
};

Expand Down
Loading