import { FC } from "react";
import {
  SimpleForm,
  TextInput,
  BooleanInput,
  Create,
  CreateProps,
} from "react-admin";
import { useSession } from "next-auth/react";
import { UserRoleInput } from "./shared";

const UserCreate: FC<CreateProps> = (props) => {
  const { data: session } = useSession();
  return (
    <Create {...props} title="Create Users">
      <SimpleForm>
        <TextInput source="email" />
        <TextInput source="name" />
        <UserRoleInput session={session} initialValue="NONE" />
        <BooleanInput source="isActive" defaultValue={true} />
        <TextInput source="createdBy" defaultValue={session.user.name} />
      </SimpleForm>
    </Create>
  );
};

export default UserCreate;
