// frontend/components/Topbar.tsx "use client"; import { useEffect, useState } from "react"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { MAIN } from "@/lib/nav"; import { getMe } from "@/lib/auth"; import { Icon } from "./Icon"; import { ThemeToggle } from "./ThemeToggle"; // 사용자 이니셜 (원본 data.js: user.initial === "지") — 인증 꺼짐일 땐 항상 이 값. const USER_INITIAL = "지"; const AUTH_ENABLED = process.env.NEXT_PUBLIC_AUTH_ENABLED === "true"; export function Topbar() { const pathname = usePathname(); // 데모 무손상: 인증 꺼짐이면 "지" 고정(fetch 없음). 켜졌을 때만 GET /me 로 갱신. const [initial, setInitial] = useState(USER_INITIAL); useEffect(() => { if (!AUTH_ENABLED) return; const ac = new AbortController(); getMe(ac.signal) .then((me) => { if (me) setInitial(me.initial); }) .catch(() => {}); return () => ac.abort(); }, []); return (
아리 AI LIFE OS
{initial}
); }