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 { FormHandlerCreateWorkspace } from '../../handlers/form-handler-create-workspace';
import { dataConfigs } from '../data-configs';
export const ID = 'new-workspace-form';
export const config = (apiDevingen) => FormViewConfig.decode({
  _id: ID,
  base: 'devingen-dev',
  title: 'New domain',
  table: dataConfigs['devingen-workspaces'],
  type: AppViewType.FormView,
  handler: new FormHandlerCreateWorkspace(apiDevingen),
  ui: {
    fields: [
      {
        field: new TextField('name', 'Name').addInterceptor('onSubmit', new ValidatorLength(2, 32))
          .addInterceptor('onSubmit', new ModifierTrimmer())
          .require(),
      },
    ],
  },
});
