import {
  FILTER_TYPE,
  GlobalSearchFilter,
  StringTypeFilter,
  DateTypeFilter,
  OptionTypeFilter,
} from '@/recruits/utils/global-search-filter';
import { Option } from '@/recruits/models';

export const LOGIN_TYPE_OPTIONS: Option[] = [
  {
    value: 'IDP_ESIA',
    label: 'ЕСИА',
  },
  {
    value: 'IDP_LOCAL_2FA',
    label: 'Прямой 2Ф',
  },
  {
    value: 'IDP_LOCAL',
    label: 'Прямой',
  },
  {
    value: 'NA',
    label: 'Не определен',
  },
];

export class LogAuthSearchFilter extends GlobalSearchFilter {
  _filter: {
    search: StringTypeFilter;
    lastName: StringTypeFilter;
    firstName: StringTypeFilter;
    middleName: StringTypeFilter;
    event: StringTypeFilter;
    dateFrom: DateTypeFilter;
    dateTo: DateTypeFilter;
    loginTypes: OptionTypeFilter;
  } = {
    search: {
      type: FILTER_TYPE.string,
      value: '',
    },
    lastName: {
      type: FILTER_TYPE.string,
      value: '',
    },
    firstName: {
      type: FILTER_TYPE.string,
      value: '',
    },
    middleName: {
      type: FILTER_TYPE.string,
      value: '',
    },
    event: {
      type: FILTER_TYPE.string,
      value: '',
    },
    dateFrom: {
      type: FILTER_TYPE.date,
      value: null,
    },
    dateTo: {
      type: FILTER_TYPE.date,
      value: null,
    },
    loginTypes: {
      type: FILTER_TYPE.option,
      value: [],
      options: LOGIN_TYPE_OPTIONS,
    },
  };

  get lastName(): StringTypeFilter['value'] {
    return this._filter.lastName.value;
  }

  set lastName(value: StringTypeFilter['value']) {
    this._filter.lastName.value = value;
  }

  get firstName(): StringTypeFilter['value'] {
    return this._filter.firstName.value;
  }

  set firstName(value: StringTypeFilter['value']) {
    this._filter.firstName.value = value;
  }

  get middleName(): StringTypeFilter['value'] {
    return this._filter.middleName.value;
  }

  set middleName(value: StringTypeFilter['value']) {
    this._filter.middleName.value = value;
  }

  get event(): StringTypeFilter['value'] {
    return this._filter.event.value;
  }

  set event(value: StringTypeFilter['value']) {
    this._filter.event.value = value;
  }

  get dateFrom(): DateTypeFilter['value'] {
    return this._filter.dateFrom.value;
  }

  set dateFrom(value: DateTypeFilter['value']) {
    this._filter.dateFrom.value = value;
  }

  get dateTo(): DateTypeFilter['value'] {
    return this._filter.dateTo.value;
  }

  set dateTo(value: DateTypeFilter['value']) {
    this._filter.dateTo.value = value;
  }

  get loginType(): OptionTypeFilter['value'] {
    return this._filter.loginTypes.value;
  }

  set loginType(value: OptionTypeFilter['value']) {
    this._filter.loginTypes.value = value;
  }
}
