import {
  AutocompleteInput,
  Create,
  DateInput,
  ReferenceInput,
  SelectInput,
  SimpleForm,
  TextInput as RaTextInput,
} from 'react-admin';
import { equipmentStatusChoices, equipmentOptionText } from '../equipment/shared';
import { StatusChangeAttachmentsInput } from './StatusChangeAttachmentsInput';

export function ChangeEquipmentStatusCreate() {
  return (
    <Create>
      <SimpleForm>
        <RaTextInput source="number" label="Номер" />
        <ReferenceInput source="equipmentId" reference="equipment">
          <AutocompleteInput
            label="Оборудование"
            optionText={equipmentOptionText}
            filterToQuery={(searchText) => ({ q: searchText })}
          />
        </ReferenceInput>
        <RaTextInput source="responsible" label="Ответственный" />
        <DateInput source="date" label="Дата" required />
        <SelectInput source="newStatus" label="Новый статус" choices={equipmentStatusChoices} required />
        <StatusChangeAttachmentsInput />
      </SimpleForm>
    </Create>
  );
}
