import React from 'react'; import { Link, useLocation } from 'react-router-dom'; import { LogOut, Settings } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { cn } from '@/lib/utils'; import { apiFetch } from '@/lib/api'; import { useAuth } from '@/context/AuthContext'; /** * Signed-in user menu (sign-out, settings). Sign-in is handled by RequireAuth + SignIn page. */ export default function GoogleAuthBar() { const location = useLocation(); const { phase, googleOn, microsoftOn, user, refresh } = useAuth(); const logout = async () => { try { await apiFetch('/api/auth/logout', { method: 'POST' }); await refresh(); } catch (e) { console.error(e); } }; if (phase === 'loading' || (phase === 'ready' && !googleOn && !microsoftOn)) { if (phase === 'loading') { return (
); } return null; } if (phase === 'error' || !user) { return null; } const settingsActive = location.pathname === '/settings' || location.pathname.startsWith('/settings/'); return (
{user.picture ? ( ) : null} {user.name || user.email || 'Signed in'}
); }