17 lines
408 B
TypeScript
17 lines
408 B
TypeScript
"use server";
|
|
|
|
import { cookies } from "next/headers";
|
|
import { LOCALE_COOKIE, isLocale, type Locale } from "./locales";
|
|
|
|
export async function setLocaleCookie(locale: Locale): Promise<void> {
|
|
if (!isLocale(locale)) {
|
|
return;
|
|
}
|
|
const store = await cookies();
|
|
store.set(LOCALE_COOKIE, locale, {
|
|
path: "/",
|
|
maxAge: 60 * 60 * 24 * 365,
|
|
sameSite: "lax",
|
|
});
|
|
}
|