import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { IsArray, IsEnum, IsNotEmpty, IsOptional, IsString, Matches, Length, ArrayMaxSize } from 'class-validator'; /** * Enum for valid other (non-body) car parts that can be damaged */ export enum OtherCarPart { ENGINE = 'engine', SUSPENSION = 'suspension', BRAKE_SYSTEM = 'brake_system', ELECTRICAL = 'electrical', RADIATOR = 'radiator', TRANSMISSION = 'transmission', EXHAUST = 'exhaust', HEADLIGHT = 'headlight', TAILLIGHT = 'taillight', MIRROR = 'mirror', GLASS = 'glass', } /** * V2 DTO for selecting other damaged parts and bank information * Step 3 of claim workflow */ export class SelectOtherPartsV2Dto { @ApiPropertyOptional({ description: 'Array of selected other damaged parts (non-body parts)', example: ['engine', 'suspension', 'headlight'], enum: OtherCarPart, isArray: true, maxItems: 11, required: false, }) @IsOptional() @IsArray({ message: 'otherParts must be an array' }) @ArrayMaxSize(11, { message: 'Maximum 11 other parts can be selected' }) @IsEnum(OtherCarPart, { each: true, message: 'Invalid part name. Must be one of the valid other car parts', }) otherParts?: OtherCarPart[]; @ApiProperty({ description: 'Sheba number (IBAN) for payment - 24 digits without IR prefix', example: '123456789012345678901234', pattern: '^[0-9]{24}$', minLength: 24, maxLength: 24, }) @IsNotEmpty({ message: 'Sheba number is required' }) @IsString({ message: 'Sheba number must be a string' }) @Length(24, 24, { message: 'Sheba number must be exactly 24 digits' }) @Matches(/^[0-9]{24}$/, { message: 'Sheba number must contain exactly 24 digits (without IR prefix)', }) shebaNumber: string; @ApiProperty({ description: 'National code of the owner - 10 digits', example: '1234567890', pattern: '^[0-9]{10}$', minLength: 10, maxLength: 10, }) @IsNotEmpty({ message: 'National code of owner is required' }) @IsString({ message: 'National code must be a string' }) @Length(10, 10, { message: 'National code must be exactly 10 digits' }) @Matches(/^[0-9]{10}$/, { message: 'National code must contain exactly 10 digits', }) nationalCodeOfOwner: string; } /** * Response DTO for select other parts V2 */ export class SelectOtherPartsV2ResponseDto { @ApiProperty({ description: 'Claim request ID', example: '507f1f77bcf86cd799439011', }) claimRequestId: string; @ApiProperty({ description: 'Public ID shared across blame and claim', example: 'A14235', }) publicId: string; @ApiProperty({ description: 'Array of selected other damaged parts', example: ['engine', 'suspension'], required: false, }) otherParts?: string[]; @ApiProperty({ description: 'Sheba number (masked for security)', example: 'IR12************1234', }) shebaNumber: string; @ApiProperty({ description: 'National code of owner (masked)', example: '12******90', }) nationalCodeOfOwner: string; @ApiProperty({ description: 'Current workflow step', example: 'UPLOAD_REQUIRED_DOCUMENTS', }) currentStep: string; @ApiProperty({ description: 'Next possible workflow step', example: 'CAPTURE_PART_DAMAGES', }) nextStep: string; @ApiProperty({ description: 'Success message', example: 'Other parts and bank information saved successfully. Please proceed to upload required documents.', }) message: string; }