Refactoring
This commit is contained in:
parent
39cfada3e8
commit
dd14dfe72e
41 changed files with 866 additions and 742 deletions
125
apps/bridge-frontend/app/_config/webhooks.ts
Normal file
125
apps/bridge-frontend/app/_config/webhooks.ts
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
import { selectAllAction } from "@/app/_actions/service";
|
||||
import { ServiceConfig } from "@/app/_lib/service";
|
||||
|
||||
const tableLookup = {
|
||||
whatsapp: "WhatsappBot",
|
||||
facebook: "FacebookBot",
|
||||
signal: "SignalBot",
|
||||
};
|
||||
|
||||
export const webhooksConfig: ServiceConfig = {
|
||||
entity: "webhooks",
|
||||
table: "Webhook",
|
||||
displayName: "Webhook",
|
||||
createFields: [
|
||||
{
|
||||
name: "name",
|
||||
label: "Name",
|
||||
required: true,
|
||||
size: 12,
|
||||
},
|
||||
{
|
||||
name: "description",
|
||||
label: "Description",
|
||||
size: 12,
|
||||
lines: 3,
|
||||
},
|
||||
{
|
||||
name: "httpMethod",
|
||||
label: "HTTP Method",
|
||||
kind: "select",
|
||||
getOptions: async () => [
|
||||
{ value: "post", label: "POST" },
|
||||
{ value: "put", label: "PUT" },
|
||||
],
|
||||
defaultValue: "post",
|
||||
required: true,
|
||||
size: 2,
|
||||
},
|
||||
|
||||
{
|
||||
name: "endpointUrl",
|
||||
label: "Endpoint",
|
||||
required: true,
|
||||
size: 10,
|
||||
},
|
||||
{
|
||||
name: "backendType",
|
||||
label: "Backend Type",
|
||||
kind: "select",
|
||||
getOptions: async (_formState: any) => [
|
||||
{ value: "whatsapp", label: "WhatsApp" },
|
||||
{ value: "facebook", label: "Facebook" },
|
||||
{ value: "signal", label: "Signal" },
|
||||
],
|
||||
defaultValue: "facebook",
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: "backendId",
|
||||
label: "Backend ID",
|
||||
kind: "select",
|
||||
getOptions: async (formState: any) => {
|
||||
console.log({ formState });
|
||||
if (!formState || !formState.values.backendType) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// @ts-expect-error
|
||||
const table = tableLookup[formState.values.backendType];
|
||||
console.log({ table });
|
||||
const result = await selectAllAction(table);
|
||||
console.log({ result });
|
||||
|
||||
return result.map((item: any) => ({
|
||||
value: item.id,
|
||||
label: item.name,
|
||||
}));
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: "headers",
|
||||
label: "HTTP Headers",
|
||||
kind: "multi",
|
||||
size: 12,
|
||||
helperText: "Useful for including authentication headers",
|
||||
},
|
||||
],
|
||||
updateFields: [
|
||||
{ name: "name", label: "Name", required: true, size: 12 },
|
||||
{
|
||||
name: "description",
|
||||
label: "Description",
|
||||
required: true,
|
||||
size: 12,
|
||||
},
|
||||
],
|
||||
displayFields: [
|
||||
{ name: "name", label: "Name", required: true, size: 12 },
|
||||
{
|
||||
name: "description",
|
||||
label: "Description",
|
||||
required: true,
|
||||
size: 12,
|
||||
},
|
||||
],
|
||||
listColumns: [
|
||||
{
|
||||
field: "name",
|
||||
headerName: "Name",
|
||||
flex: 1,
|
||||
},
|
||||
{
|
||||
field: "description",
|
||||
headerName: "Description",
|
||||
flex: 2,
|
||||
},
|
||||
{
|
||||
field: "updatedAt",
|
||||
headerName: "Updated At",
|
||||
valueGetter: (value: any) => new Date(value).toLocaleString(),
|
||||
flex: 1,
|
||||
},
|
||||
],
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue