import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { IsString, IsNotEmpty, IsArray, IsBoolean, IsOptional, ValidateNested, IsEnum, IsInt, } from 'class-validator'; import { Type } from 'class-transformer'; import { ClaimRequiredDocumentType } from 'src/Types&Enums/claim-request-management/required-document-type.enum'; import { DamagedPartItem } from 'src/claim-request-management/dto/capture-requirements-v2.dto'; import { DaghiOption } from 'src/Types&Enums/claim-request-management/daghi-option.enum'; /** * Damage line part reference — same unified shape as `damage.selectedParts` / catalog rows. * Send either `{ name, side, label_fa?, id?, catalogKey? }` or legacy `{ part, side }` * (e.g. part `backFender`, side `left`); the API persists canonical `{ id, name, side, label_fa, catalogKey? }`. */ export class ExpertReplyCarPartDamageV2Dto { @ApiPropertyOptional({ description: 'Catalog id when known' }) @IsOptional() @IsInt() id?: number; @ApiPropertyOptional({ description: 'Side-agnostic catalog segment, e.g. backfender', example: 'backfender', }) @IsOptional() @IsString() name?: string; @ApiPropertyOptional({ example: 'left' }) @IsOptional() @IsString() side?: string; @ApiPropertyOptional({ description: 'Farsi label; optional when server can resolve from catalog + vehicle.carType', }) @IsOptional() @IsString() label_fa?: string; @ApiPropertyOptional({ example: 'left_backfender' }) @IsOptional() @IsString() catalogKey?: string; @ApiPropertyOptional({ description: 'Legacy expert UI: camelCase segment with `side`, e.g. backFender', example: 'backFender', }) @IsOptional() @IsString() part?: string; } /** Same shape as V1 {@link PartsList} `daghi` (damage expert reply). */ export class DaghiDetailsV2Dto { @ApiProperty({ enum: DaghiOption, description: 'Daghi option: ارزش لوازم بازیافتی, تحویل داغی, فاقد ارزش, با احتساب داغی', }) @IsEnum(DaghiOption) option: DaghiOption; @ApiPropertyOptional({ description: `Required when option is '${DaghiOption.RECYCLED_PARTS_VALUE}'`, }) @IsOptional() @IsString() price?: string; @ApiPropertyOptional({ description: `Required when option is '${DaghiOption.DELIVER_DAMAGED_PART}' (Mongo ObjectId string)`, }) @IsOptional() @IsString() branchId?: string; } export class PartPricingV2Dto { @ApiProperty({ example: 'part-001' }) @IsString() @IsNotEmpty() partId: string; @ApiProperty({ type: ExpertReplyCarPartDamageV2Dto }) @ValidateNested() @Type(() => ExpertReplyCarPartDamageV2Dto) carPartDamage: ExpertReplyCarPartDamageV2Dto; @ApiProperty({ example: 'Minor' }) @IsString() typeOfDamage: string; @ApiProperty({ example: '5000000' }) @IsString() price: string; @ApiProperty({ example: '2000000' }) @IsString() salary: string; @ApiProperty({ example: '7000000' }) @IsString() totalPayment: string; @ApiProperty({ type: DaghiDetailsV2Dto }) @ValidateNested() @Type(() => DaghiDetailsV2Dto) daghi: DaghiDetailsV2Dto; @ApiProperty({ example: false, description: "If true, the owner must upload a repair factor image for this line; expert confirms cost later (validate-factors). Priced lines omit this or set false.", }) @IsBoolean() factorNeeded: boolean; } export class SubmitExpertReplyV2Dto { @ApiProperty({ example: 'Front door and hood have severe paint damage' }) @IsString() @IsNotEmpty() description: string; @ApiProperty({ type: [PartPricingV2Dto], description: "Each part: manual pricing and `daghi`; set `factorNeeded` only where a repair factor upload is required from the owner.", }) @IsArray() @ValidateNested({ each: true }) @Type(() => PartPricingV2Dto) parts: PartPricingV2Dto[]; } export class ClaimSubmitResendV2Dto { @ApiPropertyOptional({ description: "Instructions for the owner. At least one of description, resendDocuments, or resendCarParts must be non-empty.", }) @IsOptional() @IsString() resendDescription?: string; @ApiPropertyOptional({ type: [String], enum: ClaimRequiredDocumentType, description: "Document keys to re-upload; each value must be a ClaimRequiredDocumentType string (e.g. national_card).", }) @IsOptional() @IsArray() @IsEnum(ClaimRequiredDocumentType, { each: true }) resendDocuments?: ClaimRequiredDocumentType[]; @ApiPropertyOptional({ type: [DamagedPartItem] }) @IsOptional() @IsArray() @ValidateNested({ each: true }) @Type(() => DamagedPartItem) resendCarParts?: DamagedPartItem[]; }