"use server" import { revalidatePath } from "next/cache" import { getSessionUser } from "@/lib/session" import { getAccountContext } from "@/lib/account" import { sendLeaseForSignature, getAdapter, type ESignProvider } from "@/lib/esign" export async function sendLeaseForSignatureAction(leaseId: string, provider: string) { const user = await getSessionUser() if (!user) throw new Error("Unauthorized") const ctx = await getAccountContext(user.id) if (!ctx.canWrite) throw new Error("You don't have permission to do that") if (!getAdapter(provider)) throw new Error("Unknown provider") await sendLeaseForSignature(ctx.ownerId, leaseId, provider as ESignProvider) revalidatePath(`/leases/${leaseId}`) return { ok: true } }