App directory #4
This commit is contained in:
parent
69706053c6
commit
4d743c5e67
86 changed files with 223 additions and 107 deletions
72
apps/metamigo-frontend/app/_components/webhooks/shared.tsx
Normal file
72
apps/metamigo-frontend/app/_components/webhooks/shared.tsx
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
"use client";
|
||||
|
||||
import { SelectInput, required } from "react-admin";
|
||||
|
||||
import {
|
||||
VoiceLineField,
|
||||
VoiceLineSelectInput,
|
||||
} from "../voice/voicelines/shared";
|
||||
import {
|
||||
WhatsAppBotField,
|
||||
WhatsAppBotSelectInput,
|
||||
} from "../whatsapp/bots/shared";
|
||||
import { SignalBotField, SignalBotSelectInput } from "../signal/bots/shared";
|
||||
|
||||
const httpChoices = [
|
||||
{ id: "post", name: "POST" },
|
||||
{ id: "put", name: "PUT" },
|
||||
];
|
||||
export const HttpMethodInput = (props: any) => (
|
||||
<SelectInput
|
||||
source="httpMethod"
|
||||
choices={httpChoices}
|
||||
validate={[required()]}
|
||||
initialValue="post"
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
|
||||
const backendChoices = [
|
||||
{ id: "signal", name: "Signal" },
|
||||
{ id: "whatsapp", name: "WhatsApp" },
|
||||
{ id: "voice", name: "Voice" },
|
||||
];
|
||||
|
||||
const backendInputComponents = {
|
||||
whatsapp: WhatsAppBotSelectInput("backendId"),
|
||||
signal: SignalBotSelectInput("backendId"),
|
||||
voice: VoiceLineSelectInput("backendId"),
|
||||
};
|
||||
|
||||
const backendFieldComponents = {
|
||||
whatsapp: WhatsAppBotField("backendId"),
|
||||
signal: SignalBotField("backendId"),
|
||||
voice: VoiceLineField("backendId"),
|
||||
};
|
||||
|
||||
export const BackendTypeInput = (props: any) => (
|
||||
<SelectInput
|
||||
source="backendType"
|
||||
choices={backendChoices}
|
||||
validate={[required()]}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
|
||||
export const BackendIdInput = (form: any, ...rest: any[]) => {
|
||||
const Component = form.formData.backendType
|
||||
? // @ts-expect-error
|
||||
backendInputComponents[form.formData.backendType]
|
||||
: false;
|
||||
return <>{Component && <Component form={form} {...rest} />}</>;
|
||||
};
|
||||
|
||||
export const BackendIdField = (form: any, ...rest: any[]) => {
|
||||
console.log(form);
|
||||
|
||||
const Component = form.record.backendType
|
||||
? // @ts-expect-error
|
||||
backendFieldComponents[form.record.backendType]
|
||||
: false;
|
||||
return <>{Component && <Component form={form} {...rest} />}</>;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue