import { IsEmail, IsNotEmpty, IsString, MinLength, IsOptional, IsDateString, IsIn, IsArray, ArrayMaxSize, ValidateNested, IsBoolean } from 'class-validator';
import { Type } from 'class-transformer';
import { CustomDocumentDto } from '../../common/dto/custom-document.dto';
import { CustomImageDto } from '../../common/dto/custom-image.dto';
import { EducationEntryDto } from '../../common/dto/education-entry.dto';

export class CreateTeacherDto {
    // === Personal Details ===
    @IsNotEmpty()
    @IsString()
    name: string;

    @IsNotEmpty()
    @IsDateString()
    dateOfBirth: string;

    @IsNotEmpty()
    @IsDateString()
    joinDate: string;

    @IsNotEmpty()
    @IsString()
    mobileNumber: string;

    @IsOptional()
    @IsString()
    phone?: string;

    @IsOptional()
    @IsString()
    fatherName?: string;

    @IsOptional()
    @IsString()
    motherName?: string;

    @IsOptional()
    @IsEmail()
    email?: string;

    @IsOptional()
    @IsString()
    adhaarNumber?: string;

    @IsOptional()
    @IsString()
    panNumber?: string;

    @IsOptional()
    @IsString()
    subject?: string;

    @IsNotEmpty()
    @IsString()
    address: string;

    @IsNotEmpty()
    @IsString()
    highestQualification: string;

    @IsOptional()
    @IsString()
    photoUrl?: string;

    @IsOptional()
    @IsString()
    signature?: string;

    @IsOptional()
    @IsString()
    @MinLength(8)
    password?: string;

    @IsOptional()
    @IsBoolean()
    isActive?: boolean;

    @IsOptional()
    @IsString()
    designation?: string;

    // === Custom Documents and Images ===
    @IsOptional()
    @IsArray()
    @ArrayMaxSize(50)
    @ValidateNested({ each: true })
    @Type(() => CustomDocumentDto)
    customDocuments?: CustomDocumentDto[];

    @IsOptional()
    @IsArray()
    @ArrayMaxSize(50)
    @ValidateNested({ each: true })
    @Type(() => CustomImageDto)
    customImages?: CustomImageDto[];

    // === Education (converted to array for multiple entries) ===
    @IsOptional()
    @IsArray()
    @ArrayMaxSize(20)
    @ValidateNested({ each: true })
    @Type(() => EducationEntryDto)
    education?: EducationEntryDto[];

    // === Bank Details ===
    @IsOptional()
    @IsString()
    bankName?: string;

    @IsOptional()
    @IsString()
    accountNumber?: string;

    @IsOptional()
    @IsIn(['Savings', 'Current', 'Salary'])
    accountType?: string;

    @IsOptional()
    @IsString()
    ifscNumber?: string;

    // === PF Information ===
    @IsOptional()
    @IsString()
    pfMemberId?: string;

    @IsOptional()
    @IsString()
    pfAccountNumber?: string;

    @IsOptional()
    @IsString()
    employeeName?: string;

    @IsOptional()
    @IsIn(['Pending', 'Verified', 'Rejected'])
    kycStatus?: string;

    // === Leaving Details ===
    @IsOptional()
    @IsDateString()
    schoolLeavingDate?: string;

    @IsOptional()
    @IsString()
    leavingReason?: string;
}
