'use client';

import { usePathname } from 'next/navigation';
import { SiteHeader } from './SiteHeader';
import { AuthHeader } from './AuthHeader';
import { routeIdFromPathname } from '@/lib/localization/config';
import type { ShellMessages } from '@/lib/localization/messages';
import type { Locale } from '@/lib/localization/config';
import type { ThemePreference } from '@/lib/theme/config';

interface Props {
  locale: Locale;
  messages: ShellMessages;
  themePreference: ThemePreference;
}

export function HeaderRouter({ locale, messages, themePreference }: Props) {
  const pathname = usePathname();
  const routeId = routeIdFromPathname(pathname);
  const isAuth = routeId === 'sign-in' || routeId === 'forgot-password';

  if (isAuth) {
    return <AuthHeader locale={locale} themePreference={themePreference} />;
  }

  return <SiteHeader locale={locale} messages={messages} themePreference={themePreference} />;
}
