Edit and actions updates
This commit is contained in:
parent
0997e449bb
commit
f87bcc43a5
30 changed files with 759 additions and 139 deletions
|
|
@ -1,28 +1,50 @@
|
|||
"use server";
|
||||
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { db } from "@/app/_lib/database";
|
||||
import { addAction, updateAction, deleteAction } from "@/app/_lib/actions";
|
||||
|
||||
const entity = "facebook";
|
||||
const table = "FacebookBot";
|
||||
|
||||
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,
|
||||
};
|
||||
return addAction({
|
||||
entity,
|
||||
table,
|
||||
fields: [
|
||||
"name",
|
||||
"description",
|
||||
"appId",
|
||||
"appSecret",
|
||||
"pageId",
|
||||
"pageAccessToken",
|
||||
],
|
||||
currentState,
|
||||
formData,
|
||||
});
|
||||
};
|
||||
|
||||
export const updateFacebookBotAction = async (
|
||||
currentState: any,
|
||||
formData: FormData,
|
||||
) => {
|
||||
return updateAction({
|
||||
entity,
|
||||
table,
|
||||
fields: [
|
||||
"name",
|
||||
"description",
|
||||
"appId",
|
||||
"appSecret",
|
||||
"pageId",
|
||||
"pageAccessToken",
|
||||
],
|
||||
currentState,
|
||||
formData,
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteFacebookBotAction = async (id: string) => {
|
||||
return deleteAction({ entity, table, id });
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue