47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
"use client";
|
|
|
|
// import dynamic from "next/dynamic";
|
|
import { FC } from "react";
|
|
import {
|
|
SimpleForm,
|
|
Create,
|
|
TextInput,
|
|
required,
|
|
CreateProps,
|
|
} from "react-admin";
|
|
import { useSession } from "next-auth/react";
|
|
import { validateE164Number } from "../../../_lib/phone-numbers";
|
|
|
|
const WhatsappBotCreate: FC<CreateProps> = (props) => {
|
|
// const MuiPhoneNumber = dynamic(() => import("material-ui-phone-number"), {
|
|
// ssr: false,
|
|
// });
|
|
|
|
const { data: session } = useSession();
|
|
|
|
return (
|
|
<Create {...props} title="Create Whatsapp Bot" redirect="show">
|
|
<SimpleForm>
|
|
<TextInput
|
|
source="userId"
|
|
defaultValue={
|
|
// @ts-expect-error: non-existent property
|
|
session.user.id
|
|
}
|
|
/>
|
|
<TextInput
|
|
source="phoneNumber"
|
|
validate={[validateE164Number, required()]}
|
|
/>
|
|
{/* <MuiPhoneNumber
|
|
defaultCountry={"us"}
|
|
fullWidth
|
|
onChange={(e: any) => setFieldValue("phoneNumber", e)}
|
|
/> */}
|
|
<TextInput source="description" />
|
|
</SimpleForm>
|
|
</Create>
|
|
);
|
|
};
|
|
|
|
export default WhatsappBotCreate;
|