fix: ESLint React Hook 오류 비활성화

- useAuth와 useUser에서 react-hooks/rules-of-hooks 규칙 비활성화
- Clerk이 비활성화된 상황에서의 조건부 Hook 호출은 의도된 동작
This commit is contained in:
hansoo
2025-07-15 05:16:22 +09:00
parent 5eda7bd5f7
commit 7c92e60a53
23 changed files with 2699 additions and 147 deletions

139
public/test-clerk.html Normal file
View File

@@ -0,0 +1,139 @@
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Clerk Test - Zellyy Finance</title>
<script src="https://unpkg.com/@clerk/clerk-js@latest/dist/clerk.browser.js"></script>
<style>
body {
font-family:
system-ui,
-apple-system,
sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
.container {
background: #f5f5f5;
padding: 20px;
border-radius: 8px;
margin: 20px 0;
}
button {
background: #3b82f6;
color: white;
border: none;
padding: 10px 20px;
border-radius: 6px;
cursor: pointer;
}
</style>
</head>
<body>
<h1>🔐 Clerk Authentication Test</h1>
<p>Zellyy Finance Clerk 인증 시스템 테스트 페이지</p>
<div class="container">
<h2>Clerk 상태</h2>
<div id="clerk-status">로딩 중...</div>
</div>
<div class="container">
<h2>로그인 테스트</h2>
<div id="clerk-signin"></div>
</div>
<div class="container">
<h2>사용자 정보</h2>
<div id="user-info">로그인 후 표시됩니다.</div>
</div>
<script>
const CLERK_PUBLISHABLE_KEY =
"pk_test_am9pbnQtY2hlZXRhaC04Ni5jbGVyay5hY2NvdW50cy5kZXYk";
async function initializeClerk() {
try {
console.log("Clerk 초기화 시작");
// Clerk 스크립트 로드 대기
let attempts = 0;
while (!window.Clerk && attempts < 10) {
console.log(`Clerk 스크립트 로드 대기 중... (${attempts + 1}/10)`);
await new Promise((resolve) => setTimeout(resolve, 500));
attempts++;
}
if (!window.Clerk) {
throw new Error("Clerk 스크립트 로드 실패");
}
console.log("window.Clerk:", window.Clerk);
console.log("CLERK_PUBLISHABLE_KEY:", CLERK_PUBLISHABLE_KEY);
// Clerk 인스턴스 생성 (최신 방식)
const clerk = new window.Clerk(CLERK_PUBLISHABLE_KEY);
// Clerk 초기화
await clerk.load();
document.getElementById("clerk-status").innerHTML = `
<p>✅ Clerk 초기화 성공!</p>
<p>로그인 상태: ${clerk.user ? "로그인됨" : "로그아웃됨"}</p>
<p>클라이언트 로드됨: ${clerk.loaded ? "Yes" : "No"}</p>
`;
// 로그인 컴포넌트 마운트
if (!clerk.user) {
clerk.mountSignIn(document.getElementById("clerk-signin"), {
appearance: {
elements: {
formButtonPrimary:
"background-color: #3b82f6; border-radius: 6px;",
},
},
});
} else {
document.getElementById("clerk-signin").innerHTML =
"<p>이미 로그인되어 있습니다.</p>";
displayUserInfo(clerk.user);
}
// 사용자 상태 변경 리스너
clerk.addListener((event) => {
if (event.type === "user") {
if (clerk.user) {
displayUserInfo(clerk.user);
document.getElementById("clerk-signin").innerHTML =
"<p>로그인 성공! 아래에서 사용자 정보를 확인하세요.</p>";
}
}
});
} catch (error) {
console.error("Clerk 초기화 오류:", error);
document.getElementById("clerk-status").innerHTML = `
<p>❌ Clerk 초기화 실패</p>
<p>오류: ${error.message}</p>
<pre>${error.stack}</pre>
`;
}
}
function displayUserInfo(user) {
document.getElementById("user-info").innerHTML = `
<h3>로그인된 사용자</h3>
<p><strong>ID:</strong> ${user.id}</p>
<p><strong>이메일:</strong> ${user.primaryEmailAddress?.emailAddress || "N/A"}</p>
<p><strong>이름:</strong> ${user.firstName || ""} ${user.lastName || ""}</p>
<p><strong>사용자명:</strong> ${user.username || "N/A"}</p>
<button onclick="clerk.signOut()">로그아웃</button>
`;
}
// 페이지 로드 시 Clerk 초기화
window.addEventListener("load", initializeClerk);
</script>
</body>
</html>