import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger"; import { IsArray, IsEnum, IsNotEmpty, ArrayMinSize, ArrayUnique, IsOptional, IsInt, } from "class-validator"; import { ClaimVehicleTypeV2 } from "src/static/outer-car-parts-catalog"; import { DamageSelectedPartV2BodyDto } from "./damage-selected-part-v2.dto"; /** * V2 DTO for selecting damaged outer car parts. * Submit `selectedPartIds` with IDs from the `GET outer-parts-catalog` response. */ export class SelectOuterPartsV2Dto { @ApiPropertyOptional({ description: "Selected outer part IDs from the Fanavaran car-components catalog. " + "IDs must match values returned by GET outer-parts-catalog.", example: [9, 10, 30], type: [Number], }) @IsOptional() @IsArray({ message: "selectedPartIds must be an array" }) @ArrayMinSize(1, { message: "At least one part ID must be selected" }) @ArrayUnique({ message: "Duplicate part IDs are not allowed" }) @IsInt({ each: true, message: "Each selected part ID must be an integer" }) selectedPartIds?: number[]; @ApiPropertyOptional({ description: "Vehicle type (sedan, suv, hatchback, pickup, van). Optional — stored for context only; " + "all vehicle types share the same Fanavaran parts catalog.", enum: ClaimVehicleTypeV2, }) @IsOptional() @IsEnum(ClaimVehicleTypeV2) carType?: ClaimVehicleTypeV2; } /** * Response DTO for select outer parts V2 */ export class SelectOuterPartsV2ResponseDto { @ApiProperty({ description: "Claim request ID", example: "507f1f77bcf86cd799439011", }) claimRequestId: string; @ApiProperty({ description: "Public ID shared across blame and claim", example: "A14235", }) publicId: string; @ApiProperty({ description: "Ordered selected parts: id, side-agnostic name, side, label_fa (and optional catalogKey)", type: [DamageSelectedPartV2BodyDto], }) selectedParts: DamageSelectedPartV2BodyDto[]; @ApiProperty({ description: "Selected part IDs", example: [9, 7, 11], type: [Number], }) selectedPartIds: number[]; @ApiProperty({ description: "Current workflow step", example: "SELECT_OUTER_PARTS", }) currentStep: string; @ApiProperty({ description: "Next possible workflow step", example: "SELECT_OTHER_PARTS", }) nextStep: string; @ApiProperty({ description: "Success message", example: "Outer parts selected successfully. Please proceed to select other parts.", }) message: string; @ApiPropertyOptional({ description: "Best-effort Fanavaran damage-case submit result. Selecting parts still succeeds when this contains a warning.", }) fanavaranDamageCase?: unknown; } export class SetClaimVehicleTypeV2Dto { @ApiProperty({ description: "Vehicle type selected by user", enum: ClaimVehicleTypeV2, }) @IsNotEmpty() @IsEnum(ClaimVehicleTypeV2) carType: ClaimVehicleTypeV2; } /** * Shape returned by `GET .../outer-parts-catalog`. * Sourced live from the Fanavaran `car/base-info/car-components` lookup so that * the list always matches what Fanavaran accepts in `DmgSections[].DmgSectionId`. */ export class OuterPartCatalogItemDto { @ApiProperty({ description: "Fanavaran DmgSectionId — use this value when submitting selectedPartIds", example: 30, }) id: number; @ApiProperty({ description: "Display label in Farsi (Caption from Fanavaran)", example: "درب جلو سمت راننده", }) label_fa: string; }