This commit is contained in:
SepehrYahyaee
2026-05-18 10:06:14 +03:30
parent f0ba8949cb
commit 7ff3e9fd10
6 changed files with 113 additions and 58 deletions

View File

@@ -7,59 +7,12 @@ import {
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({
@@ -86,16 +39,15 @@ export class DaghiDetailsV2Dto {
}
export class PartPricingV2Dto {
@ApiProperty({ example: 'part-001' })
@ApiProperty({
example: '12',
description:
'Stable part id from GET claim detail `damagedParts[].partId` or `selectedParts` identity (`id:{catalogId}` or `{side}|{name}`). Required.',
})
@IsString()
@IsNotEmpty()
partId: string;
@ApiProperty({ type: ExpertReplyCarPartDamageV2Dto })
@ValidateNested()
@Type(() => ExpertReplyCarPartDamageV2Dto)
carPartDamage: ExpertReplyCarPartDamageV2Dto;
@ApiProperty({ example: 'Minor' })
@IsString()
typeOfDamage: string;
@@ -135,7 +87,7 @@ export class SubmitExpertReplyV2Dto {
@ApiProperty({
type: [PartPricingV2Dto],
description:
"Each part: manual pricing and `daghi`; set `factorNeeded` only where a repair factor upload is required from the owner.",
"One line per damaged part (`partId` from claim detail `damagedParts[]`), plus pricing, `daghi`, and `factorNeeded`.",
})
@IsArray()
@ValidateNested({ each: true })