Finish bridge generalization

This commit is contained in:
Darren Clarke 2024-04-26 15:49:58 +02:00
parent cb7a3a08dc
commit cca8d03988
93 changed files with 634 additions and 2085 deletions

View file

@ -7,6 +7,7 @@ import { TextField } from "ui";
import { Create as InternalCreate } from "@/app/_components/Create";
import { generateCreateAction } from "@/app/_lib/actions";
import { serviceConfig } from "@/app/_lib/config";
import { FieldDescription } from "@/app/_lib/service";
type CreateProps = {
service: string;
@ -16,18 +17,18 @@ export const Create: FC<CreateProps> = ({ service }) => {
const {
[service]: { entity, table, displayName, createFields: fields },
} = serviceConfig;
const createFieldNames = fields.map((val) => val.name);
const createAction = generateCreateAction({ entity, table, fields });
const initialState = {
message: null,
errors: {},
values: createFieldNames.reduce((acc, key) => {
// @ts-expect-error
acc[key] = fields[key].defaultValue;
return acc;
}, {}),
values: fields.reduce(
(acc: Record<string, any>, field: FieldDescription) => {
acc[field.name] = field.defaultValue;
return acc;
},
{},
),
};
console.log("initialState", initialState);
const [formState, formAction] = useFormState(createAction, initialState);
return (
@ -39,11 +40,11 @@ export const Create: FC<CreateProps> = ({ service }) => {
>
<Grid container direction="row" rowSpacing={3} columnSpacing={2}>
{fields.map((field) => (
<Grid item xs={field.size ?? 6}>
<Grid key={field.name} item xs={field.size ?? 6}>
<TextField
key={field.name}
name={field.name}
label={field.label}
lines={field.lines ?? 1}
required={field.required ?? false}
formState={formState}
helperText={field.helperText}

View file

@ -1,9 +1,11 @@
import { Create } from "./_components/Create";
type PageProps = {
params: { service: string };
params: { segment: string[] };
};
export default function Page({ params: { service } }: PageProps) {
export default function Page({ params: { segment } }: PageProps) {
const service = segment[0];
return <Create service={service} />;
}

View file

@ -29,7 +29,7 @@ export const Detail: FC<DetailProps> = ({ service, row }) => {
>
<Grid container direction="row" rowSpacing={3} columnSpacing={2}>
{fields.map((field) => (
<Grid item xs={6} key={field.name}>
<Grid item xs={field.size ?? 6} key={field.name}>
<DisplayTextField
name={field.name}
label={field.label}

View file

@ -3,11 +3,12 @@ import { serviceConfig } from "@/app/_lib/config";
import { Detail } from "./_components/Detail";
type Props = {
params: { service: string; segment: string[] };
params: { segment: string[] };
};
export default async function Page({ params: { service, segment } }: Props) {
const id = segment?.[0];
export default async function Page({ params: { segment } }: Props) {
const service = segment[0];
const id = segment?.[1];
if (!id) return null;

View file

@ -21,14 +21,15 @@ export const Edit: FC<EditProps> = ({ service, row }) => {
} = serviceConfig;
const updateFieldNames = fields.map((val) => val.name);
const updateAction = generateUpdateAction({ entity, table, fields });
const updateValues = Object.fromEntries(
Object.entries(row).filter(([key]) => updateFieldNames.includes(key)),
);
updateValues.id = row.id;
const initialState = {
message: null,
errors: {},
values: Object.fromEntries(
Object.entries(row).filter(([key]) => updateFieldNames.includes(key)),
),
values: updateValues,
};
console.log("initialState", initialState);
const [formState, formAction] = useFormState(updateAction, initialState);
return (
@ -40,11 +41,11 @@ export const Edit: FC<EditProps> = ({ service, row }) => {
>
<Grid container direction="row" rowSpacing={3} columnSpacing={2}>
{fields.map((field) => (
<Grid item xs={field.size ?? 6}>
<Grid key={field.name} item xs={field.size ?? 6}>
<TextField
key={field.name}
name={field.name}
label={field.label}
lines={field.lines ?? 1}
required={field.required ?? false}
formState={formState}
helperText={field.helperText}

View file

@ -3,13 +3,12 @@ import { serviceConfig } from "@/app/_lib/config";
import { Edit } from "./_components/Edit";
type PageProps = {
params: { service: string; segment: string[] };
params: { segment: string[] };
};
export default async function Page({
params: { service, segment },
}: PageProps) {
const id = segment?.[0];
export default async function Page({ params: { segment } }: PageProps) {
const service = segment[0];
const id = segment?.[1];
if (!id) return null;

View file

@ -1,66 +0,0 @@
"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 });
};

View file

@ -16,7 +16,7 @@ export const List: FC<ListProps> = ({ service, rows }) => {
return (
<InternalList
title={displayName}
title={`${displayName}s`}
entity={entity}
rows={rows}
columns={listColumns}

View file

@ -8,13 +8,13 @@ type ServiceLayoutProps = {
};
};
export const ServiceLayout = ({
export default function ServiceLayout({
children,
detail,
edit,
create,
params: { segment },
}: ServiceLayoutProps) => {
}: ServiceLayoutProps) {
const length = segment?.length ?? 0;
const isCreate = length === 2 && segment[1] === "create";
const isEdit = length === 3 && segment[2] === "edit";
@ -29,4 +29,4 @@ export const ServiceLayout = ({
{isCreate && create}
</>
);
};
}

View file

@ -1,19 +1,18 @@
// import { List } from "./_components/List";
// import { db } from "@/app/_lib/database";
// import { serviceConfig } from "@/app/_lib/config";
import { List } from "./_components/List";
import { db } from "@/app/_lib/database";
import { serviceConfig } from "@/app/_lib/config";
type PageProps = {
params: {
service: string;
segment: string[];
};
};
export default async function Page({ params: { service } }: PageProps) {
console.log({ service });
export default async function Page({ params: { segment } }: PageProps) {
const service = segment[0];
return <h1> Nice</h1>;
// const config = serviceConfig[service];
// const rows = await db.selectFrom(config.table).selectAll().execute();
const config = serviceConfig[service];
const rows = await db.selectFrom(config.table).selectAll().execute();
// return <List service={service} rows={rows} />;
return <List service={service} rows={rows} />;
}

View file

@ -1,83 +0,0 @@
"use client";
import { FC } from "react";
import { useFormState } from "react-dom";
import { Grid } from "@mui/material";
import { TextField } from "ui";
import { Create as InternalCreate } from "@/app/_components/Create";
import { addFacebookBotAction } from "../../_actions/facebook";
export const Create: FC = () => {
const initialState = {
message: null,
errors: {},
values: {
name: "",
description: "",
one: "",
},
};
const [formState, formAction] = useFormState(
addFacebookBotAction,
initialState,
);
return (
<InternalCreate
title="Create Facebook Connection"
entity="facebook"
formAction={formAction}
formState={formState}
>
<Grid container direction="row" rowSpacing={3} columnSpacing={2}>
<Grid item xs={12}>
<TextField name="name" label="Name" required formState={formState} />
</Grid>
<Grid item xs={12}>
<TextField
name="description"
label="Description"
formState={formState}
lines={3}
/>
</Grid>
<Grid item xs={6}>
<TextField
name="appId"
label="App ID"
required
formState={formState}
helperText="Get it from Facebook Developer Console"
/>
</Grid>
<Grid item xs={6}>
<TextField
name="appSecret"
label="App Secret"
required
formState={formState}
helperText="Get it from Facebook Developer Console"
/>
</Grid>
<Grid item xs={6}>
<TextField
name="pageId"
label="Page ID"
required
formState={formState}
helperText="Get it from Facebook Developer Console"
/>
</Grid>
<Grid item xs={6}>
<TextField
name="pageAccessToken"
label="Page Access Token"
required
formState={formState}
helperText="Get it from Facebook Developer Console"
/>
</Grid>
</Grid>
</InternalCreate>
);
};

View file

@ -1,5 +0,0 @@
import { Create } from "./_components/Create";
export default function Page() {
return <Create />;
}

View file

@ -1,56 +0,0 @@
"use client";
import { FC } from "react";
import { Grid } from "@mui/material";
import { DisplayTextField } from "ui";
import { FacebookBot } from "@/app/_lib/database";
import { Detail as InternalDetail } from "@/app/_components/Detail";
import { deleteFacebookBotAction } from "../../_actions/facebook";
type DetailProps = {
row: FacebookBot;
};
export const Detail: FC<DetailProps> = ({ row }) => (
<InternalDetail
title={`Facebook Connection: ${row.name}`}
entity="facebook"
id={row.id}
deleteAction={deleteFacebookBotAction}
>
<Grid container direction="row" rowSpacing={3} columnSpacing={2}>
<Grid item xs={12}>
<DisplayTextField name="name" label="Name" value={row.name} />
</Grid>
<Grid item xs={12}>
<DisplayTextField
name="description"
label="Description"
lines={3}
value={row.description}
/>
</Grid>
<Grid item xs={6}>
<DisplayTextField name="appId" label="App ID" value={row.appId} />
</Grid>
<Grid item xs={6}>
<DisplayTextField
name="appSecret"
label="App Secret"
value={row.appSecret}
copyable
/>
</Grid>
<Grid item xs={6}>
<DisplayTextField name="pageId" label="Page ID" value={row.pageId} />
</Grid>
<Grid item xs={6}>
<DisplayTextField
name="pageAccessToken"
label="Page Access Token"
value={row.pageAccessToken}
/>
</Grid>
</Grid>
</InternalDetail>
);

View file

@ -1,24 +0,0 @@
import { db } from "@/app/_lib/database";
import { Detail } from "./_components/Detail";
export const dynamic = "force-dynamic";
type Props = {
params: { segment: string[] };
};
export default async function Page({ params: { segment } }: Props) {
const id = segment?.[0];
if (!id) return null;
const row = await db
.selectFrom("FacebookBot")
.selectAll()
.where("id", "=", id)
.executeTakeFirst();
if (!row) return null;
return <Detail row={row} />;
}

View file

@ -1,105 +0,0 @@
"use client";
import { FC } from "react";
import { useFormState } from "react-dom";
import { Grid } from "@mui/material";
import { TextField } from "ui";
import { FacebookBot } from "@/app/_lib/database";
import { Edit as InternalEdit } from "@/app/_components/Edit";
import { updateFacebookBotAction } from "../../_actions/facebook";
type EditProps = {
row: FacebookBot;
};
export const Edit: FC<EditProps> = ({ row }) => {
const initialState = {
message: null,
errors: {},
values: row,
};
const [formState, formAction] = useFormState(
updateFacebookBotAction,
initialState,
);
return (
<InternalEdit
title={`Edit Facebook Connection: ${row.name}`}
entity="facebook"
formAction={formAction}
formState={formState}
>
<Grid container direction="row" rowSpacing={3} columnSpacing={2}>
<Grid item xs={12}>
<TextField name="name" label="Name" required formState={formState} />
</Grid>
<Grid item xs={12}>
<TextField
name="description"
label="Description"
formState={formState}
lines={3}
/>
</Grid>
<Grid item xs={6}>
<TextField
name="token"
label="Token"
disabled
formState={formState}
refreshable
helperText="Token used to authenticate requests from Link"
/>
</Grid>
<Grid item xs={6}>
<TextField
name="verifyToken"
label="Verify Token"
disabled
formState={formState}
refreshable
helperText="Token used to authenticate requests from Facebook"
/>
</Grid>
<Grid item xs={6}>
<TextField
name="appId"
label="App ID"
required
formState={formState}
helperText="App ID of your approved Facebook application"
/>
</Grid>
<Grid item xs={6}>
<TextField
name="appSecret"
label="App Secret"
required
formState={formState}
helperText="App Secret of your approved Facebook application"
/>
</Grid>
<Grid item xs={6}>
<TextField
name="pageId"
label="Page ID"
required
formState={formState}
helperText="Page ID of the Facebook page that will receive messages"
/>
</Grid>
<Grid item xs={6}>
<TextField
name="pageAccessToken"
label="Page Access Token"
required
formState={formState}
helperText="Access Token of the Facbook page that will receive messages"
/>
</Grid>
</Grid>
</InternalEdit>
);
};

View file

@ -1,24 +0,0 @@
import { db } from "@/app/_lib/database";
import { Edit } from "./_components/Edit";
export const dynamic = "force-dynamic";
type Props = {
params: { segment: string[] };
};
export default async function Page({ params: { segment } }: Props) {
const id = segment?.[0];
if (!id) return null;
const row = await db
.selectFrom("FacebookBot")
.selectAll()
.where("id", "=", id)
.executeTakeFirst();
if (!row) return null;
return <Edit row={row} />;
}

View file

@ -1,50 +0,0 @@
"use server";
import { addAction, updateAction, deleteAction } from "@/app/_lib/actions";
const entity = "facebook";
const table = "FacebookBot";
export const addFacebookBotAction = 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 });
};

View file

@ -1,39 +0,0 @@
"use client";
import { FC } from "react";
import { GridColDef } from "@mui/x-data-grid-pro";
import { List } from "@/app/_components/List";
type FacebookBotsListProps = {
rows: any[];
};
export const FacebookBotsList: FC<FacebookBotsListProps> = ({ rows }) => {
const columns: GridColDef[] = [
{
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,
},
];
return (
<List
title="Facebook Connections"
entity="facebook"
rows={rows}
columns={columns}
/>
);
};

View file

@ -1,3 +0,0 @@
import { ServiceLayout } from "@/app/_components/ServiceLayout";
export default ServiceLayout;

View file

@ -1,10 +0,0 @@
import { FacebookBotsList } from "./_components/FacebookBotsList";
import { db } from "@/app/_lib/database";
export const dynamic = "force-dynamic";
export default async function Page() {
const rows = await db.selectFrom("FacebookBot").selectAll().execute();
return <FacebookBotsList rows={rows} />;
}

View file

@ -1,47 +0,0 @@
"use client";
import { FC } from "react";
import { useFormState } from "react-dom";
import { Grid } from "@mui/material";
import { TextField } from "ui";
import { Create as InternalCreate } from "@/app/_components/Create";
import { addSignalBotAction } from "../../_actions/signal";
export const Create: FC = () => {
const initialState = {
message: null,
errors: {},
values: {
name: "",
description: "",
one: "",
},
};
const [formState, formAction] = useFormState(
addSignalBotAction,
initialState,
);
return (
<InternalCreate
title="Create Signal Connection"
entity="signal"
formAction={formAction}
formState={formState}
>
<Grid container direction="row" rowSpacing={3} columnSpacing={2}>
<Grid item xs={12}>
<TextField name="name" label="Name" required formState={formState} />
</Grid>
<Grid item xs={12}>
<TextField
name="description"
label="Description"
formState={formState}
lines={3}
/>
</Grid>
</Grid>
</InternalCreate>
);
};

View file

@ -1,5 +0,0 @@
import { Create } from "./_components/Create";
export default function Page() {
return <Create />;
}

View file

@ -1,35 +0,0 @@
"use client";
import { FC } from "react";
import { Grid } from "@mui/material";
import { DisplayTextField } from "ui";
import { SignalBot } from "@/app/_lib/database";
import { Detail as InternalDetail } from "@/app/_components/Detail";
import { deleteSignalBotAction } from "../../_actions/signal";
type DetailProps = {
row: SignalBot;
};
export const Detail: FC<DetailProps> = ({ row }) => (
<InternalDetail
title={`Signal Connection: ${row.name}`}
entity="signal"
id={row.id}
deleteAction={deleteSignalBotAction}
>
<Grid container direction="row" rowSpacing={3} columnSpacing={2}>
<Grid item xs={12}>
<DisplayTextField name="name" label="Name" value={row.name} />
</Grid>
<Grid item xs={12}>
<DisplayTextField
name="description"
label="Description"
lines={3}
value={row.description}
/>
</Grid>
</Grid>
</InternalDetail>
);

View file

@ -1,24 +0,0 @@
import { db } from "@/app/_lib/database";
import { Detail } from "./_components/Detail";
export const dynamic = "force-dynamic";
type Props = {
params: { segment: string[] };
};
export default async function Page({ params: { segment } }: Props) {
const id = segment?.[0];
if (!id) return null;
const row = await db
.selectFrom("SignalBot")
.selectAll()
.where("id", "=", id)
.executeTakeFirst();
if (!row) return null;
return <Detail row={row} />;
}

View file

@ -1,48 +0,0 @@
"use client";
import { FC } from "react";
import { useFormState } from "react-dom";
import { Grid } from "@mui/material";
import { TextField } from "ui";
import { SignalBot } from "@/app/_lib/database";
import { Edit as InternalEdit } from "@/app/_components/Edit";
import { updateSignalBotAction } from "../../_actions/signal";
type EditProps = {
row: SignalBot;
};
export const Edit: FC<EditProps> = ({ row }) => {
const initialState = {
message: null,
errors: {},
values: row,
};
const [formState, formAction] = useFormState(
updateSignalBotAction,
initialState,
);
return (
<InternalEdit
title={`Edit Signal Connection: ${row.name}`}
entity="signal"
formAction={formAction}
formState={formState}
>
<Grid container direction="row" rowSpacing={3} columnSpacing={2}>
<Grid item xs={12}>
<TextField name="name" label="Name" required formState={formState} />
</Grid>
<Grid item xs={12}>
<TextField
name="description"
label="Description"
formState={formState}
lines={3}
/>
</Grid>
</Grid>
</InternalEdit>
);
};

View file

@ -1,24 +0,0 @@
import { db } from "@/app/_lib/database";
import { Edit } from "./_components/Edit";
export const dynamic = "force-dynamic";
type Props = {
params: { segment: string[] };
};
export default async function Page({ params: { segment } }: Props) {
const id = segment?.[0];
if (!id) return null;
const row = await db
.selectFrom("SignalBot")
.selectAll()
.where("id", "=", id)
.executeTakeFirst();
if (!row) return null;
return <Edit row={row} />;
}

View file

@ -1,36 +0,0 @@
"use server";
import { addAction, updateAction, deleteAction } from "@/app/_lib/actions";
const entity = "signal";
const table = "SignalBot";
export const addSignalBotAction = async (
currentState: any,
formData: FormData,
) => {
return addAction({
entity,
table,
fields: ["name", "description"],
currentState,
formData,
});
};
export const updateSignalBotAction = async (
currentState: any,
formData: FormData,
) => {
return updateAction({
entity,
table,
fields: ["name"],
currentState,
formData,
});
};
export const deleteSignalBotAction = async (id: string) => {
return deleteAction({ entity, table, id });
};

View file

@ -1,45 +0,0 @@
"use client";
import { FC } from "react";
import { GridColDef } from "@mui/x-data-grid-pro";
import { List } from "@/app/_components/List";
type SignalBotsListProps = {
rows: any[];
};
export const SignalBotsList: FC<SignalBotsListProps> = ({ rows }) => {
const columns: GridColDef[] = [
{
field: "name",
headerName: "Name",
flex: 1,
},
{
field: "phoneNumber",
headerName: "Phone Number",
flex: 1,
},
{
field: "description",
headerName: "Description",
flex: 2,
},
{
field: "updatedAt",
headerName: "Updated At",
valueGetter: (params: any) =>
new Date(params.row?.updatedAt).toLocaleString(),
flex: 1,
},
];
return (
<List
title="Signal Connections"
entity="signal"
rows={rows}
columns={columns}
/>
);
};

View file

@ -1,3 +0,0 @@
import { ServiceLayout } from "@/app/_components/ServiceLayout";
export default ServiceLayout;

View file

@ -1,10 +0,0 @@
import { SignalBotsList } from "./_components/SignalBotsList";
import { db } from "@/app/_lib/database";
export const dynamic = "force-dynamic";
export default async function Page() {
const rows = await db.selectFrom("SignalBot").selectAll().execute();
return <SignalBotsList rows={rows} />;
}

View file

@ -1,36 +0,0 @@
"use client";
import { FC } from "react";
import { useFormState } from "react-dom";
import { Grid } from "@mui/material";
import { TextField } from "ui";
import { Create as InternalCreate } from "@/app/_components/Create";
import { addUserAction } from "../../_actions/users";
export const Create: FC = () => {
const initialState = {
message: null,
errors: {},
values: {
name: "",
description: "",
one: "",
},
};
const [formState, formAction] = useFormState(addUserAction, initialState);
return (
<InternalCreate
title="Create User"
entity="users"
formAction={formAction}
formState={formState}
>
<Grid container direction="row" rowSpacing={3} columnSpacing={2}>
<Grid item xs={12}>
<TextField name="name" label="Name" required formState={formState} />
</Grid>
</Grid>
</InternalCreate>
);
};

View file

@ -1,5 +0,0 @@
import { Create } from "./_components/Create";
export default function Page() {
return <Create />;
}

View file

@ -1,27 +0,0 @@
"use client";
import { FC } from "react";
import { Grid } from "@mui/material";
import { DisplayTextField } from "ui";
import { User } from "@/app/_lib/database";
import { Detail as InternalDetail } from "@/app/_components/Detail";
import { deleteUserAction } from "../../_actions/users";
type DetailProps = {
row: User;
};
export const Detail: FC<DetailProps> = ({ row }) => (
<InternalDetail
title={`User: ${row.name}`}
entity="users"
id={row.id}
deleteAction={deleteUserAction}
>
<Grid container direction="row" rowSpacing={3} columnSpacing={2}>
<Grid item xs={12}>
<DisplayTextField name="name" label="Name" value={row.name} />
</Grid>
</Grid>
</InternalDetail>
);

View file

@ -1,24 +0,0 @@
import { db } from "@/app/_lib/database";
import { Detail } from "./_components/Detail";
export const dynamic = "force-dynamic";
type Props = {
params: { segment: string[] };
};
export default async function Page({ params: { segment } }: Props) {
const id = segment?.[0];
if (!id) return null;
const row = await db
.selectFrom("User")
.selectAll()
.where("id", "=", id)
.executeTakeFirst();
if (!row) return null;
return <Detail row={row} />;
}

View file

@ -1,37 +0,0 @@
"use client";
import { FC } from "react";
import { useFormState } from "react-dom";
import { Grid } from "@mui/material";
import { TextField } from "ui";
import { User } from "@/app/_lib/database";
import { Edit as InternalEdit } from "@/app/_components/Edit";
import { updateUserAction } from "../../_actions/users";
type EditProps = {
row: User;
};
export const Edit: FC<EditProps> = ({ row }) => {
const initialState = {
message: null,
errors: {},
values: row,
};
const [formState, formAction] = useFormState(updateUserAction, initialState);
return (
<InternalEdit
title={`Edit User: ${row.name}`}
entity="users"
formAction={formAction}
formState={formState}
>
<Grid container direction="row" rowSpacing={3} columnSpacing={2}>
<Grid item xs={12}>
<TextField name="name" label="Name" required formState={formState} />
</Grid>
</Grid>
</InternalEdit>
);
};

View file

@ -1,24 +0,0 @@
import { db } from "@/app/_lib/database";
import { Edit } from "./_components/Edit";
export const dynamic = "force-dynamic";
type Props = {
params: { segment: string[] };
};
export default async function Page({ params: { segment } }: Props) {
const id = segment?.[0];
if (!id) return null;
const row = await db
.selectFrom("User")
.selectAll()
.where("id", "=", id)
.executeTakeFirst();
if (!row) return null;
return <Edit row={row} />;
}

View file

@ -1,33 +0,0 @@
"use server";
import { addAction, updateAction, deleteAction } from "@/app/_lib/actions";
const entity = "users";
const table = "User";
export const addUserAction = async (currentState: any, formData: FormData) => {
return addAction({
entity,
table,
fields: ["name"],
currentState,
formData,
});
};
export const updateUserAction = async (
currentState: any,
formData: FormData,
) => {
return updateAction({
entity,
table,
fields: ["name"],
currentState,
formData,
});
};
export const deleteUserAction = async (id: string) => {
return deleteAction({ entity, table, id });
};

View file

@ -1,31 +0,0 @@
"use client";
import { FC } from "react";
import { GridColDef } from "@mui/x-data-grid-pro";
import { List } from "@/app/_components/List";
type UsersListProps = {
rows: any[];
};
export const UsersList: FC<UsersListProps> = ({ rows }) => {
const columns: GridColDef[] = [
{
field: "name",
headerName: "Name",
flex: 2,
},
{
field: "email",
headerName: "Email",
flex: 2,
},
{
field: "emailVerified",
headerName: "Verified",
flex: 1,
},
];
return <List title="Users" entity="users" rows={rows} columns={columns} />;
};

View file

@ -1,3 +0,0 @@
import { ServiceLayout } from "@/app/_components/ServiceLayout";
export default ServiceLayout;

View file

@ -1,11 +0,0 @@
import { UsersList } from "./_components/UsersList";
import { db } from "@/app/_lib/database";
export const dynamic = "force-dynamic";
export default async function Page() {
const rows = await db.selectFrom("User").selectAll().execute();
console.log(rows);
return <UsersList rows={rows} />;
}

View file

@ -1,47 +0,0 @@
"use client";
import { FC } from "react";
import { useFormState } from "react-dom";
import { Grid } from "@mui/material";
import { TextField } from "ui";
import { Create as InternalCreate } from "@/app/_components/Create";
import { addVoiceLineAction } from "../../_actions/voice";
export const Create: FC = () => {
const initialState = {
message: null,
errors: {},
values: {
name: "",
description: "",
one: "",
},
};
const [formState, formAction] = useFormState(
addVoiceLineAction,
initialState,
);
return (
<InternalCreate
title="Create Voice Connection"
entity="voice"
formAction={formAction}
formState={formState}
>
<Grid container direction="row" rowSpacing={3} columnSpacing={2}>
<Grid item xs={12}>
<TextField name="name" label="Name" required formState={formState} />
</Grid>
<Grid item xs={12}>
<TextField
name="description"
label="Description"
formState={formState}
lines={3}
/>
</Grid>
</Grid>
</InternalCreate>
);
};

View file

@ -1,5 +0,0 @@
import { Create } from "./_components/Create";
export default function Page() {
return <Create />;
}

View file

@ -1,35 +0,0 @@
"use client";
import { FC } from "react";
import { Grid } from "@mui/material";
import { DisplayTextField } from "ui";
import { VoiceLine } from "@/app/_lib/database";
import { Detail as InternalDetail } from "@/app/_components/Detail";
import { deleteVoiceLineAction } from "../../_actions/voice";
type DetailProps = {
row: VoiceLine;
};
export const Detail: FC<DetailProps> = ({ row }) => (
<InternalDetail
title={`Voice Line: ${row.name}`}
entity="voice"
id={row.id}
deleteAction={deleteVoiceLineAction}
>
<Grid container direction="row" rowSpacing={3} columnSpacing={2}>
<Grid item xs={12}>
<DisplayTextField name="name" label="Name" value={row.name} />
</Grid>
<Grid item xs={12}>
<DisplayTextField
name="description"
label="Description"
lines={3}
value={row.description}
/>
</Grid>
</Grid>
</InternalDetail>
);

View file

@ -1,24 +0,0 @@
import { db } from "@/app/_lib/database";
import { Detail } from "./_components/Detail";
export const dynamic = "force-dynamic";
type Props = {
params: { segment: string[] };
};
export default async function Page({ params: { segment } }: Props) {
const id = segment?.[0];
if (!id) return null;
const row = await db
.selectFrom("VoiceLine")
.selectAll()
.where("id", "=", id)
.executeTakeFirst();
if (!row) return null;
return <Detail row={row} />;
}

View file

@ -1,48 +0,0 @@
"use client";
import { FC } from "react";
import { useFormState } from "react-dom";
import { Grid } from "@mui/material";
import { TextField } from "ui";
import { VoiceLine } from "@/app/_lib/database";
import { Edit as InternalEdit } from "@/app/_components/Edit";
import { updateVoiceLineAction } from "../../_actions/voice";
type EditProps = {
row: VoiceLine;
};
export const Edit: FC<EditProps> = ({ row }) => {
const initialState = {
message: null,
errors: {},
values: row,
};
const [formState, formAction] = useFormState(
updateVoiceLineAction,
initialState,
);
return (
<InternalEdit
title={`Edit Voice Line: ${row.name}`}
entity="voice"
formAction={formAction}
formState={formState}
>
<Grid container direction="row" rowSpacing={3} columnSpacing={2}>
<Grid item xs={12}>
<TextField name="name" label="Name" required formState={formState} />
</Grid>
<Grid item xs={12}>
<TextField
name="description"
label="Description"
formState={formState}
lines={3}
/>
</Grid>
</Grid>
</InternalEdit>
);
};

View file

@ -1,24 +0,0 @@
import { db } from "@/app/_lib/database";
import { Edit } from "./_components/Edit";
export const dynamic = "force-dynamic";
type Props = {
params: { segment: string[] };
};
export default async function Page({ params: { segment } }: Props) {
const id = segment?.[0];
if (!id) return null;
const row = await db
.selectFrom("VoiceLine")
.selectAll()
.where("id", "=", id)
.executeTakeFirst();
if (!row) return null;
return <Edit row={row} />;
}

View file

@ -1,36 +0,0 @@
"use server";
import { addAction, updateAction, deleteAction } from "@/app/_lib/actions";
const entity = "voice";
const table = "VoiceLine";
export const addVoiceLineAction = async (
currentState: any,
formData: FormData,
) => {
return addAction({
entity,
table,
fields: ["name"],
currentState,
formData,
});
};
export const updateVoiceLineAction = async (
currentState: any,
formData: FormData,
) => {
return updateAction({
entity,
table,
fields: ["name"],
currentState,
formData,
});
};
export const deleteVoiceLineAction = async (id: string) => {
return deleteAction({ entity, table, id });
};

View file

@ -1,47 +0,0 @@
"use client";
import { FC } from "react";
import { GridColDef } from "@mui/x-data-grid-pro";
import { List } from "@/app/_components/List";
type VoiceBotsListProps = {
rows: any[];
};
export const VoiceBotsList: FC<VoiceBotsListProps> = ({ rows }) => {
const columns: GridColDef[] = [
{
field: "id",
headerName: "ID",
flex: 1,
},
{
field: "phoneNumber",
headerName: "Phone Number",
flex: 2,
},
{
field: "createdAt",
headerName: "Created At",
valueGetter: (params: any) =>
new Date(params.row?.createdAt).toLocaleString(),
flex: 1,
},
{
field: "updatedAt",
headerName: "Updated At",
valueGetter: (params: any) =>
new Date(params.row?.updatedAt).toLocaleString(),
flex: 1,
},
];
return (
<List
title="Voice Connections"
entity="voice"
rows={rows}
columns={columns}
/>
);
};

View file

@ -1,3 +0,0 @@
import { ServiceLayout } from "@/app/_components/ServiceLayout";
export default ServiceLayout;

View file

@ -1,10 +0,0 @@
import { VoiceBotsList } from "./_components/VoiceBotsList";
import { db } from "@/app/_lib/database";
export const dynamic = "force-dynamic";
export default async function Page() {
const rows = await db.selectFrom("VoiceLine").selectAll().execute();
return <VoiceBotsList rows={rows} />;
}

View file

@ -1,44 +0,0 @@
"use client";
import { FC } from "react";
import { useFormState } from "react-dom";
import { Grid } from "@mui/material";
import { TextField } from "ui";
import { Create as InternalCreate } from "@/app/_components/Create";
import { addWebhookAction } from "../../_actions/webhooks";
export const Create: FC = () => {
const initialState = {
message: null,
errors: {},
values: {
name: "",
description: "",
one: "",
},
};
const [formState, formAction] = useFormState(addWebhookAction, initialState);
return (
<InternalCreate
title="Create Webhook"
entity="webhooks"
formAction={formAction}
formState={formState}
>
<Grid container direction="row" rowSpacing={3} columnSpacing={2}>
<Grid item xs={12}>
<TextField name="name" label="Name" required formState={formState} />
</Grid>
<Grid item xs={12}>
<TextField
name="description"
label="Description"
formState={formState}
lines={3}
/>
</Grid>
</Grid>
</InternalCreate>
);
};

View file

@ -1,5 +0,0 @@
import { Create } from "./_components/Create";
export default function Page() {
return <Create />;
}

View file

@ -1,35 +0,0 @@
"use client";
import { FC } from "react";
import { Grid } from "@mui/material";
import { DisplayTextField } from "ui";
import { Webhook } from "@/app/_lib/database";
import { Detail as InternalDetail } from "@/app/_components/Detail";
import { deleteWebhookAction } from "../../_actions/webhooks";
type DetailProps = {
row: Webhook;
};
export const Detail: FC<DetailProps> = ({ row }) => (
<InternalDetail
title={`Webhook: ${row.name}`}
entity="webhooks"
id={row.id}
deleteAction={deleteWebhookAction}
>
<Grid container direction="row" rowSpacing={3} columnSpacing={2}>
<Grid item xs={12}>
<DisplayTextField name="name" label="Name" value={row.name} />
</Grid>
<Grid item xs={12}>
<DisplayTextField
name="description"
label="Description"
lines={3}
value={row.description}
/>
</Grid>
</Grid>
</InternalDetail>
);

View file

@ -1,24 +0,0 @@
import { db } from "@/app/_lib/database";
import { Detail } from "./_components/Detail";
export const dynamic = "force-dynamic";
type Props = {
params: { segment: string[] };
};
export default async function Page({ params: { segment } }: Props) {
const id = segment?.[0];
if (!id) return null;
const row = await db
.selectFrom("Webhook")
.selectAll()
.where("id", "=", id)
.executeTakeFirst();
if (!row) return null;
return <Detail row={row} />;
}

View file

@ -1,48 +0,0 @@
"use client";
import { FC } from "react";
import { useFormState } from "react-dom";
import { Grid } from "@mui/material";
import { TextField } from "ui";
import { Webhook } from "@/app/_lib/database";
import { Edit as InternalEdit } from "@/app/_components/Edit";
import { updateWebhookAction } from "../../_actions/webhooks";
type EditProps = {
row: Webhook;
};
export const Edit: FC<EditProps> = ({ row }) => {
const initialState = {
message: null,
errors: {},
values: row,
};
const [formState, formAction] = useFormState(
updateWebhookAction,
initialState,
);
return (
<InternalEdit
title={`Edit Webhook: ${row.name}`}
entity="webhooks"
formAction={formAction}
formState={formState}
>
<Grid container direction="row" rowSpacing={3} columnSpacing={2}>
<Grid item xs={12}>
<TextField name="name" label="Name" required formState={formState} />
</Grid>
<Grid item xs={12}>
<TextField
name="description"
label="Description"
formState={formState}
lines={3}
/>
</Grid>
</Grid>
</InternalEdit>
);
};

View file

@ -1,24 +0,0 @@
import { db } from "@/app/_lib/database";
import { Edit } from "./_components/Edit";
export const dynamic = "force-dynamic";
type Props = {
params: { segment: string[] };
};
export default async function Page({ params: { segment } }: Props) {
const id = segment?.[0];
if (!id) return null;
const row = await db
.selectFrom("Webhook")
.selectAll()
.where("id", "=", id)
.executeTakeFirst();
if (!row) return null;
return <Edit row={row} />;
}

View file

@ -1,36 +0,0 @@
"use server";
import { addAction, updateAction, deleteAction } from "@/app/_lib/actions";
const entity = "webhooks";
const table = "Webhook";
export const addWebhookAction = async (
currentState: any,
formData: FormData,
) => {
return addAction({
entity,
table,
fields: ["name"],
currentState,
formData,
});
};
export const updateWebhookAction = async (
currentState: any,
formData: FormData,
) => {
return updateAction({
entity,
table,
fields: ["name"],
currentState,
formData,
});
};
export const deleteWebhookAction = async (id: string) => {
return deleteAction({ entity, table, id });
};

View file

@ -1,42 +0,0 @@
"use client";
import { FC } from "react";
import { GridColDef } from "@mui/x-data-grid-pro";
import { List } from "@/app/_components/List";
type WebhooksListProps = {
rows: any[];
};
export const WebhooksList: FC<WebhooksListProps> = ({ rows }) => {
const columns: GridColDef[] = [
{
field: "id",
headerName: "ID",
flex: 1,
},
{
field: "phoneNumber",
headerName: "Phone Number",
flex: 2,
},
{
field: "createdAt",
headerName: "Created At",
valueGetter: (params: any) =>
new Date(params.row?.createdAt).toLocaleString(),
flex: 1,
},
{
field: "updatedAt",
headerName: "Updated At",
valueGetter: (params: any) =>
new Date(params.row?.updatedAt).toLocaleString(),
flex: 1,
},
];
return (
<List title="Webhooks" entity="webhooks" rows={rows} columns={columns} />
);
};

View file

@ -1,3 +0,0 @@
import { ServiceLayout } from "@/app/_components/ServiceLayout";
export default ServiceLayout;

View file

@ -1,11 +0,0 @@
import { WebhooksList } from "./_components/WebhooksList";
import { db } from "@/app/_lib/database";
export const dynamic = "force-dynamic";
export default async function Page() {
const rows = await db.selectFrom("Webhook").selectAll().execute();
console.log(rows);
return <WebhooksList rows={rows} />;
}

View file

@ -1,47 +0,0 @@
"use client";
import { FC } from "react";
import { useFormState } from "react-dom";
import { Grid } from "@mui/material";
import { TextField } from "ui";
import { Create as InternalCreate } from "@/app/_components/Create";
import { addWhatsappBotAction } from "../../_actions/whatsapp";
export const Create: FC = () => {
const initialState = {
message: null,
errors: {},
values: {
name: "",
description: "",
one: "",
},
};
const [formState, formAction] = useFormState(
addWhatsappBotAction,
initialState,
);
return (
<InternalCreate
title="Create WhatsApp Connection"
entity="whatsapp"
formAction={formAction}
formState={formState}
>
<Grid container direction="row" rowSpacing={3} columnSpacing={2}>
<Grid item xs={12}>
<TextField name="name" label="Name" required formState={formState} />
</Grid>
<Grid item xs={12}>
<TextField
name="description"
label="Description"
formState={formState}
lines={3}
/>
</Grid>
</Grid>
</InternalCreate>
);
};

View file

@ -1,5 +0,0 @@
import { Create } from "./_components/Create";
export default function Page() {
return <Create />;
}

View file

@ -1,35 +0,0 @@
"use client";
import { FC } from "react";
import { Grid } from "@mui/material";
import { DisplayTextField } from "ui";
import { WhatsappBot } from "@/app/_lib/database";
import { Detail as InternalDetail } from "@/app/_components/Detail";
import { deleteWhatsappBotAction } from "../../_actions/whatsapp";
type DetailProps = {
row: WhatsappBot;
};
export const Detail: FC<DetailProps> = ({ row }) => (
<InternalDetail
title={`WhatsApp Connection: ${row.name}`}
entity="whatsapp"
id={row.id}
deleteAction={deleteWhatsappBotAction}
>
<Grid container direction="row" rowSpacing={3} columnSpacing={2}>
<Grid item xs={12}>
<DisplayTextField name="name" label="Name" value={row.name} />
</Grid>
<Grid item xs={12}>
<DisplayTextField
name="description"
label="Description"
lines={3}
value={row.description}
/>
</Grid>
</Grid>
</InternalDetail>
);

View file

@ -1,24 +0,0 @@
import { db } from "@/app/_lib/database";
import { Detail } from "./_components/Detail";
export const dynamic = "force-dynamic";
type Props = {
params: { segment: string[] };
};
export default async function Page({ params: { segment } }: Props) {
const id = segment?.[0];
if (!id) return null;
const row = await db
.selectFrom("WhatsappBot")
.selectAll()
.where("id", "=", id)
.executeTakeFirst();
if (!row) return null;
return <Detail row={row} />;
}

View file

@ -1,58 +0,0 @@
"use client";
import { FC } from "react";
import { useFormState } from "react-dom";
import { Grid } from "@mui/material";
import { TextField } from "ui";
import { WhatsappBot } from "@/app/_lib/database";
import { Edit as InternalEdit } from "@/app/_components/Edit";
import { updateWhatsappBotAction } from "../../_actions/whatsapp";
type EditProps = {
row: WhatsappBot;
};
export const Edit: FC<EditProps> = ({ row }) => {
const initialState = {
message: null,
errors: {},
values: row,
};
const [formState, formAction] = useFormState(
updateWhatsappBotAction,
initialState,
);
return (
<InternalEdit
title={`Edit Whatsapp Connection: ${row.name}`}
entity="whatsapp"
formAction={formAction}
formState={formState}
>
<Grid container direction="row" rowSpacing={3} columnSpacing={2}>
<Grid item xs={12}>
<TextField name="name" label="Name" required formState={formState} />
</Grid>
<Grid item xs={12}>
<TextField
name="description"
label="Description"
formState={formState}
lines={3}
/>
</Grid>
<Grid item xs={6}>
<TextField
name="token"
label="Token"
disabled
formState={formState}
refreshable
helperText="Token used to authenticate requests from Link"
/>
</Grid>
</Grid>
</InternalEdit>
);
};

View file

@ -1,24 +0,0 @@
import { db } from "@/app/_lib/database";
import { Edit } from "./_components/Edit";
export const dynamic = "force-dynamic";
type Props = {
params: { segment: string[] };
};
export default async function Page({ params: { segment } }: Props) {
const id = segment?.[0];
if (!id) return null;
const row = await db
.selectFrom("WhatsappBot")
.selectAll()
.where("id", "=", id)
.executeTakeFirst();
if (!row) return null;
return <Edit row={row} />;
}

View file

@ -1,36 +0,0 @@
"use server";
import { addAction, updateAction, deleteAction } from "@/app/_lib/actions";
const entity = "whatsapp";
const table = "WhatsappBot";
export const addWhatsappBotAction = async (
currentState: any,
formData: FormData,
) => {
return addAction({
entity,
table,
fields: ["name"],
currentState,
formData,
});
};
export const updateWhatsappBotAction = async (
currentState: any,
formData: FormData,
) => {
return updateAction({
entity,
table,
fields: ["name"],
currentState,
formData,
});
};
export const deleteWhatsappBotAction = async (id: string) => {
return deleteAction({ entity, table, id });
};

View file

@ -1,46 +0,0 @@
"use client";
import { FC } from "react";
import { GridColDef } from "@mui/x-data-grid-pro";
import { WhatsappBot } from "@/app/_lib/database";
import { List } from "@/app/_components/List";
type WhatsappListProps = {
rows: WhatsappBot[];
};
export const WhatsappList: FC<WhatsappListProps> = ({ rows }) => {
const columns: GridColDef[] = [
{
field: "name",
headerName: "Name",
flex: 1,
},
{
field: "phoneNumber",
headerName: "Phone Number",
flex: 1,
},
{
field: "description",
headerName: "Description",
flex: 2,
},
{
field: "updatedAt",
headerName: "Updated At",
valueGetter: (params: any) =>
new Date(params.row?.updatedAt).toLocaleString(),
flex: 1,
},
];
return (
<List
title="WhatsApp Connections"
entity="whatsapp"
rows={rows}
columns={columns}
/>
);
};

View file

@ -1,3 +0,0 @@
import { ServiceLayout } from "@/app/_components/ServiceLayout";
export default ServiceLayout;

View file

@ -1,11 +0,0 @@
import { WhatsappList } from "./_components/WhatsappList";
import { db } from "@/app/_lib/database";
export const dynamic = "force-dynamic";
export default async function Page() {
const rows = await db.selectFrom("WhatsappBot").selectAll().execute();
console.log(rows);
return <WhatsappList rows={rows} />;
}

View file

@ -1 +0,0 @@
"use server";

View file

@ -26,7 +26,7 @@ export const Edit: FC<EditProps> = ({
if (formState.success) {
router.push(`/${entity}`);
}
}, [formState.success, router]);
}, [formState.success, router, entity]);
return (
<Dialog

View file

@ -367,10 +367,12 @@ export const Sidebar: FC<SidebarProps> = ({ open, setOpen }) => {
{user?.image && (
<Grid item>
<Box sx={{ width: 20, height: 20 }}>
<img
<Image
src={user?.image ?? ""}
alt="Profile image"
style={{ width: "100%" }}
width={20}
height={20}
unoptimized
/>
</Box>
</Grid>

View file

@ -1,6 +1,16 @@
import type { ServiceConfig } from "./service";
import { facebookConfig as facebook } from "./facebook";
import { signalConfig as signal } from "./signal";
import { whatsappConfig as whatsapp } from "./whatsapp";
import { voiceConfig as voice } from "./voice";
import { webhooksConfig as webhooks } from "./webhooks";
import { usersConfig as users } from "./users";
export const serviceConfig: Record<string, ServiceConfig> = {
facebook,
signal,
whatsapp,
voice,
webhooks,
users,
};

View file

@ -4,57 +4,64 @@ import { Service, ServiceConfig } from "./service";
export const facebookConfig: ServiceConfig = {
entity: "facebook",
table: "FacebookBot",
displayName: "Facebook Connections",
displayName: "Facebook Connection",
createFields: [
{ name: "name", type: "text", label: "Name", required: true },
{
name: "name",
label: "Name",
required: true,
size: 12,
},
{
name: "description",
type: "text",
label: "Description",
required: true,
size: 12,
lines: 3,
},
{ name: "appId", type: "text", label: "App ID", required: true },
{ name: "appSecret", type: "text", label: "App Secret", required: true },
{ name: "pageId", type: "text", label: "Page ID", required: true },
{ name: "appId", label: "App ID", required: true },
{ name: "appSecret", label: "App Secret", required: true },
{ name: "pageId", label: "Page ID", required: true },
{
name: "pageAccessToken",
type: "text",
label: "Page Access Token",
required: true,
},
],
updateFields: [
{ name: "name", type: "text", label: "Name", required: true },
{ name: "name", label: "Name", required: true, size: 12 },
{
name: "description",
type: "text",
label: "Description",
required: true,
size: 12,
lines: 3,
},
{ name: "appId", type: "text", label: "App ID", required: true },
{ name: "appSecret", type: "text", label: "App Secret", required: true },
{ name: "pageId", type: "text", label: "Page ID", required: true },
{ name: "appId", label: "App ID", required: true },
{ name: "appSecret", label: "App Secret", required: true },
{ name: "pageId", label: "Page ID", required: true },
{
name: "pageAccessToken",
type: "text",
label: "Page Access Token",
required: true,
},
],
displayFields: [
{ name: "name", type: "text", label: "Name", required: true },
{ name: "name", label: "Name", required: true, size: 12 },
{
name: "description",
type: "text",
label: "Description",
required: true,
size: 12,
},
{ name: "appId", label: "App ID", required: true },
{ name: "appSecret", label: "App Secret", required: true },
{
name: "pageId",
label: "Page ID",
required: true,
copyable: true,
},
{ name: "appId", type: "text", label: "App ID", required: true },
{ name: "appSecret", type: "text", label: "App Secret", required: true },
{ name: "pageId", type: "text", label: "Page ID", required: true },
{
name: "pageAccessToken",
type: "text",
label: "Page Access Token",
required: true,
},

View file

@ -7,16 +7,16 @@ const entities = [
"whatsapp",
"signal",
"voice",
"webhook",
"user",
"webhooks",
"users",
] as const;
export type Entity = (typeof entities)[number];
export type FieldDescription = {
name: string;
type: string;
label: string;
type?: string;
lines?: number;
copyable?: boolean;
defaultValue?: string;

View file

@ -1,5 +1,81 @@
import { NextRequest, NextResponse } from "next/server";
import { Service } from "./service";
import { Service, ServiceConfig } from "./service";
export const signalConfig: ServiceConfig = {
entity: "signal",
table: "SignalBot",
displayName: "Signal Connection",
createFields: [
{
name: "name",
label: "Name",
required: true,
size: 12,
},
{
name: "description",
label: "Description",
size: 12,
lines: 3,
},
{
name: "phoneNumber",
label: "phoneNumber",
required: true,
},
],
updateFields: [
{ name: "name", label: "Name", required: true, size: 12 },
{
name: "description",
label: "Description",
required: true,
size: 12,
},
{
name: "phoneNumber",
label: "phoneNumber",
required: true,
},
],
displayFields: [
{ name: "name", label: "Name", required: true, size: 12 },
{
name: "description",
label: "Description",
required: true,
size: 12,
},
{
name: "phoneNumber",
label: "phoneNumber",
required: true,
},
],
listColumns: [
{
field: "name",
headerName: "Name",
flex: 1,
},
{
field: "phoneNumber",
headerName: "Phone Number",
flex: 1,
},
{
field: "description",
headerName: "Description",
flex: 2,
},
{
field: "updatedAt",
headerName: "Updated At",
valueGetter: (value: any) => new Date(value).toLocaleString(),
flex: 1,
},
],
};
const getAllBots = async (req: NextRequest) => {
console.log({ req });

View file

@ -0,0 +1,56 @@
import { ServiceConfig } from "./service";
export const usersConfig: ServiceConfig = {
entity: "users",
table: "User",
displayName: "User",
createFields: [
{
name: "name",
label: "Name",
required: true,
size: 12,
},
{
name: "email",
label: "Email",
required: true,
size: 12,
},
],
updateFields: [
{ name: "name", label: "Name", required: true, size: 12 },
{
name: "email",
label: "Email",
required: true,
size: 12,
},
],
displayFields: [
{ name: "name", label: "Name", required: true, size: 12 },
{
name: "email",
label: "Email",
size: 12,
},
],
listColumns: [
{
field: "name",
headerName: "Name",
flex: 1,
},
{
field: "email",
headerName: "Email",
flex: 2,
},
{
field: "updatedAt",
headerName: "Updated At",
valueGetter: (value: any) => new Date(value).toLocaleString(),
flex: 1,
},
],
};

View file

@ -1,5 +1,81 @@
import { NextRequest, NextResponse } from "next/server";
import { Service } from "./service";
import { Service, ServiceConfig } from "./service";
export const voiceConfig: ServiceConfig = {
entity: "voice",
table: "VoiceLine",
displayName: "Voice Line",
createFields: [
{
name: "name",
label: "Name",
required: true,
size: 12,
},
{
name: "description",
label: "Description",
size: 12,
lines: 3,
},
{
name: "phoneNumber",
label: "phoneNumber",
required: true,
},
],
updateFields: [
{ name: "name", label: "Name", required: true, size: 12 },
{
name: "description",
label: "Description",
required: true,
size: 12,
},
{
name: "phoneNumber",
label: "Phone Number",
required: true,
},
],
displayFields: [
{ name: "name", label: "Name", required: true, size: 12 },
{
name: "description",
label: "Description",
required: true,
size: 12,
},
{
name: "phoneNumber",
label: "Phone Number",
required: true,
},
],
listColumns: [
{
field: "name",
headerName: "Name",
flex: 1,
},
{
field: "phoneNumber",
headerName: "Phone Number",
flex: 1,
},
{
field: "description",
headerName: "Description",
flex: 2,
},
{
field: "updatedAt",
headerName: "Updated At",
valueGetter: (value: any) => new Date(value).toLocaleString(),
flex: 1,
},
],
};
const getAllBots = async (req: NextRequest) => {
console.log({ req });

View file

@ -0,0 +1,57 @@
import { ServiceConfig } from "./service";
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,
},
],
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,
},
],
};

View file

@ -1,5 +1,81 @@
import { NextRequest, NextResponse } from "next/server";
import { Service } from "./service";
import { Service, ServiceConfig } from "./service";
export const whatsappConfig: ServiceConfig = {
entity: "whatsapp",
table: "WhatsappBot",
displayName: "WhatsApp Connection",
createFields: [
{
name: "name",
label: "Name",
required: true,
size: 12,
},
{
name: "description",
label: "Description",
size: 12,
lines: 3,
},
{
name: "phoneNumber",
label: "Phone Number",
required: true,
},
],
updateFields: [
{ name: "name", label: "Name", required: true, size: 12 },
{
name: "description",
label: "Description",
required: true,
size: 12,
},
{
name: "phoneNumber",
label: "Phone Number",
required: true,
},
],
displayFields: [
{ name: "name", label: "Name", required: true, size: 12 },
{
name: "description",
label: "Description",
required: true,
size: 12,
},
{
name: "phoneNumber",
label: "Phone Number",
required: true,
},
],
listColumns: [
{
field: "name",
headerName: "Name",
flex: 1,
},
{
field: "phoneNumber",
headerName: "Phone Number",
flex: 1,
},
{
field: "description",
headerName: "Description",
flex: 2,
},
{
field: "updatedAt",
headerName: "Updated At",
valueGetter: (value: any) => new Date(value).toLocaleString(),
flex: 1,
},
],
};
const getAllBots = async (req: NextRequest) => {
console.log({ req });

View file

@ -21,25 +21,25 @@
"@mui/lab": "^5.0.0-alpha.170",
"@mui/material": "^5",
"@mui/material-nextjs": "^5.15.11",
"@mui/x-data-grid-pro": "^7.3.0",
"@mui/x-date-pickers-pro": "^7.2.0",
"@mui/x-data-grid-pro": "^7.3.1",
"@mui/x-date-pickers-pro": "^7.3.1",
"@mui/x-license": "^7.2.0",
"date-fns": "^3.6.0",
"dotenv": "^16.4.5",
"kysely": "^0.26.1",
"material-ui-popup-state": "^5.1.0",
"mui-chips-input": "^2.1.4",
"next": "14.2.2",
"next": "14.2.3",
"next-auth": "^4.24.7",
"pg": "^8.11.5",
"react": "18.2.0",
"react": "18.3.0",
"react-cookie": "^7.1.4",
"react-digit-input": "^2.1.0",
"react-dom": "18.2.0",
"react-dom": "18.3.0",
"react-qr-code": "^2.0.12",
"react-timer-hook": "^3.0.7",
"tss-react": "^4.9.6",
"tsx": "^4.7.2",
"tss-react": "^4.9.7",
"tsx": "^4.7.3",
"ui": "*"
},
"devDependencies": {
@ -48,7 +48,7 @@
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint": "^8",
"eslint-config-next": "14.2.2",
"eslint-config-next": "14.2.3",
"ts-config": "*",
"typescript": "^5"
}

View file

@ -16,7 +16,7 @@
"jest": "^29.7.0",
"kysely": "^0.27.3",
"pg": "^8.11.5",
"remeda": "^1.60.1",
"remeda": "^1.61.0",
"twilio": "^5.0.4"
},
"devDependencies": {

View file

@ -20,39 +20,39 @@
"@mui/icons-material": "^5",
"@mui/lab": "^5.0.0-alpha.170",
"@mui/material": "^5",
"@mui/x-data-grid-pro": "^7.3.0",
"@mui/x-date-pickers-pro": "^7.2.0",
"@mui/x-data-grid-pro": "^7.3.1",
"@mui/x-date-pickers-pro": "^7.3.1",
"@opensearch-project/opensearch": "^2.7.0",
"cryptr": "^6.3.0",
"date-fns": "^3.6.0",
"http-proxy-middleware": "^3.0.0",
"leafcutter-ui": "*",
"material-ui-popup-state": "^5.1.0",
"next": "14.2.2",
"next": "14.2.3",
"next-auth": "^4.24.7",
"next-http-proxy-middleware": "^1.2.6",
"opensearch-common": "*",
"nodemailer": "^6.9.13",
"react": "18.2.0",
"react": "18.3.0",
"react-cookie": "^7.1.4",
"react-cookie-consent": "^9.0.0",
"react-dom": "18.2.0",
"react-dom": "18.3.0",
"react-iframe": "^1.8.5",
"react-markdown": "^9.0.1",
"react-polyglot": "^0.7.2",
"sharp": "^0.33.3",
"swr": "^2.2.5",
"tss-react": "^4.9.6",
"tss-react": "^4.9.7",
"uuid": "^9.0.1"
},
"devDependencies": {
"@babel/core": "^7.24.4",
"@types/node": "^20.12.7",
"@types/react": "18.2.79",
"@types/react": "18.3.0",
"@types/uuid": "^9.0.8",
"babel-loader": "^9.1.3",
"eslint": "^8.0.0",
"eslint-config-next": "^14.2.2",
"eslint-config-next": "^14.2.3",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",

View file

@ -18,36 +18,36 @@
"@mui/icons-material": "^5",
"@mui/lab": "^5.0.0-alpha.170",
"@mui/material": "^5",
"@mui/x-data-grid-pro": "^7.3.0",
"@mui/x-date-pickers-pro": "^7.2.0",
"@mui/x-data-grid-pro": "^7.3.1",
"@mui/x-date-pickers-pro": "^7.3.1",
"date-fns": "^3.6.0",
"graphql-request": "^6.1.0",
"leafcutter-ui": "*",
"material-ui-popup-state": "^5.1.0",
"bridge-ui": "*",
"mui-chips-input": "^2.1.4",
"next": "14.2.2",
"next": "14.2.3",
"next-auth": "^4.24.7",
"opensearch-common": "*",
"react": "18.2.0",
"react": "18.3.0",
"react-cookie": "^7.1.4",
"react-dom": "18.2.0",
"react-dom": "18.3.0",
"react-iframe": "^1.8.5",
"react-polyglot": "^0.7.2",
"sharp": "^0.33.3",
"swr": "^2.2.5",
"tss-react": "^4.9.6",
"tss-react": "^4.9.7",
"twilio-client": "^1.15.1",
"ui": "*"
},
"devDependencies": {
"@babel/core": "^7.24.4",
"@types/node": "^20.12.7",
"@types/react": "18.2.79",
"@types/react": "18.3.0",
"@types/uuid": "^9.0.8",
"babel-loader": "^9.1.3",
"eslint": "^8.0.0",
"eslint-config-next": "^14.2.2",
"eslint-config-next": "^14.2.3",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",