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 { AddOrganisationAdminFormHandler } from '../../handlers/AddOrganisationAdminFormHandler';
import { dataConfigs } from '../data-configs';
import { userDataProvider } from '../data-provider-configs';
import { spaces } from '../spaces';
export const ID = 'form-view-organisation-admin-add';
export const config = (dataApi) => FormViewConfig.decode({
  _id: ID,
  base: 'mentornity',
  title: 'Add New Admin',
  space: spaces['mentornity'],
  table: dataConfigs['users'],
  type: AppViewType.FormView,
  handler: new AddOrganisationAdminFormHandler(),
  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('organisationId'),
      },
      {
        field: new SingleChoiceField('admin', '', undefined, '', 'select').setDataProvider(userDataProvider(dataApi))
          .setDataAdapter(new DvnDataAdapter('firstName+lastName', 'email'))
          .require(),
      },
    ],
  },
  params: {
    organisationId: {
      required: true,
    },
  },
});
