"use server"; import { revalidatePath } from "next/cache"; import { db } from "@/app/_lib/database"; export const addFacebookBotAction = async ( currentState: any, formData: FormData, ) => { const newBot = { name: formData.get("name")?.toString() ?? null, description: formData.get("description")?.toString() ?? null, appId: formData.get("appId")?.toString() ?? null, appSecret: formData.get("appSecret")?.toString() ?? null, pageId: formData.get("pageId")?.toString() ?? null, pageAccessToken: formData.get("pageAccessToken")?.toString() ?? null, }; await db.insertInto("FacebookBot").values(newBot).execute(); revalidatePath("/facebook"); return { ...currentState, values: newBot, success: true, }; };