/**
 * Language switcher — toggle EN ↔ pt-br using a cookie.
 * Server reads the cookie in getLocale(); client component sets it.
 */
import { cookies } from "next/headers";
import { LocaleToggleClient } from "./locale-toggle-client";

export type Locale = "en" | "pt-br";

export async function getLocale(): Promise<Locale> {
  const store = await cookies();
  const v = store.get("locale")?.value;
  return v === "en" ? "en" : "pt-br";
}

export function LocaleToggle({ current }: { current: Locale }) {
  return <LocaleToggleClient current={current} />;
}
