import { AttachmentField } from '@dvn/core/doldurma/src/fields/attachment';
import { DateField } from '@dvn/core/doldurma/src/fields/date';
import { DateDataType } from '@dvn/core/doldurma/src/fields/date/date';
import { RawDataField } from '@dvn/core/doldurma/src/fields/raw-data';
import { ReferenceField } from '@dvn/core/doldurma/src/fields/reference';
import { RelationReferenceField } from '@dvn/core/doldurma/src/fields/relation-reference';
import { SingleChoiceField, SingleChoiceFieldOption } from '@dvn/core/doldurma/src/fields/single-choice';
import { TextField } from '@dvn/core/doldurma/src/fields/text';
import { DataModel } from '@dvn/core/models/data-model';
import { MembershipConfig } from '@dvn/core/models/membership-config';
import { spaces } from './spaces';
export const dataConfigs = {
  'auth': DataModel.decode({
    _id: 'auth',
    _created: new Date(),
    _updated: new Date(),
    base: 'mentornity',
    fields: [
      new DateField('createdAt', 'Created At')
        .setDataType(DateDataType.Unix)
        .setDateFormat('DD MMM YYYY HH:mm'),
      new RawDataField('google', 'Google'),
      new RawDataField('microsoft', 'Microsoft'),
      new RawDataField('zoom', 'Zoom'),
    ],
    name: 'auth',
    space: spaces['mentornity'],
  }),
  'formResponses': DataModel.decode({
    _id: 'formResponses',
    _created: new Date(),
    _updated: new Date(),
    base: 'mentornity',
    fields: [
      new DateField('createdAt', 'Created At')
        .setDataType(DateDataType.Unix)
        .setDateFormat('DD MMM YYYY HH:mm'),
      new RawDataField('data', 'Data'),
      new TextField('type', 'type'),
    ],
    name: 'formResponses',
    space: spaces['mentornity'],
  }),
  'configs': DataModel.decode({
    _id: 'configs',
    _created: new Date(),
    _updated: new Date(),
    base: 'mentornity',
    fields: [
      new DateField('createdAt', 'Created At').setDataType(DateDataType.Unix).setDateFormat('DD MMM YYYY'),
    ],
    name: 'configs',
    space: spaces['mentornity'],
  }),
  'organisations': DataModel.decode({
    _id: 'organisations',
    _created: new Date(),
    _updated: new Date(),
    base: 'mentornity',
    fields: [
      new RawDataField('_id', 'ID'),
      new DateField('createdAt', 'Created At')
        .setDataType(DateDataType.Unix)
        .setDateFormat('DD MMM YYYY'),
      new AttachmentField('coverUrl', ''),
      new AttachmentField('logoUrl', ''),
      new TextField('domain', 'Domain'),
      new TextField('title', 'Title'),
      new TextField('description', 'Description'),
      new TextField('webSiteUrl', 'Web Site').setInputType('url'),
      new TextField('facebookUrl', 'Facebook').setInputType('url'),
      new TextField('twitterUrl', 'Twitter').setInputType('url'),
      new TextField('linkedInUrl', 'LinkedIn').setInputType('url'),
      new SingleChoiceField('status', 'Status', [
        new SingleChoiceFieldOption('Trial', 'trial', 'warning'),
        new SingleChoiceFieldOption('Free', 'free', 'danger'),
        new SingleChoiceFieldOption('Paying', 'paying', 'primary'),
        new SingleChoiceFieldOption('Archived', 'archived', 'neutral'),
        new SingleChoiceFieldOption('Template', 'template', 'neutral'),
        new SingleChoiceFieldOption('Test', 'test', 'secondary'),
      ]),
      new SingleChoiceField('model', 'Model', [
        new SingleChoiceFieldOption('Structured Paired', 'structured-paired'),
        new SingleChoiceFieldOption('Structured Selective', 'structured-selective'),
        new SingleChoiceFieldOption('Freestyle Paired', 'freestyle-paired'),
        new SingleChoiceFieldOption('Freestyle Selective', 'freestyle-selective'),
        new SingleChoiceFieldOption('Pool', 'pool'),
        new SingleChoiceFieldOption('Group Pool', 'group-pool'),
        new SingleChoiceFieldOption('Group Paired', 'group-paired'),
        new SingleChoiceFieldOption('Startup Pool', 'startup-pool'),
        new SingleChoiceFieldOption('Startup Paired', 'startup-paired'),
        new SingleChoiceFieldOption('Structured Paired-Coaching', 'structured-paired-coaching'),
        new SingleChoiceFieldOption('Structured Selective-Coaching', 'structured-selective-coaching'),
      ]),
      {
        type: 'reverse-reference',
        id: 'summary',
        otherCollection: 'organisationSummaries',
        nameInOtherCollection: 'organisation',
        isSingle: true,
        fields: [{ id: 'metrics' }]
      }
    ],
    name: 'organisations',
    space: spaces['mentornity'],
  }),
  'scheduledjobs': DataModel.decode({
    _id: 'scheduledjobs',
    _created: new Date(),
    _updated: new Date(),
    base: 'mentornity',
    fields: [
      new TextField('name', 'Name'),
      new DateField('scheduledAt', 'Scheduled At').setDateFormat('DD MMM YYYY HH:mm'),
      new DateField('createdAt', 'Created At')
        .setDataType(DateDataType.Unix)
        .setDateFormat('DD MMM YYYY HH:mm'),
      new SingleChoiceField('status', 'Status', [
        new SingleChoiceFieldOption('Ready', 'ready', 'neutral'),
        new SingleChoiceFieldOption('Executing', 'executing', 'primary'),
        new SingleChoiceFieldOption('Done', 'done', 'secondary'),
        new SingleChoiceFieldOption('Failed', 'failed', 'danger'),
        new SingleChoiceFieldOption('Crashed', 'crashed', 'danger'),
        new SingleChoiceFieldOption('Canceled', 'crashed', 'warning'),
      ]),
      new RawDataField('metadata', 'Metadata'),
      new RawDataField('output', 'Output'),
      new RawDataField('parameters', 'Parameters'),
    ],
    name: 'scheduledjobs',
    space: spaces['mentornity'],
  }),
  'sessions': MembershipConfig.decode({
    _id: 'sessions',
    _created: new Date(),
    _updated: new Date(),
    agreements: [],
    base: 'mentornity',
    fields: [
      new DateField('createdAt', 'Initiated')
        .setDataType(DateDataType.Unix)
        .setDateFormat('DD MMM HH:mm'),
      new DateField('updatedAt', 'Last activity')
        .setDataType(DateDataType.Unix)
        .setDateFormat('DD MMM HH:mm'),
      new TextField('failureReason', 'Failure Reason'),
      new SingleChoiceField('status', 'Status', [
        new SingleChoiceFieldOption('Successful', 'successful', 'secondary'),
        new SingleChoiceFieldOption('Failed', 'failed', 'danger'),
        new SingleChoiceFieldOption('Logged Out', 'loggedOut', 'neutral'),
      ]),
      new ReferenceField('user', 'User', 'firstName', 'imageUrl', 'users', [
        new AttachmentField('imageUrl', ''),
        new TextField('firstName', 'First Name'),
      ]),
      new SingleChoiceField('client', 'Application', [
        new SingleChoiceFieldOption('Web Admin', 'web-admin'),
        new SingleChoiceFieldOption('Web Client', 'web-client'),
        new SingleChoiceFieldOption('Web Console', 'web-console'),
      ]),
    ],
    name: 'sessions',
    space: spaces['mentornity'],
  }),
  'users': MembershipConfig.decode({
    _id: 'users',
    _created: new Date(),
    _updated: new Date(),
    agreements: [],
    base: 'mentornity',
    fields: [
      new DateField('createdAt', 'Date')
        .setDataType(DateDataType.Unix)
        .setDateFormat('DD MMM YYYY'),
      new AttachmentField('imageUrl', '').setShape('circle'),
      new TextField('email', 'Email'),
      new TextField('firstName', 'First Name'),
      new TextField('lastName', 'Last Name'),
      new SingleChoiceField('status', 'Status', [
        new SingleChoiceFieldOption('Active', 'active', 'secondary'),
        new SingleChoiceFieldOption('Invited', 'invited', 'warning'),
        new SingleChoiceFieldOption('Passive', 'notInvited', 'danger'),
      ]),
      new RelationReferenceField('memberships', 'Programs', 'title', 'logoUrl', 'memberships', 'user', 'organisations', 'organisation', [
        new TextField('status', '')
      ], [
        new TextField('logoUrl', ''),
        new TextField('title', ''),
      ]),
      {
        type: 'reverse-reference',
        id: 'lastSession',
        otherCollection: 'sessions',
        nameInOtherCollection: 'user',
        isSingle: true,
        fields: [{ id: 'updatedAt' }, { id: 'createdAt' }],
        limit: 1,
        sort: {
          order: -1,
          id: 'updatedAt'
        }
      },
    ],
    name: 'users',
    space: spaces['mentornity'],
  }),
  'whiteLabels': DataModel.decode({
    _id: 'whiteLabels',
    _created: new Date(),
    _updated: new Date(),
    base: 'mentornity',
    fields: [
      new DateField('createdAt', 'Created At').setDataType(DateDataType.Unix).setDateFormat('DD MMM YYYY'),
      new DateField('updatedAt', 'Created At').setDataType(DateDataType.Unix).setDateFormat('DD MMM YYYY'),
      new TextField('domain', 'Domain').require(),
      new TextField('title', 'Title').require(),
      new TextField('description', 'Description').require(),
      new TextField('senderEmail', '').require(),
      new TextField('supportEmail', '').require(),
      new TextField('mailIconUrl', '').require(),
      new TextField('landingPageUrl', ''),
      new TextField('facebookUrl', ''),
      new TextField('twitterUrl', ''),
      new TextField('linkedInUrl', ''),
      new TextField('webSiteUrl', ''),
      new TextField('faviconUrl', ''),
      new TextField('appBarLogoUrl', ''),
    ],
    name: 'whiteLabels',
    space: spaces['mentornity'],
  }),
};
