import Link from "next/link";
import { LOCALES, type Locale } from "@/lib/i18n";

type LanguageSwitcherProps = {
  locale: Locale;
  path?: string;
};

const LABELS: Record<Locale, string> = {
  it: "Italiano",
  en: "English",
  es: "Espanol",
};

export function LanguageSwitcher({ locale, path = "" }: LanguageSwitcherProps) {
  return (
    <nav aria-label="Language switcher" className="lang-switcher">
      {LOCALES.map((item) => (
        <Link
          className={`lang-switcher__link ${item === locale ? "lang-switcher__link--active" : ""}`}
          href={`/${item}${path}`}
          key={item}
        >
          {LABELS[item]}
        </Link>
      ))}
    </nav>
  );
}
