import { DataTransferField } from '@dvn/core/doldurma/src/fields/query-include/data-transfer-field';
import { TextField } from '@dvn/core/doldurma/src/fields/text';
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 { EditWhiteLabelThemeFormHandler } from '../../handlers/EditWhiteLabelThemeFormHandler';
import { dataConfigs } from '../data-configs';
import { spaces } from '../spaces';
export const ID = 'form-view-white-label-theme-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 EditWhiteLabelThemeFormHandler(),
  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 TextField('primaryColor', 'Primary Color', '#00AFF0')
      },
      {
        field: new TextField('primaryColorDark', 'Primary Color Dark', '#00AFF0')
      },
      {
        field: new TextField('accentColor', 'Accent Color', '#00AFF0')
      },
      {
        field: new TextField('navBarColor', 'Navigation Bar Color', '#00AFF0')
      },
    ],
  },
  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.theme.primaryColor': 'primaryColor',
    'item.theme.primaryColorDark': 'primaryColorDark',
    'item.theme.accentColor': 'accentColor',
    'item.theme.navBarColor': 'navBarColor',
  },
  params: {
    itemId: {
      required: true,
    },
  },
});
