"use server"; import { revalidatePath } from "next/cache"; import { createClient } from "@/lib/supabase/server"; type ActionResult = { success: boolean; error?: string }; export async function createPosition(payload: { title: string; superior_employee_id: string; is_lead: boolean; team_id?: string; }): Promise { const supabase = await createClient(); const { error } = await supabase.rpc("create_position", { payload }); if (error) return { success: false, error: error.message }; revalidatePath("/positions"); revalidatePath("/orgchart"); revalidatePath("/"); return { success: true }; } export async function staffPositionInternally(payload: { position_id: string; employee_id: string; }): Promise { const supabase = await createClient(); const { error } = await supabase.rpc("staff_position_internally", { payload }); if (error) return { success: false, error: error.message }; revalidatePath("/positions"); revalidatePath("/orgchart"); revalidatePath("/employees"); revalidatePath(`/employees/${payload.employee_id}`); revalidatePath("/"); return { success: true }; }