import { DvnDataAdapter } from '@dvn/core/adapters/DvnDataAdapter';
import { DataTransferField } from '@dvn/core/doldurma/src/fields/query-include/data-transfer-field';
import { SingleChoiceField } from '@dvn/core/doldurma/src/fields/single-choice';
import { FormViewConfig } from '@dvn/core/models/form-view-config';
import { AppViewType } from '@dvn/core/models/view-config';
import { DvnDataProvider } from '@dvn/core/providers/DvnDataProvider';
import { RemoveOrganisationAdminFormHandler } from '../../handlers/RemoveOrganisationAdminFormHandler';
import { dataConfigs } from '../data-configs';
import { spaces } from '../spaces';
export const ID = 'form-view-organisation-admin-remove';
export const config = (_dataApi) => FormViewConfig.decode({
  _id: ID,
  base: 'mentornity',
  title: 'Remove Admin',
  space: spaces['mentornity'],
  table: dataConfigs['users'],
  type: AppViewType.FormView,
  handler: new RemoveOrganisationAdminFormHandler(),
  ui: {
    fields: [
      // this field is passed by the parameters. this is a data holder field to pass the data to form handler
      {
        field: new DataTransferField('organisationDomain'),
      },
      {
        field: new SingleChoiceField('admin', '', undefined, '', 'select').setDataProvider(new DvnDataProvider(undefined, 'users', {})).setDataAdapter(new DvnDataAdapter('firstName+lastName', '_id'))
          .disable()
          .require(),
      },
    ],
  },
  params: {
    admin: {
      required: true,
    },
    organisationDomain: {
      required: true,
    },
  },
});
