'use server';

import { cookies } from "next/headers";
import { cookieObject } from "@/apifetchers/basics";

/**
 * Server action to delete all access cookies at once
 * This is a direct server action that can be called from server components
 */
export async function deleteAllCookies() {
  try {
    const cookieStore = await cookies();
    if (cookieStore.has("eys-zzz")) { cookieStore.delete({ name: "eys-zzz", ...cookieObject }); }
    if (cookieStore.has("eys-yyy")) { cookieStore.delete({ name: "eys-yyy", ...cookieObject }); }
    if (cookieStore.has("eys-sel")) { cookieStore.delete({ name: "eys-sel", ...cookieObject }); }
    return true;
  } catch (error) { console.error("Error in deleteAllCookies:", error); return false }
}
