'use client';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import { useLanguage } from '@/lib/language-context';
import { languages, Language, getTranslation } from '@/lib/translations';
import { useCustomerAuth } from '@/presentation/providers/customer-auth-provider';
import { Globe, LogIn, LogOut, Sparkles, UtensilsCrossed } from 'lucide-react';
export const LANGUAGE_BANNER_HEIGHT = 48;
export const LANGUAGE_BANNER_HEIGHT_LOGGED_IN_DESKTOP = 56;
export const LANGUAGE_BANNER_HEIGHT_LOGGED_IN_MOBILE = 160;
export const LANGUAGE_BANNER_HEIGHT_MENU_MANAGER_MOBILE = 160;
export const NAVBAR_HEIGHT = 68;
export function getLanguageBannerHeight(
isAuthenticated: boolean,
isMobile = false,
isMenuManager = false,
): number {
if (!isAuthenticated) return LANGUAGE_BANNER_HEIGHT;
if (isMobile) {
return isMenuManager
? LANGUAGE_BANNER_HEIGHT_MENU_MANAGER_MOBILE
: LANGUAGE_BANNER_HEIGHT_LOGGED_IN_MOBILE;
}
return LANGUAGE_BANNER_HEIGHT_LOGGED_IN_DESKTOP;
}
export function getHeaderTotalHeight(
isAuthenticated: boolean,
isMobile = false,
isMenuManager = false,
): number {
return getLanguageBannerHeight(isAuthenticated, isMobile, isMenuManager) + NAVBAR_HEIGHT;
}
/** @deprecated Use getHeaderTotalHeight() for dynamic height. */
export const HEADER_TOTAL_HEIGHT = LANGUAGE_BANNER_HEIGHT + NAVBAR_HEIGHT;
export default function LanguageSwitcher() {
const { language, setLanguage } = useLanguage();
const t = getTranslation(language);
const pathname = usePathname();
const { email, isAuthenticated, isMenuManager, logout } = useCustomerAuth();
const isLoginActive = !isAuthenticated && pathname === '/login';
const isAdminActive = pathname === '/admin';
const emailInitial = email?.charAt(0).toUpperCase() ?? '?';
const handleSelect = (lang: Language) => {
setLanguage(lang);
};
const handleLogout = async () => {
await logout();
};
const loginButton = (
{t.nav.login}
Login
);
const menuManagementLink = (variant: 'desktop' | 'mobile' | 'mobile-full' = 'desktop') => (
{variant === 'mobile' ? 'Menu' : t.auth.customer.menuManagement}
);
const logoutButton = (variant: 'desktop' | 'mobile' | 'mobile-full' = 'desktop') => (
);
return (
{/* ── Row 1: languages (+ desktop auth inline) ── */}
Language
{languages.map((lang) => {
const isActive = language === lang.code;
return (
);
})}
{/* Desktop: guest login OR logged-in account strip (single row, no clipping) */}
{!isAuthenticated ? (
loginButton
) : (
{t.auth.customer.loggedInAs}
{email}
{isMenuManager && menuManagementLink('desktop')}
{logoutButton('desktop')}
)}
{/* Mobile guest: login icon only */}
{!isAuthenticated &&
{loginButton}
}
{/* ── Mobile logged-in: creative account card ── */}
{isAuthenticated && (
{emailInitial}
{t.auth.customer.loggedInAs}
{email}
{isMenuManager && menuManagementLink('mobile-full')}
{logoutButton('mobile-full')}
)}
);
}