import { DocumentsType, IUserPhotoDoc } from '@/modules/documents';
import { valueof } from '@/UI-kit/types';

export interface IAdditionalFields {
    region_id?: number | string;
}

export interface IApiRequest {
    type: valueof<typeof DocumentsType>;
    value: {
        number: string;
    };
    addition_fields?: undefined | unknown | IAdditionalFields;
}

export enum IPassportType {
    NATIONAL = 'national',
    FOREIGN_PASSPORT = 'foreign_passport',
    FOREIGN_BIOMETRIC_PASSPORT = 'foreign_biometric_passport',
}

export interface IPassportValue {
    seria: string;
    number: string;
    document_type: IPassportType;
    issue_date: string;
    last_name: string;
    first_name: string;
    middle_name?: string | null;
    birth_date: string;
    sex: 'мужской' | 'женский';
    citizenship: string;
    issued_country: string;
    region_id: number | string;
}

export interface IApiRequestPassport extends IApiRequest {
    value: IPassportValue;
}

export interface IPatentValue {
    seria: string;
    number: string;
    blank_seria: string;
    blank_number: string;
    issue_date: string;
    paid_until: string;
}

export interface IApiRequestPatent extends IApiRequest {
    value: IPatentValue;
}

export interface IFsspValue {
    seria: string;
    number: string;
    document_type: IPassportType;
    issue_date: string;
    last_name: string;
    first_name: string;
    middle_name?: string | null;
    birth_date: string;
    citizenship: string;
    residence_region: string;
    sex: 'мужской' | 'женский';
    issued_country: string;
}

export interface IApiRequestFssp extends IApiRequest {
    value: IFsspValue;
}

export type TAvailableDoc = IApiRequest | IApiRequestPatent | IApiRequestPassport | IApiRequestFssp;

export interface IPatentForm {
    document: string;
    blank: string;
    issue_date: string;
    paid_until: string;
}

export interface IApiResponse {
    id: number;
    user_id: number;
    type: valueof<typeof DocumentsType>;
    value: TAvailableDoc;
    photos: IUserPhotoDoc[];
    addition_fields: unknown | IAdditionalFields;
    created_at: string | null;
    updated_at: string | null;
    deleted_at: string | null;
}
