261103_03_ENH: 공유 인증 사용자 정보 동기화 및 프로젝트 접근 전환 개선
This commit is contained in:
19
src/components/app-shell/AuthSessionGate.tsx
Normal file
19
src/components/app-shell/AuthSessionGate.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
"use client";
|
||||
|
||||
import type { ReactNode } from "react";
|
||||
import { useAuthSession } from "@/hooks/useAuthSession";
|
||||
|
||||
export function AuthSessionGate({ children }: { children: ReactNode }) {
|
||||
const session = useAuthSession();
|
||||
const user = session.data;
|
||||
const checking = session.isPending || session.isFetching;
|
||||
const identity = user && JSON.stringify([user.userId, user.userRole, user.userTeam, user.userCmpn]);
|
||||
|
||||
return <>
|
||||
{session.isError && !checking && <div role="alert" className="p-8 text-center text-sm">
|
||||
<p>로그인 정보를 확인하지 못했습니다.</p>
|
||||
<button type="button" onClick={() => { void session.refetch(); }}>다시 시도</button>
|
||||
</div>}
|
||||
{user && <div key={identity} hidden={session.isError}>{children}</div>}
|
||||
</>;
|
||||
}
|
||||
Reference in New Issue
Block a user