import { BooleanField } from '@dvn/core/doldurma/src/fields/boolean';
import { DataTransferField } from '@dvn/core/doldurma/src/fields/query-include/data-transfer-field';
import { Comparison } from '@dvn/core/models/filter';
import { FormViewConfig } from '@dvn/core/models/form-view-config';
import { AppViewType } from '@dvn/core/models/view-config';
import { spaces } from '../spaces';
import { EditOrganisationConfigFormHandler } from '../../handlers/EditOrganisationConfigFormHandler';
import { dataConfigs } from '../data-configs';
export const ID = 'form-view-organisation-config-edit';
export const viewConfig = FormViewConfig.decode({
  _id: ID,
  base: 'mentornity',
  title: 'Edit Configuration',
  space: spaces['mentornity'],
  table: dataConfigs['configs'],
  type: AppViewType.FormView,
  handler: new EditOrganisationConfigFormHandler(),
  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('item'),
      },
      {
        field: new BooleanField('membershipForm', 'Membership Form', `Shows "My Info" item on the left menu which opens a form page for editing profile, metadata and mentorship in a single form.`),
      },
      {
        field: new BooleanField('pairOverviewAndDetail', 'Pair Overview and Detail', 'Shows new mentors/mentees and mentor selection page.'),
      },
    ],
  },
  query: {
    fields: [
      new DataTransferField('webAppConfiguration'),
    ],
    filter: {
      comparison: Comparison.Eq,
      id: 'organisation._id',
      value: '$itemId',
    },
  },
  conversionConfig: {
    'item.webAppConfiguration.membershipForm': 'membershipForm',
    'item.webAppConfiguration.pairOverviewAndDetail': 'pairOverviewAndDetail'
  },
  params: {
    itemId: {
      required: true,
    },
  },
});
