forked from Yara724/api
136 lines
3.5 KiB
TypeScript
136 lines
3.5 KiB
TypeScript
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). Accepted: IR + 24 digits OR only 24 digits',
|
|
example: 'IR123456789012345678901234',
|
|
})
|
|
@IsNotEmpty({ message: 'sheba is required' })
|
|
@IsString({ message: 'sheba must be a string' })
|
|
sheba: string;
|
|
|
|
@ApiPropertyOptional({
|
|
description: 'Legacy alias of sheba for backward compatibility',
|
|
example: '123456789012345678901234',
|
|
})
|
|
@IsOptional()
|
|
@IsString()
|
|
shebaNumber?: string;
|
|
|
|
@ApiProperty({
|
|
description: 'National code of insurer/owner - 10 digits',
|
|
example: '1234567890',
|
|
pattern: '^[0-9]{10}$',
|
|
minLength: 10,
|
|
maxLength: 10,
|
|
})
|
|
@IsNotEmpty({ message: 'nationalCodeOfInsurer 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',
|
|
})
|
|
nationalCodeOfInsurer: string;
|
|
|
|
@ApiPropertyOptional({
|
|
description: 'Legacy alias for backward compatibility',
|
|
example: '1234567890',
|
|
})
|
|
@IsOptional()
|
|
@IsString()
|
|
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;
|
|
}
|