import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger"; import { IsNotEmpty, IsOptional, IsString, MaxLength } from "class-validator"; import { Types } from "mongoose"; import { AddPlateDto } from "src/profile/dto/user/AddPlateDto"; import { StepsEnum } from "src/Types&Enums/blame-request-management/steps.enum"; import { WeatherCondition, RoadCondition, LightCondition, } from "src/Types&Enums/blame-request-management/accident-conditions.enum"; import { BlameRequestType } from "src/Types&Enums/blame-request-management/blameRequestType.enum"; import { IsEnum } from "class-validator"; export class InitialFormDto { @ApiProperty({ required: false, default: false }) expertOpinion?: boolean; @ApiProperty({ required: false, default: false }) imDamaged?: boolean; @ApiProperty({ required: true, default: false }) imGuilty?: boolean; } export class CarBodyFormDto { @ApiProperty({ required: false, default: false }) car?: boolean; @ApiProperty({ required: false, default: false }) object?: boolean; } export class CarBodySecondForm { @ApiProperty({ required: false, default: false }) imDamaged?: boolean; @ApiProperty({ required: true, default: false }) imGuilty?: boolean; } export class FirstPartyFileDto { @ApiProperty() descriptions?: string; @ApiProperty() voices?: string; @ApiPropertyOptional({ type: String }) firstPartyVideoId?: string; } export class DescriptionDto { @ApiProperty({ description: "Accident description (required for all types)" }) desc: string; @ApiPropertyOptional({ description: "CAR_BODY only. Ignored for THIRD_PARTY.", example: "2025-12-08", }) accidentDate?: Date; @ApiPropertyOptional({ description: "CAR_BODY only. Ignored for THIRD_PARTY.", example: "14:30", }) accidentTime?: string; @ApiPropertyOptional({ enum: WeatherCondition, description: "CAR_BODY only. Ignored for THIRD_PARTY.", example: WeatherCondition.CLEAR, }) weatherCondition?: WeatherCondition; @ApiPropertyOptional({ enum: RoadCondition, description: "CAR_BODY only. Ignored for THIRD_PARTY.", example: RoadCondition.DRY, }) roadCondition?: RoadCondition; @ApiPropertyOptional({ enum: LightCondition, description: "CAR_BODY only. Ignored for THIRD_PARTY.", example: LightCondition.DAYLIGHT, }) lightCondition?: LightCondition; } /** * V4 FileMaker description step (THIRD_PARTY and CAR_BODY alike). * Accident date and time are required for all file types in V4 so the * front-end can display them consistently regardless of blame type. */ export class DescriptionV4Dto { @ApiProperty({ description: "Accident description" }) @IsString() @IsNotEmpty() desc: string; @ApiPropertyOptional({ description: "Date of the accident. Required for the first (guilty) party; " + "optional for the second (damaged) party.", example: "2025-12-08", }) @IsOptional() accidentDate?: Date; @ApiPropertyOptional({ description: "Time of the accident. Required for the first (guilty) party; " + "optional for the second (damaged) party.", example: "14:30", }) @IsOptional() @IsString() accidentTime?: string; } /** * THIRD_PARTY description step: only desc is accepted. */ export class ThirdPartyDescriptionDto { @ApiProperty({ description: "Accident description" }) desc: string; } /** * CAR_BODY description step: desc + accident date/time and conditions required. */ export class CarBodyDescriptionDto { @ApiProperty({ description: "Accident description" }) desc: string; @ApiProperty({ description: "Date of accident", example: "2025-12-08" }) accidentDate: Date; @ApiProperty({ description: "Time of accident", example: "14:30" }) accidentTime: string; @ApiProperty({ enum: WeatherCondition, example: WeatherCondition.CLEAR }) weatherCondition: WeatherCondition; @ApiProperty({ enum: RoadCondition, example: RoadCondition.DRY }) roadCondition: RoadCondition; @ApiProperty({ enum: LightCondition, example: LightCondition.DAYLIGHT }) lightCondition: LightCondition; } export class FirstPartyDetail { // @ApiProperty({ type: String }) firstPartyId?: Types.ObjectId; // @ApiProperty({ type: String }) firstPartyPhoneNumber?: string; // @ApiProperty({ type: String }) firstPartyClientId?: string; @ApiProperty({ type: AddPlateDto, description: "first add plate and send plate id to this field", }) firstPartyPlate?: AddPlateDto; @ApiProperty() firstPartyFile?: FirstPartyFileDto; } export class SecondPartyDetail { @ApiProperty({ type: String }) secondPartyId?: Types.ObjectId; @ApiProperty({ type: String }) secondPartyPhoneNumber?: string; @ApiProperty({ type: String }) secondPartyClientId?: string; @ApiProperty({ type: String, description: "first add plate and send plate id to this field", }) secondPartyPlateId?: Types.ObjectId; @ApiProperty({ type: String }) secondPartyVideoId?: string; } export class LocationDto { @ApiProperty({ type: Number, required: true }) lat: number; @ApiProperty({ type: Number, required: true }) lon: number; } // export class CreateRequestDto { // @ApiProperty({ type: String, required: false }) // type?: "THIRD_PARTY" | "CAR_BODY"; // } /** * V2 create blame request (new model `BlameRequest`). */ export class CreateBlameRequestDtoV2 { @IsEnum(BlameRequestType) @ApiProperty({ enum: BlameRequestType, description: "Type of blame request" }) type: BlameRequestType; } /** * V2 step: FIRST_BLAME_CONFESSION */ export class BlameConfessionDtoV2 { @ApiProperty({ required: false, default: false }) expertOpinion?: boolean; @ApiProperty({ required: false, default: false }) imDamaged?: boolean; @ApiProperty({ required: true, default: false }) imGuilty?: boolean; } /** * V2 initial-form step submitted with a VIN/chassis number instead of a plate. * All identity and license fields from {@link AddPlateDto} are preserved; only * `plate` is replaced by `vin` (the 17-character chassis / VIN string). */ export class InitialFormVinDto { @ApiProperty({ type: String, required: true, description: "17-character VIN / chassis number (شماره شاسی)", example: "NAAM01E15HK123456", maxLength: 17, }) @IsString() @IsNotEmpty() @MaxLength(17) vin: string; @ApiProperty({ type: String, required: true }) nationalCodeOfInsurer: string; @ApiProperty({ type: String, required: true }) nationalCodeOfDriver: string; @ApiProperty({ type: String, required: true }) insurerLicense: string; @ApiProperty({ type: String, required: true }) driverLicense: string; @ApiProperty({ type: Boolean, required: true }) driverIsInsurer: boolean; @ApiProperty({ type: Boolean, required: true, default: false }) isNewCar: boolean; @ApiProperty({ type: Boolean, required: true }) userNoCertificate: boolean; @ApiProperty({ type: Number, required: true }) insurerBirthday: number; @ApiPropertyOptional({ type: String, required: false }) driverBirthday: string | null; } // export class DocsOfThisFile { // @ApiProperty() // firstPartyFile?: FirstPartyFileDto; // } export class CreateRequestManagementDto { @ApiPropertyOptional({ required: false, description: "first step" }) initialForm?: InitialFormDto; @ApiPropertyOptional({ required: false, description: "first step" }) firstPartyDetails?: FirstPartyDetail; // @ApiPropertyOptional({ required: false, description: "second step call" }) // docsOFirstParty?: DocsOfThisFile; @ApiPropertyOptional({ required: false }) secondPartyDetails?: SecondPartyDetail; @ApiPropertyOptional({ required: false, description: "third step call" }) locationForm?: LocationDto; @ApiProperty({ type: "string", format: "binary", required: false }) firstPartyVideoId: Express.Multer.File; } // type: "object", // properties: { // file: { // type: "string", // format: "binary", // }, // }, export class CreateRequestManagementInitialFormStep { step?: StepsEnum; userId?: Types.ObjectId; nextStep?: StepsEnum; message?: string; requestId?: Types.ObjectId; @ApiPropertyOptional({ required: false, description: "first step" }) initialForm?: InitialFormDto; constructor(userId, reqId, step, nextStep, message?) { this.requestId = reqId; this.userId = userId; this.step = step; this.nextStep = nextStep; this.message = message; } } export class RequestManagementDtoRs { step?: StepsEnum; firstPartyUserId?: Types.ObjectId; secondPartyUserId?: Types.ObjectId | null; nextStep?: StepsEnum; message?: string; requestId?: Types.ObjectId; claimFile?: Types.ObjectId | null; constructor( firstPartyUser, secondPartyUserId, step, nextStep, message?, requestId?, claimFile = null, ) { this.requestId = requestId; this.firstPartyUserId = firstPartyUser; this.secondPartyUserId = secondPartyUserId; this.step = step; this.nextStep = nextStep; this.message = message; this.claimFile = claimFile; } }