66 lines
1.2 KiB
TypeScript
66 lines
1.2 KiB
TypeScript
"use server";
|
|
|
|
import { addAction, updateAction, deleteAction } from "@/app/_lib/actions";
|
|
|
|
// write a function that returns the addRecordAction
|
|
|
|
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 (
|
|
currentState: any,
|
|
formData: FormData,
|
|
) => {
|
|
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 });
|
|
};
|