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 { CreateWhiteLabelFormHandler } from '../../handlers/CreateWhiteLabelFormHandler';
import { dataConfigs } from '../data-configs';
import { spaces } from '../spaces';
import { viewConfig as createFormViewConfig } from './form-view-white-label-create';
export const ID = 'form-view-white-label-edit';
export const viewConfig = FormViewConfig.decode({
  _id: ID,
  base: 'mentornity',
  title: 'Edit White Label',
  space: spaces['mentornity'],
  table: dataConfigs['whiteLabels'],
  type: AppViewType.FormView,
  handler: new CreateWhiteLabelFormHandler(),
  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'),
      },
      ...createFormViewConfig.ui.fields,
    ],
  },
  query: {
    fields: [
      new DataTransferField('title'),
      new DataTransferField('description'),
      new DataTransferField('domain'),
      new DataTransferField('senderEmail'),
      new DataTransferField('supportEmail'),
      new DataTransferField('mailIconUrl'),
      new DataTransferField('landingPageUrl'),
      new DataTransferField('facebookUrl'),
      new DataTransferField('twitterUrl'),
      new DataTransferField('linkedInUrl'),
      new DataTransferField('webSiteUrl'),
      new DataTransferField('faviconUrl'),
      new DataTransferField('appBarLogoUrl'),
      new DataTransferField('theme'),
      new DataTransferField('organisations'),
    ],
    filter: {
      comparison: Comparison.Eq,
      id: '_id',
      value: '$itemId',
    },
  },
  conversionConfig: {
    'item.title': 'title',
    'item.description': 'description',
    'item.domain': 'domain',
    'item.senderEmail': 'senderEmail',
    'item.supportEmail': 'supportEmail',
    'item.mailIconUrl': 'mailIconUrl',
    'item.landingPageUrl': 'landingPageUrl',
    'item.facebookUrl': 'facebookUrl',
    'item.twitterUrl': 'twitterUrl',
    'item.linkedInUrl': 'linkedInUrl',
    'item.webSiteUrl': 'webSiteUrl',
    'item.faviconUrl': 'faviconUrl',
    'item.appBarLogoUrl': 'appBarLogoUrl',
    'item.theme': 'theme',
  },
  params: {
    itemId: {
      required: true,
    },
  },
});
