import { BooleanField } from '@dvn/core/doldurma/src/fields/boolean';
import { MultipleChoiceField, MultipleChoiceFieldOption } from '@dvn/core/doldurma/src/fields/multiple-choice';
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 { EditOrganisationConfigFormHandler } from '../../handlers/EditOrganisationConfigFormHandler';
import { dataConfigs } from '../data-configs';
import { spaces } from '../spaces';
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.'),
      },
      {
        field: new MultipleChoiceField('adminRoutes', 'Admin routes', [
          new MultipleChoiceFieldOption('Mentors', 'mentors'),
          new MultipleChoiceFieldOption('Mentees', 'mentees'),
          new MultipleChoiceFieldOption('Groups', 'groups'),
          new MultipleChoiceFieldOption('Calendar', 'calendar'),
          new MultipleChoiceFieldOption('Feedbacks', 'feedbacks'),
          new MultipleChoiceFieldOption('MeetingGoals', 'meetingGoals'),
          new MultipleChoiceFieldOption('Announcements', 'announcements'),
          new MultipleChoiceFieldOption('Reports', 'reports'),
          new MultipleChoiceFieldOption('Subscriptions', 'subscriptions'),
          new MultipleChoiceFieldOption('Forms', 'forms'),
          new MultipleChoiceFieldOption('Applications', 'applications'),
          new MultipleChoiceFieldOption('Screens', 'viewSettings'),
        ], '', 'select'),
      },
      {
        field: new MultipleChoiceField('mentorRoutes', 'Mentor routes', [
          new MultipleChoiceFieldOption('Feed', 'feed'),
          new MultipleChoiceFieldOption('Mentors', 'mentors'),
          new MultipleChoiceFieldOption('Mentees', 'mentees'),
          new MultipleChoiceFieldOption('Groups', 'groups'),
          new MultipleChoiceFieldOption('Forms', 'forms'),
        ], '', 'select'),
      },
      {
        field: new MultipleChoiceField('menteeRoutes', 'Mentee routes', [
          new MultipleChoiceFieldOption('Feed', 'feed'),
          new MultipleChoiceFieldOption('Mentors', 'mentors'),
          new MultipleChoiceFieldOption('Mentees', 'mentees'),
          new MultipleChoiceFieldOption('Groups', 'groups'),
          new MultipleChoiceFieldOption('Forms', 'forms'),
        ], '', 'select'),
      },
      {
        field: new MultipleChoiceField('anonymousRoutes', 'Anonymous routes', [
          new MultipleChoiceFieldOption('Mentors', 'mentors'),
          new MultipleChoiceFieldOption('Groups', 'groups'),
        ], '', 'select'),
      },
    ],
  },
  query: {
    fields: [
      new DataTransferField('webAppConfiguration'),
      new DataTransferField('routes'),
    ],
    filter: {
      comparison: Comparison.Eq,
      id: 'organisation._id',
      value: '$itemId',
    },
  },
  conversionConfig: {
    'item.webAppConfiguration.membershipForm': 'membershipForm',
    'item.webAppConfiguration.pairOverviewAndDetail': 'pairOverviewAndDetail',
    'item.routes.admin': 'adminRoutes',
    'item.routes.mentee': 'menteeRoutes',
    'item.routes.mentor': 'mentorRoutes',
    'item.routes.anonymous': 'anonymousRoutes',
  },
  params: {
    itemId: {
      required: true,
    },
  },
});
