"use client";

import type { Locale } from "@/lib/i18n";

export function LanguageSwitcher({
  locale,
  label,
}: {
  locale: Locale;
  label: string;
}) {
  const nextLocale: Locale = locale === "fa" ? "en" : "fa";
  return (
    <button
      type="button"
      className="icon-button language-switcher"
      aria-label={label}
      title={label}
      onClick={() => {
        document.cookie = `capila_locale=${nextLocale}; Path=/; Max-Age=31536000; SameSite=Lax`;
        window.location.reload();
      }}
    >
      {nextLocale.toUpperCase()}
    </button>
  );
}
