diff --git a/solution/frontend/src/components/layout/AppShell.tsx b/solution/frontend/src/components/layout/AppShell.tsx index b78b597..d1d943c 100644 --- a/solution/frontend/src/components/layout/AppShell.tsx +++ b/solution/frontend/src/components/layout/AppShell.tsx @@ -2,7 +2,7 @@ import type {ComponentType, ReactNode} from 'react'; import {Link, NavLink, useLocation} from 'react-router'; import {LayoutGrid, LogOut, Search, Wand2} from 'lucide-react'; import {cn} from '@/lib/utils'; -import {useAuthStore} from '@/stores/auth'; +import {userLabel, useAuthStore} from '@/stores/auth'; export type NavItem = { to: string; @@ -60,7 +60,7 @@ export function AppShell({children, nav = OWNER_NAV}: {children: ReactNode; nav?
- {user?.name ?? user?.id} + {user ? userLabel(user) : ''} {user?.companyName ? ` · ${user.companyName}` : ''}
+ + )} +
diff --git a/solution/frontend/src/stores/auth.ts b/solution/frontend/src/stores/auth.ts index 50f291c..82fad43 100644 --- a/solution/frontend/src/stores/auth.ts +++ b/solution/frontend/src/stores/auth.ts @@ -31,6 +31,14 @@ export function toAuthUser(res: ResMe): AuthUser { }; } +/** + * 화면에 띄울 이름. 구글 계정의 로그인 아이디는 `google_` 라 그대로 보이면 안 된다 — + * 이름 → 이메일 순으로 떨어뜨리고 아이디는 마지막이다. + */ +export function userLabel(user: AuthUser): string { + return user.name || user.email || user.id; +} + interface AuthState { user: AuthUser | null; /** 부팅 시 저장된 토큰을 확인하기 전까지 true. 가드가 이 동안 리다이렉트를 미룬다. */