forked from Yara724/api
114 lines
2.7 KiB
TypeScript
114 lines
2.7 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
|
import { Type } from "class-transformer";
|
|
import {
|
|
IsArray,
|
|
IsEnum,
|
|
IsInt,
|
|
IsNotEmpty,
|
|
IsOptional,
|
|
IsString,
|
|
MaxLength,
|
|
MinLength,
|
|
Validate,
|
|
ValidateNested,
|
|
} from "class-validator";
|
|
import { HasObjectionEntriesConstraint } from "src/common/validators/has-objection-entries.validator";
|
|
import { IsRepairLineAmountToman } from "src/common/validators/repair-line-amount-toman.validator";
|
|
import { ObjectionPartHasContentConstraint } from "src/common/validators/objection-part-content.validator";
|
|
import { TypeOfDamage } from "src/Types&Enums/claim-request-management/type-of-damage.enum";
|
|
|
|
export class UserObjectionPartDto {
|
|
@ApiProperty({
|
|
example: 201,
|
|
description: "Numeric catalog part id of the priced line being disputed.",
|
|
})
|
|
@Validate(ObjectionPartHasContentConstraint)
|
|
@IsInt()
|
|
partId: number;
|
|
|
|
@ApiPropertyOptional({
|
|
description:
|
|
"Why the owner disagrees (min 3 chars when provided). Required unless partPrice or partSalary is sent.",
|
|
})
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(2000)
|
|
reason?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
description: "Owner-proposed part price (Toman, integer string).",
|
|
})
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(32)
|
|
@IsRepairLineAmountToman()
|
|
partPrice?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
description: "Owner-proposed salary / labor (Toman, integer string).",
|
|
})
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(32)
|
|
@IsRepairLineAmountToman()
|
|
partSalary?: string;
|
|
|
|
@ApiPropertyOptional({ enum: TypeOfDamage })
|
|
@IsOptional()
|
|
@IsEnum(TypeOfDamage)
|
|
typeOfDamage?: TypeOfDamage;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(500)
|
|
carPartDamage?: string;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(64)
|
|
side?: string;
|
|
}
|
|
|
|
export class NewPartDto {
|
|
@ApiPropertyOptional({
|
|
nullable: true,
|
|
description: "Optional catalog id when the new part exists in the outer catalog.",
|
|
})
|
|
@IsOptional()
|
|
@IsInt()
|
|
partId?: number | null;
|
|
|
|
@ApiProperty({ example: "سپر جلو" })
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
@MinLength(1)
|
|
@MaxLength(200)
|
|
partName: string;
|
|
|
|
@ApiPropertyOptional({ example: "front" })
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(64)
|
|
side?: string;
|
|
}
|
|
|
|
export class UserObjectionDto {
|
|
@ApiPropertyOptional({ type: [UserObjectionPartDto] })
|
|
@Validate(HasObjectionEntriesConstraint)
|
|
@IsOptional()
|
|
@IsArray()
|
|
@ValidateNested({ each: true })
|
|
@Type(() => UserObjectionPartDto)
|
|
objectionParts?: UserObjectionPartDto[];
|
|
|
|
@ApiPropertyOptional({ type: [NewPartDto] })
|
|
@Validate(HasObjectionEntriesConstraint)
|
|
@IsOptional()
|
|
@IsArray()
|
|
@ValidateNested({ each: true })
|
|
@Type(() => NewPartDto)
|
|
newParts?: NewPartDto[];
|
|
}
|