import { ActionFunction, json } from "@remix-run/node";
import { timezoneCookie } from "~/services/timezone.server";

export const action: ActionFunction = async ({ request }) => {
  const { timezone } = await request.json();

  const cookieHeader = await timezoneCookie.serialize(timezone);

  return json(
    { success: true },
    {
      headers: {
        "Set-Cookie": cookieHeader,
      },
    },
  );
};
