import { EInputComponentType, EInputType } from '@/UI-kit/types';
import { getPassportValidator } from '@/modules/documents/constants';
import { IDocsSchemaType } from '@/modules/form/types';
import { IPassportFieldsOptions } from '@/modules/documents/type';
import { uiKitI18n } from '@/configs';
import { COUNTRY_TYPE, SEX_TYPE_RU } from '@/modules/documents/constants/directory';

export function usePassportFieldsScheme(options?: IPassportFieldsOptions): IDocsSchemaType[] {
    const {
        lastName,
        firstName,
        middleName,
        birthDate,
        gender,
        passportNumber,
        passportSeries,
        citizenship,
        issueDate,
        regionId,
    } = getPassportValidator();

    return [
        {
            name: 'last_name',
            label: uiKitI18n?.global.t('moduleDocuments.forms.nonresident_passport.lastName.label'),
            type: EInputType.text,
            placeholder: uiKitI18n?.global.t(
                'moduleDocuments.forms.nonresident_passport.lastName.placeholder',
            ),
            validateOnChange: false,
            validator: lastName,
            isShowClear: true,
            isCapitalize: true,
        },
        {
            name: 'first_name',
            label: uiKitI18n?.global.t(
                'moduleDocuments.forms.nonresident_passport.firstName.label',
            ),
            type: EInputType.text,
            placeholder: uiKitI18n?.global.t(
                'moduleDocuments.forms.nonresident_passport.firstName.placeholder',
            ),
            validateOnChange: false,
            validator: firstName,
            isShowClear: true,
            isCapitalize: true,
        },
        {
            name: 'middle_name',
            label: uiKitI18n?.global.t(
                'moduleDocuments.forms.nonresident_passport.middleName.label',
            ),
            type: EInputType.text,
            placeholder: uiKitI18n?.global.t(
                'moduleDocuments.forms.nonresident_passport.middleName.placeholder',
            ),
            validateOnChange: false,
            validator: middleName,
            isShowClear: true,
            isCapitalize: true,
        },
        {
            name: 'birth_date',
            label: uiKitI18n?.global.t(
                'moduleDocuments.forms.nonresident_passport.birthDate.label',
            ),
            type: EInputType.text,
            placeholder: uiKitI18n?.global.t(
                'moduleDocuments.forms.nonresident_passport.birthDate.placeholder',
            ),
            validateOnChange: false,
            masked: true,
            isDate: true,
            validator: birthDate,
            mask: '##.##.####',
            components: EInputComponentType.mask,
            isShowClear: true,
        },
        {
            name: 'seria',
            label: uiKitI18n?.global.t(
                'moduleDocuments.forms.nonresident_passport.passportSeries.label',
            ),
            type: EInputType.text,
            placeholder: 'FA',
            validateOnChange: false,
            validator: passportSeries,
            mask: 'SSSSSSSSSSSSSSSSSSSSSSSSS',
            components: EInputComponentType.mask,
            isShowClear: true,
        },
        {
            name: 'number',
            label: uiKitI18n?.global.t(
                'moduleDocuments.forms.nonresident_passport.passportNumber.label',
            ),
            type: EInputType.text,
            placeholder: '0000000',
            validateOnChange: false,
            validator: passportNumber,
            mask: 'SSSSSSSSSSSSSSSSSSSSSSSSS',
            components: EInputComponentType.mask,
            isShowClear: true,
        },
        {
            name: 'issue_date',
            label: uiKitI18n?.global.t(
                'moduleDocuments.forms.nonresident_passport.issue_date.label',
            ),
            type: EInputType.text,
            placeholder: uiKitI18n?.global.t(
                'moduleDocuments.forms.nonresident_passport.issue_date.placeholder',
            ),
            validateOnChange: false,
            validator: issueDate,
            mask: '##.##.####',
            isDate: true,
            masked: true,
            components: EInputComponentType.mask,
            isShowClear: true,
        },
        {
            name: 'citizenship',
            label: uiKitI18n?.global.t(
                'moduleDocuments.forms.nonresident_passport.citizenship.label',
            ),
            type: EInputType.select,
            placeholder: uiKitI18n?.global.t(
                'moduleDocuments.forms.nonresident_passport.citizenship.placeholder',
            ),
            validateOnChange: false,
            validator: citizenship,
            select: {
                showSearchInput: true,
                placeholderSearchInput: uiKitI18n?.global.t(
                    'moduleDocuments.forms.nonresident_passport.citizenship.placeholderSearchInput',
                ),
                options: options?.citizenshipOptions || COUNTRY_TYPE,
            },
        },
        {
            name: 'region_id',
            label: uiKitI18n?.global.t(
                'moduleDocuments.forms.nonresident_passport.region_id.label',
            ),
            type: EInputType.select,
            placeholder: uiKitI18n?.global.t(
                'moduleDocuments.forms.nonresident_passport.region_id.placeholder',
            ),
            validateOnChange: false,
            validator: regionId,
            select: {
                showSearchInput: true,
                placeholderSearchInput: uiKitI18n?.global.t(
                    'moduleDocuments.forms.nonresident_passport.region_id.placeholderSearchInput',
                ),
                options: options?.regionOptions || COUNTRY_TYPE,
            },
        },
        {
            name: 'sex',
            label: uiKitI18n?.global.t('moduleDocuments.forms.nonresident_passport.gender.label'),
            type: EInputType.radio,
            validateOnChange: false,
            validator: gender,
            radioButtonData: [
                {
                    value: SEX_TYPE_RU[0].value,
                    label: uiKitI18n?.global.t(
                        'moduleDocuments.forms.nonresident_passport.gender.options.male',
                    ),
                },
                {
                    value: SEX_TYPE_RU[1].value,
                    label: uiKitI18n?.global.t(
                        'moduleDocuments.forms.nonresident_passport.gender.options.female',
                    ),
                },
            ],
        },
    ];
}
