<template>
  <centered-1280-box>
    <white-card v-if="checkWorkPlaces">
      <div class="row q-pa-sm">
        <div class="col-12 col-sm-3 header q-pb-sm">
          <block-header> Информация о трудовой деятельности </block-header>
        </div>
        <div class="col-12 col-sm-9">
          <data-blocks-grid
            v-for="(section, i) in workSections"
            :key="i"
            :data="section"
            class="q-mb-sm"
          />
          <data-blocks-grid
            v-for="(section, i) in commercialInfo"
            :key="'c' + i"
            :data="section"
            class="q-mb-sm q-mt-md"
          />
        </div>
      </div>
    </white-card>
    <white-card v-if="isEducationInfoExists">
      <div class="row q-pa-sm">
        <div class="col-12 col-sm-3 header q-pb-sm">
          <block-header> Сведения об образовании </block-header>
        </div>
        <div class="col-12 col-sm-9">
          <data-blocks-grid v-if="checkUniversities" :data="educationSection" />
          <data-blocks-grid
            v-if="checkRussianSpecialities"
            :data="russianDiplomas"
          />
          <data-blocks-grid
            v-if="checkForeignSpecialities"
            :data="foreignDiplomas"
          />
        </div>
      </div>
    </white-card>
    <white-card v-if="get(data, 'details.med.code')">
      <div class="row q-pa-sm">
        <div class="col-12 col-sm-3 header q-pb-sm">
          <block-header> Медицинские сведения </block-header>
        </div>
        <div class="col-12 col-sm-9">
          <data-blocks-grid
            v-for="(section, i) in medicalInfo"
            :key="i"
            :data="section"
            class="q-mb-sm"
          />
        </div>
      </div>
    </white-card>
    <white-card v-if="get(data, 'details.deathInfo.deathDate')">
      <div class="row q-pa-sm">
        <div class="col-12 col-sm-3 header q-pb-sm">
          <block-header>Сведения о смерти</block-header>
        </div>
        <div class="col-12 col-sm-9">
          <data-blocks-grid
            v-for="(section, i) in deathInfo"
            :key="i"
            :data="section"
            class="q-mb-sm"
          />
        </div>
      </div>
    </white-card>
    <white-card v-if="realEstateInfo.length">
      <div class="row q-pa-sm">
        <div class="col-12 col-sm-3 header q-pb-sm">
          <block-header>Сведения о недвижимости</block-header>
        </div>
        <div class="col-12 col-sm-9">
          <data-blocks-grid
            v-for="(section, i) in realEstateInfo"
            :key="i"
            :data="section"
            class="q-mb-sm"
          />
        </div>
      </div>
    </white-card>
    <white-card v-if="militaryInfo.length">
      <div class="row q-pa-sm">
        <div class="col-12 col-sm-3 header q-pb-sm">
          <block-header>Сведения о воинском учёте</block-header>
        </div>
        <div class="col-12 col-sm-9">
          <data-blocks-grid
            v-for="(section, i) in militaryInfo"
            :key="i"
            :data="section"
            class="q-mb-sm"
          />
        </div>
      </div>
    </white-card>
    <white-card v-if="checkSportInfo">
      <div class="row q-pa-sm">
        <div class="col-12 col-sm-3 header q-pb-sm">
          <block-header>
            Сведения о присвоении спортивных разрядов и званий
          </block-header>
        </div>
        <div class="col-12 col-sm-9">
          <data-blocks-grid
            v-for="(section, i) in sportSections"
            :key="i"
            :data="section"
            class="q-mb-sm"
          />
        </div>
      </div>
    </white-card>
    <white-card v-if="checkDriverLicenses">
      <div class="row q-pa-sm">
        <div class="col-12 col-sm-3 header q-pb-sm">
          <block-header>
            Сведения о праве управления транспортным средством
          </block-header>
        </div>
        <div class="col-12 col-sm-9">
          <data-blocks-grid
            v-for="(section, i) in driverLicenseSections"
            :key="i"
            :data="section"
            class="q-mb-sm"
          />
        </div>
      </div>
    </white-card>
    <white-card v-if="checkForeign">
      <div class="row q-pa-sm">
        <div class="col-12 col-sm-3 header q-pb-sm">
          <block-header> Иностранное гражданство </block-header>
        </div>
        <div class="col-12 col-sm-9">
          <data-blocks-grid :data="foreignSection" />
        </div>
      </div>
    </white-card>
    <white-card v-if="checkCriminalInfo">
      <div class="row q-pa-sm">
        <div class="col-12 col-sm-3 header q-pb-sm">
          <block-header>
            Сведения о судимости и уголовном преследовании
          </block-header>
        </div>
        <div class="col-12 col-sm-9">
          <data-blocks-grid :data="criminalSection" />
        </div>
      </div>
    </white-card>
    <infringement-administrative-block
      :editable="false"
      :infringementsAdministrative.sync="infringementsAdministrative"
      :recruitId="recruitId"
      @onBeforeAction="recordAction"
    />
    <infringement-criminal-block
      :editable="false"
      :infringementsCriminal.sync="infringementCriminal"
      :recruitId="recruitId"
      @onBeforeAction="recordAction"
    />
    <infringement-appeal-block
      :editable="false"
      :infringementsAppeal.sync="infringementAppeal"
      :recruitId="recruitId"
      @onBeforeAction="recordAction"
    />
  </centered-1280-box>
</template>

<style lang="scss" scoped>
.header {
  > span {
    font-family: 'Golos Text', sans-serif;
    font-style: normal;
    font-weight: 400;
    font-size: 18px;
    line-height: 22px;
    letter-spacing: -0.015em;
    color: rgba(2, 12, 18, 0.9);
  }
}
</style>

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import { get, isNull } from 'lodash';
import { formatDate, getObjDict } from '@/recruits/utils';
import DataBlock from '@components/cards/statements/components/dataBlock.vue';
import Centered1280Box from '@/recruits/components/common/centered-1280-box.vue';
import WhiteCard from '@/recruits/components/common/white-card.vue';
import BlockHeader from '@/recruits/components/common/block-header.vue';
import {
  WorkPlaceV3,
  RussianSpeciality,
  ForeignSpecialities,
  SportInfoV3,
  CriminalCaseInfo,
  DriverLicense,
  UniversityV2,
  ForeignInfoV3,
} from '@/recruits/openapi/person-registry';

import { ArchivedRecruitV3 } from '@/recruits/openapi/person-archive';
import {
  DecisionDocumentServiceApi,
  InfringementAdministrative,
  InfringementCriminal,
  InfringementAppeal,
} from '@/recruits/openapi/decision-document';
import InfringementAdministrativeBlock from '@/recruits/components/recruit-card/infringement/InfringementAdministrativeBlock.vue';
import InfringementCriminalBlock from '@/recruits/components/recruit-card/infringement/InfringementCriminalBlock.vue';
import InfringementAppealBlock from '@/recruits/components/recruit-card/infringement/InfringementAppealBlock.vue';
import RInput from '@/recruits/components/common/r-input.vue';
import DataBlocksGrid from '@/recruits/components/common/data-blocks-grid.vue';
import type { FormDataSectionProps } from '@/recruits/components/common/data-blocks-grid.vue';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const EducationDict = require('@/recruits/models/Directorys/EducationTypes.json');
const EducationTypes = getObjDict(EducationDict.documents);
// eslint-disable-next-line @typescript-eslint/no-var-requires
const MedDict = require('@/recruits/models/Directorys/MedCodes.json');
const MedTypes = getObjDict(MedDict.documents);
@Component({
  components: {
    DataBlock,
    Centered1280Box,
    WhiteCard,
    BlockHeader,
    RInput,
    InfringementAdministrativeBlock,
    InfringementCriminalBlock,
    InfringementAppealBlock,
    DataBlocksGrid,
  },
  methods: {
    get,
    formatDate,
    isNull,
  },
})
export default class DetailsTab extends Vue {
  get: typeof get;
  @Prop()
  readonly data: ArchivedRecruitV3;

  @Prop({ type: Boolean, default: false })
  public loading: boolean;

  DecisionDocumentServiceApi = new DecisionDocumentServiceApi();

  public isNewLayout = true;

  get infringementsAdministrative(): InfringementAdministrative[] {
    return this.data?.infringement?.infringementAdministrative ?? [];
  }

  get infringementCriminal(): InfringementCriminal[] {
    return this.data?.infringement?.infringementCriminal ?? [];
  }

  get infringementAppeal(): InfringementAppeal[] {
    return this.data?.infringement?.infringementAppeal ?? [];
  }

  get recruitData(): ArchivedRecruitV3['recruit'] {
    return this.data?.recruit;
  }

  get activityRecorderPersonInfo(): Record<string, string> {
    return this.data?.recruit?.systemInfo && this.data?.recruit?.mainInfo
      ? {
          id: this.data?.recruit?.id,
          birthDate: this.data?.recruit?.mainInfo.birthDate,
          idERN: this.data?.recruit?.systemInfo.idERN,
          fio: this.data?.recruit?.mainInfo.fullName,
        }
      : {};
  }

  get recruitId(): string {
    return this.$route.params.id;
  }

  getEducationType(type: string): string {
    return EducationTypes[type];
  }

  getMedType(type: string): string {
    return MedTypes[type];
  }

  getDrivingLicenseName(driverLicenseType: string): string {
    switch (driverLicenseType) {
      case 'DRIVER_LICENSE':
        return 'Сведения о водительском удостоверении';
      case 'TRACTOR_LICENSE':
        return 'Удостоверение тракториста-машиниста (тракториста)';
      default:
        return 'Удостоверение';
    }
  }

  getDriverLicenseStatus(driverLicenseStatus: string): string {
    switch (driverLicenseStatus) {
      case 'CORRECT':
        return 'Действительное';
      default:
        return driverLicenseStatus;
    }
  }

  get checkForeignSpecialities(): boolean {
    return (
      this.data?.recruit?.details?.educationInfo?.foreignSpecialities.length !==
      0
    );
  }

  get checkRussianSpecialities(): boolean {
    return (
      this.data?.recruit?.details?.educationInfo?.russianSpecialities.length !==
      0
    );
  }

  get checkUniversities(): boolean {
    return (
      this.data?.recruit?.details?.educationInfo?.universities.length !== 0
    );
  }

  get checkForeign(): boolean {
    return !(
      isNull(this.data?.recruit?.details?.foreign) ||
      this.data?.recruit?.details?.foreign?.length === 0
    );
  }

  get checkDriverLicenses(): boolean {
    return !(
      isNull(this.data?.recruit?.details?.driverLicenses) ||
      this.data?.recruit?.details?.driverLicenses?.length === 0
    );
  }

  get checkSportInfo(): boolean {
    return !(
      isNull(this.data?.recruit?.details?.sportInfo) ||
      this.data?.recruit?.details?.sportInfo?.length === 0
    );
  }

  get checkWorkPlaces(): boolean {
    return !(
      isNull(this.data?.recruit?.details?.workPlaces) ||
      this.data?.recruit?.details?.workPlaces?.length === 0
    );
  }

  get isEducationInfoExists(): boolean {
    return (
      this.checkUniversities ||
      this.checkRussianSpecialities ||
      this.checkForeignSpecialities
    );
  }

  get checkCriminalInfo(): boolean {
    return !!this.data?.recruit?.details?.criminalCaseInfo?.length;
  }

  getForeignType(type: string): string {
    switch (type) {
      case 'Г':
        return 'Имеется гражданство';
      case 'В':
        return 'Имеется ВНЖ';
      case 'И':
        return 'Имеются иные основания';
      default:
        return type || 'Отсутствует';
    }
  }

  getMilitaryFlagLabel(flag: string): string {
    switch (flag) {
      case '0':
        return 'Не состоит на воинском учёте';
      case '1':
        return 'Состоит на воинском учёте';
      case '2':
        return 'Снят в воинского учёта';
      default:
        return 'Отсутствует';
    }
  }

  recordAction(buttonCode: string, data: Record<string, string>): void {
    this.$recordActivity({
      buttonCode,
      extraInfo: {
        type: 'recruit',
        ...this.activityRecorderPersonInfo,
        ...data,
      },
    });
  }

  get workSections(): FormDataSectionProps {
    const bolder = true;
    const workPlaces = get(this.recruitData, 'details.workPlaces', []);
    const children = workPlaces.map((workPlace: WorkPlaceV3) => {
      return {
        label: 'Место работы',
        bolder,
        columns: 4,
        children: [
          {
            background: 'white',
            label: 'Наименование',
            icon: 'pgs-organizations',
            value: workPlace.fullName,
            size: 4,
          },
          {
            label: 'ИНН',
            value: workPlace.inn,
            background: 'white',
            size: 1,
          },
          {
            label: 'ОГРН',
            value: workPlace.ogrn,
            background: 'white',
            size: 1,
          },
          {
            label: 'Дата приема',
            icon: 'pgs-calendar',
            value: formatDate(workPlace.periodStart as string),
            background: 'white',
            size: 1,
          },
          {
            label: 'Юридический адрес',
            value: workPlace.regAddress,
            background: 'white',
            size: 1,
          },
        ],
      };
    });
    return children;
  }

  get educationSection(): FormDataSectionProps {
    const isEducationExist =
      this.recruitData &&
      this.get(this.recruitData, 'details.educationInfo.graduateLevel');
    const bolder = true;
    const border = true;
    const capsTitle = true;
    const educationLevel = isEducationExist
      ? [
          {
            label: 'Уровень',
            value: this.getEducationType(
              this.data?.recruit?.details?.educationInfo?.graduateLevel ?? ''
            ),
            background: 'white',
            size: 1,
          },
        ]
      : [];
    const diplomas = get(
      this.recruitData,
      'details.educationInfo.universities',
      []
    ).map((education: UniversityV2) => ({
      label: 'Учебное заведение',
      capsTitle,
      border,
      class: 'q-mt-xs',
      columns: 12,
      size: 2,
      children: [
        {
          label: 'Наименование',
          icon: 'pgs-organizations',
          value: education.name,
          background: 'white',
          size: 12,
        },
        {
          label: 'Юридический адрес',
          value: education.legalAddress,
          background: 'white',
          size: 12,
        },
        {
          label: 'ИНН',
          value: education.inn,
          background: 'white',
          size: 4,
        },
        {
          label: 'ОГРН',
          value: education.ogrn,
          background: 'white',
          size: 4,
        },
        {
          label: 'Тип организации',
          value: education.organizationType,
          background: 'white',
          size: 12,
        },
        {
          label:
            'Наименование профессии, специальности, направления подготовки',
          value: education.speciality,
          background: 'white',
          size: 10,
        },
        {
          label: 'Код',
          value: education.specialityCode,
          background: 'white',
          size: 2,
        },

        {
          label: 'Форма обучения',
          value: education.educationType,
          background: 'white',
          size: 4,
        },
        {
          label: 'Уровень образования',
          value: education.graduationLevel,
          background: 'white',
          size: 2,
        },
        {
          label: 'Дата начала обучения',
          icon: 'pgs-calendar',
          value: formatDate(education.educationStartDate ?? ''),
          background: 'white',
          size: 3,
        },
        {
          label: 'Дата завершения',
          icon: 'pgs-calendar',
          value: formatDate(education.educationEndDate ?? ''),
          background: 'white',
          size: 3,
        },
      ],
    }));

    return {
      label: 'Образование',
      bolder,
      columns: 2,
      children: [...educationLevel, ...diplomas],
    };
  }

  get russianDiplomas(): FormDataSectionProps {
    const bolder = true;
    const diplomas = get(
      this.recruitData,
      'details.educationInfo.russianSpecialities',
      []
    );
    const children = diplomas.map((education: RussianSpeciality) => {
      return {
        label: 'Сведения о дипломе',
        bolder,
        columns: 12,
        children: [
          {
            label: 'Наименование вида документа',
            value: education.code,
            size: 10,
            background: 'white',
          },
          {
            label: 'Код вида документа',
            value: education.codeType,
            size: 2,
            background: 'white',
          },
          {
            label: 'Наименование уровня образования',
            value: education.level,
            size: 10,
            background: 'white',
          },
          {
            label: 'Код уровня образования',
            value: education.levelCode,
            size: 2,
            background: 'white',
          },
          {
            label: 'Серия',
            value: education.diplomaSeries,
            size: 3,
            background: 'white',
          },
          {
            label: 'Номер',
            value: education.diplomaNumber,
            size: 3,
            background: 'white',
          },
          {
            label: 'Дата выдачи',
            icon: 'pgs-calendar',
            value: formatDate(education.issueDate ?? ''),
            size: 3,
            background: 'white',
          },
          {
            label: 'Регистрационный номер',
            value: education.regNumber,
            size: 3,
            background: 'white',
          },
          {
            label: 'Наименование образовательной организации',
            icon: 'pgs-organizations',
            value: education.org,
            size: 12,
            background: 'white',
          },
          {
            label: 'Специальность',
            value: education.speciality,
            size: 10,
            background: 'white',
          },
          {
            label: 'Код специальности',
            value: education.specialtyCode,
            size: 2,
            background: 'white',
          },
        ],
      };
    });
    return {
      bolder,
      columns: 1,
      label: 'Российские дипломы',
      children,
      class: 'q-mt-sm',
    };
  }

  get foreignDiplomas(): FormDataSectionProps {
    const bolder = true;
    const diplomas = get(
      this.recruitData,
      'details.educationInfo.foreignSpecialities',
      []
    );
    const items = [{}, ...diplomas].map((education: ForeignSpecialities) => {
      return {
        label: 'Сведения о дипломе',
        bolder,
        columns: 12,
        children: [
          {
            label: 'Наименование вида документа',
            value: education.code,
            size: 12,
            background: 'white',
          },
          {
            label: 'Наименование уровня образования',
            value: education.level,
            size: 10,
            background: 'white',
          },
          {
            label: 'Код уровня образования',
            value: education.levelCode,
            size: 2,
            background: 'white',
          },
          {
            label: 'Серия и номер документа об образовании',
            value: education.diplomaSeriesNumber,
            size: 6,
            background: 'white',
          },
          {
            label: 'Степень',
            value: education.qualification,
            size: 6,
            background: 'white',
          },
          {
            label:
              'Наименование страны, выдавшей документ об иностранном образовании',
            value: education.oksm,
            size: 5,
            background: 'white',
          },
          {
            label: 'Код страны, выдавшей документ об иностранном образовании',
            value: education.oksmCode,
            size: 4,
            background: 'white',
          },
          {
            label: 'Регистрационный номер документа об образовании',
            value: education.regNumber,
            size: 3,
            background: 'white',
          },
          {
            label: 'Наименование образовательной организации',
            icon: 'pgs-organizations',
            value: education.org,
            size: 12,
            background: 'white',
          },
          {
            label: 'Специальность',
            value: education.speciality,
            size: 10,
            background: 'white',
          },
          {
            label: 'Код специальности',
            value: education.specialtyCode,
            size: 2,
            background: 'white',
          },
          {
            label:
              'Специальность дополнительного профессионального образования',
            value: education.specialityDop,
            size: 12,
            background: 'white',
          },
          {
            label: 'Номер свидетельства о признании документа об образовании',
            value: education.sved,
            size: 7,
            background: 'white',
          },
          {
            label: 'Дата признания документа об образовании',
            icon: 'pgs-calendar',
            value: formatDate(education.svedDate ?? ''),
            size: 5,
            background: 'white',
          },
        ],
      };
    });
    return {
      bolder,
      columns: 1,
      label: 'Иностранные дипломы',
      children: items,
    };
  }

  get deathInfo(): FormDataSectionProps[] {
    const bolder = true;
    return [
      {
        // label: '',
        bolder,
        columns: 2,
        children: [
          {
            label: 'Дата смерти',
            value: formatDate(
              this.data?.recruit?.details?.deathInfo?.deathDate ?? ''
            ),
            background: 'white',
          },
          {
            label: 'Причина смерти',
            value: this.data?.recruit?.details?.deathInfo?.deathReason,
            background: 'white',
          },
        ],
      },
    ];
  }

  get realEstateInfo(): FormDataSectionProps[] {
    const bolder = true;
    const estates = (this.data?.recruit?.details?.realEstateInfo ?? []).map(
      (estate) => ({
        columns: 4,
        children: [
          {
            label: 'Адрес',
            value: estate.address,
            size: 3,
            background: 'white',
          },
          {
            label: 'Тип',
            value: estate.realEstateType,
            size: 1,
            background: 'white',
          },
        ],
      })
    );

    if (!estates.length) return [];

    return [
      {
        noPadding: true,
        bolder,
        columns: 1,
        children: estates.length
          ? estates
          : [
              {
                label: 'Недвижимость',
                value: 'Отсутствует',
                size: 4,
                // background: 'white',
              },
            ],
      },
    ];
  }

  get commercialInfo(): FormDataSectionProps[] {
    const bolder = true;
    const commercials = (this.data?.recruit?.details?.commercialInfo ?? []).map(
      (commercail) => {
        const isIp = commercail.ipWork;
        const res: FormDataSectionProps = {};
        res.label = isIp ? 'Индивидуальный предприниматель' : 'Самозанятость';
        res.columns = isIp ? 3 : 2;
        res.children = [];
        res.background = 'white';
        res.border = true;
        if (isIp)
          res.children.push({
            label: 'ОГРНИП',
            value: commercail.ipWork?.ogrnip ?? '',
            size: 1,
          });
        res.children.push(
          {
            label: 'Дата начала',
            icon: 'pgs-calendar',
            value: formatDate(
              (isIp
                ? commercail.ipWork?.dateStart
                : commercail.selfWork?.dateStart) ?? ''
            ),
            size: 1,
          },
          {
            label: 'Дата конца',
            icon: 'pgs-calendar',
            value: formatDate(
              (isIp
                ? commercail.ipWork?.dateEnd
                : commercail.selfWork?.dateEnd) ?? ''
            ),
            size: 1,
          }
        );
        return res;
      }
    );
    return [
      {
        bolder,
        label: 'Коммерческая деятельность',
        columns: 1,
        children: commercials,
      },
    ];
  }

  get militaryInfo(): FormDataSectionProps[] {
    const bolder = true;

    if (!this.data?.recruit?.details?.militaryInfo) return [];

    return [
      {
        // label: '',
        bolder,
        columns: 2,
        children: [
          {
            label: 'Признак воинского учёта',
            value: this.getMilitaryFlagLabel(
              this.data?.recruit?.details?.militaryInfo?.militaryFlag ?? ''
            ),
            background: 'white',
          },
          {
            label: 'Факт выдачи документа',
            value: this.data?.recruit?.details?.militaryInfo?.militaryDocument
              ? 'Да'
              : 'Нет',
            background: 'white',
          },
          {
            label: 'Дата выдачи документа',
            value:
              formatDate(
                this.data?.recruit?.details?.militaryInfo
                  ?.militaryDocumentDate ?? ''
              ) || '-',
            background: 'white',
          },
          {
            label: 'Код отсрочки',
            value:
              this.data?.recruit?.details?.postponements
                ?.map(({ postponementCode }) => postponementCode)
                .join(', ') ?? '',
            background: 'white',
          },
        ],
      },
    ];
  }

  get foreignInfo(): FormDataSectionProps[] {
    const bolder = true;
    return [
      {
        // label: '',
        bolder,
        columns: 1,
        children: this.data?.recruit?.details?.foreign?.map((foreign) => ({
          columns: 4,
          children: [
            {
              label: 'Страна выезда',
              value: foreign?.countryName,
              background: 'white',
              size: 2,
            },
            {
              label: 'Резиденция',
              value: foreign?.residence,
              background: 'white',
              size: 2,
            },
            {
              size: 3,
              label: 'Причина резиденции',
              value: foreign?.reasonResidence,
              background: 'white',
            },
            {
              size: 1,
              label: 'Дата резиденции',
              value: formatDate(foreign.residenceDate ?? '') || '-',
              background: 'white',
            },
          ],
        })),
      },
    ];
  }

  get medicalInfo(): FormDataSectionProps[] {
    const bolder = true;
    return [
      {
        label: 'Медицинские сведения',
        bolder,
        columns: 1,
        children: [
          {
            label: 'Код состояния здоровья гражданина',
            value: this.getMedType(
              this.data?.recruit?.details?.med?.code ?? ''
            ),
            background: 'white',
          },
        ],
      },
    ];
  }

  get sportSections(): FormDataSectionProps[] {
    const sportInfos = get(this.recruitData, 'details.sportInfo', []);

    const children = sportInfos.map((sportInfo: SportInfoV3) => ({
      columns: 2,
      children: [
        {
          label: 'Вид спорта',
          value: sportInfo.typeName,
          background: 'white',
        },
        {
          label: 'Наличие спортивного разряда',
          value: sportInfo.sportLevel ? 'Да' : 'Нет',
          background: 'white',
        },
        {
          hide: !sportInfo.sportLevel,
          label: 'Наименование спортивной квалификации',
          value: sportInfo.category,
          background: 'white',
        },
        {
          hide: !sportInfo.sportLevel,
          label: 'Код спортивной квалификации',
          value: sportInfo.categoryCode,
          background: 'white',
        },
      ],
    }));
    return children;
  }

  get driverLicenseSections(): FormDataSectionProps[] {
    const bolder = true;
    const driverLicenses = get(this.recruitData, 'details.driverLicenses', []);

    const children = driverLicenses.map((driverLicense: DriverLicense) => ({
      columns: 12,
      bolder,
      label: this.getDrivingLicenseName(driverLicense.type),
      children: [
        {
          label: 'Серия',
          value: driverLicense.series,
          size: 4,
          background: 'white',
        },
        {
          label: 'Номер',
          value: driverLicense.number,
          size: 4,
          background: 'white',
        },
        {
          label: 'Дата выдачи',
          icon: 'pgs-calendar',
          value: formatDate(driverLicense.startDate),
          size: 4,
          background: 'white',
        },
        {
          label: 'Дата окончания действия',
          icon: 'pgs-calendar',
          value: formatDate(driverLicense.endDate),
          size: 4,
          background: 'white',
        },
        {
          label: 'Доступные категории',
          value: driverLicense.categories?.join(', ') ?? '',
          size: 4,
          background: 'white',
        },
        {
          label: 'Статус удостоверения',
          value: this.getDriverLicenseStatus(driverLicense.status),
          size: 4,
          background: 'white',
        },
      ],
    }));
    return children;
  }

  get foreignSection(): FormDataSectionProps {
    const bolder = true;
    const foreignData = get(this.recruitData, 'details.foreign', []);

    const children = foreignData.map((foreign: ForeignInfoV3) => ({
      columns: 12,
      children: [
        {
          label: 'Наименование государства',
          value: foreign.countryName,
          size: 12,
          background: 'white',
        },
        {
          label: 'Наличие права проживания в иностранном государстве',
          value: foreign.residence,
          size: 6,
          background: 'white',
        },
        {
          label:
            'Дата возникновения права на постоянное проживание на территории иностранного государства',
          icon: 'pgs-calendar',
          value: formatDate(foreign.reasonDate ?? ''),
          size: 6,
          background: 'white',
        },
        {
          label: 'Основание проживания в иностранном государстве (при Иных)',
          value: this.getForeignType(foreign.reasonResidence ?? ''),
          size: 8,
          background: 'white',
        },
        {
          label: 'Дата получения гражданства',
          icon: 'pgs-calendar',
          value: formatDate(foreign.residenceDate ?? ''),
          size: 4,
          background: 'white',
        },
      ],
    }));
    return {
      bolder,
      noPadding: true,
      // label: 'Иностранное гражданство',
      children,
    };
  }

  get criminalSection(): FormDataSectionProps {
    const bolder = true;
    const criminalInfo = get(this.recruitData, 'details.criminalCaseInfo', []);

    const children = criminalInfo.map((criminalInfo: CriminalCaseInfo) => ({
      columns: 12,
      noPadding: true,
      children: [
        {
          label: 'Наименование места отбывания наказания',
          value: criminalInfo?.prisonName || '',
          size: 12,
          background: 'white',
        },
        {
          label: 'Адрес места отбывания наказания',
          value: criminalInfo?.prisonAddress || '',
          size: 6,
          background: 'white',
        },
        {
          label: 'Дата начала отбывания наказания',
          icon: 'pgs-calendar',
          value: formatDate(criminalInfo?.startDate || ''),
          size: 6,
          background: 'white',
        },
        {
          label: 'Дата окончания отбывания наказания',
          icon: 'pgs-calendar',
          value: formatDate(criminalInfo?.endDate || ''),
          size: 4,
          background: 'white',
        },
      ],
    }));
    return {
      bolder,
      label: 'Уголовное преследование',
      children,
    };
  }
}
</script>
