"use client";

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 SignalBotCreate:FC<CreateProps> = (props) => {
  const { data: session } = useSession();

  return (
    <Create {...props} title="Create Signal Bot">
      <SimpleForm>
        <TextInput
          source="userId"
          defaultValue={
            // @ts-expect-error: ID does exist
            session.user.id
          }
        />
        <TextInput
          source="phoneNumber"
          validate={[validateE164Number, required()]}
        />
        <TextInput source="description" />
      </SimpleForm>
    </Create>
  );
};

export default SignalBotCreate;
