"use server"

import { cookies } from "next/headers"

export async function setOrgCookie(orgId: string | null) {
  const cookieStore = await cookies()
  if (orgId) {
    cookieStore.set("currentOrganizationId", orgId, {
      path: "/",
      httpOnly: true,
      sameSite: "lax",
      maxAge: 60 * 60 * 24 * 365, // 1 year
    })
  } else {
    cookieStore.delete("currentOrganizationId")
  }
}
