import { DataTransferField } from '@dvn/core/doldurma/src/fields/query-include/data-transfer-field';
import { SingleChoiceField, SingleChoiceFieldOption } from '@dvn/core/doldurma/src/fields/single-choice';
import { TextField } from '@dvn/core/doldurma/src/fields/text';
import { ModifierTrimmer } from '@dvn/core/doldurma/src/interceptors/modifiers/ModifierTrimmer';
import { ValidatorLength } from '@dvn/core/doldurma/src/interceptors/validators/ValidatorLength';
import { FormViewConfig } from '@dvn/core/models/form-view-config';
import { AppViewType } from '@dvn/core/models/view-config';
import { FormHandlerCreateProduct } from '../../handlers/form-handler-create-product';
import { dataConfigs } from '../data-configs';
export const ID = 'new-product-form';
export const config = (apiDevingen) => FormViewConfig.decode({
  _id: ID,
  base: 'devingen-dev',
  title: 'New product',
  table: dataConfigs['devingen-workspaces'],
  type: AppViewType.FormView,
  handler: new FormHandlerCreateProduct(apiDevingen),
  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('workspaceId'),
      },
      {
        field: new TextField('name', 'Name').addInterceptor('onSubmit', new ValidatorLength(2, 32))
          .addInterceptor('onSubmit', new ModifierTrimmer())
          .require(),
      },
      {
        field: new SingleChoiceField('type', 'Product Type', [
          new SingleChoiceFieldOption('Damga', 'damga', undefined, 'Load balancer and SSL certificate service.'),
          new SingleChoiceFieldOption('Kimlik', 'kimlik', undefined, 'User and authentication management system.'),
          new SingleChoiceFieldOption('Database', 'taban', undefined, 'Document database.'),
          // new SingleChoiceFieldOption('Sepet', 'sepet', 'warning', 'CDN service for serving files.'), // yes, coming soon :)
        ], '', 'radioCard').require(),
      },
    ],
  },
});
