'use client';

import { useLocale } from 'next-intl';
import { Link, usePathname } from '@/i18n/navigation';
import type { Locale } from '@/i18n/routing';

type LocaleSwitcherProps = { label: string; ariaLabel: string };

export function LocaleSwitcher({ label, ariaLabel }: LocaleSwitcherProps) {
  const pathname = usePathname();
  const target: Locale = useLocale() === 'ar' ? 'en' : 'ar';

  return (
    <Link
      href={pathname}
      locale={target}
      hrefLang={target}
      lang={target}
      aria-label={ariaLabel}
      className="inline-flex min-h-11 min-w-11 items-center justify-center px-2 text-sm text-bone transition-colors duration-300 hover:text-gold-hi"
    >
      {label}
    </Link>
  );
}
