link-stack/apps/bridge-frontend/app/(main)/[...segment]/_actions/facebook.ts

67 lines
1.2 KiB
TypeScript
Raw Normal View History

2024-04-24 21:44:05 +02:00
"use server";
2024-04-25 12:31:03 +02:00
import { addAction, updateAction, deleteAction } from "@/app/_lib/actions";
2024-04-26 14:31:33 +02:00
// write a function that returns the addRecordAction
2024-04-24 21:44:05 +02:00
2024-04-26 14:31:33 +02:00
export function generateAddRecordAction(
entity: string,
table: string,
fields: string[],
) {
// The returned function matches the signature of addRecordAction, but uses the parameters from the outer function.
return async (currentState: any, formData: FormData) => {
return addAction({
entity,
table,
fields,
currentState,
formData,
});
};
}
export const addRecordAction = async (
2024-04-24 21:44:05 +02:00
currentState: any,
formData: FormData,
) => {
2024-04-25 12:31:03 +02:00
return addAction({
entity,
table,
fields: [
"name",
"description",
"appId",
"appSecret",
"pageId",
"pageAccessToken",
],
currentState,
formData,
});
};
2024-04-24 21:44:05 +02:00
2024-04-25 12:31:03 +02:00
export const updateFacebookBotAction = async (
currentState: any,
formData: FormData,
) => {
return updateAction({
entity,
table,
fields: [
"name",
"description",
"appId",
"appSecret",
"pageId",
"pageAccessToken",
],
currentState,
formData,
});
};
2024-04-24 21:44:05 +02:00
2024-04-25 12:31:03 +02:00
export const deleteFacebookBotAction = async (id: string) => {
return deleteAction({ entity, table, id });
2024-04-24 21:44:05 +02:00
};