forked from Yara724/api
Initial commit after migration to gitea
This commit is contained in:
211
src/request-management/dto/create-request-management.dto.ts
Normal file
211
src/request-management/dto/create-request-management.dto.ts
Normal file
@@ -0,0 +1,211 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
||||
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";
|
||||
|
||||
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()
|
||||
desc: string;
|
||||
|
||||
// CAR_BODY specific fields
|
||||
@ApiPropertyOptional({
|
||||
description: "Date of accident (for CAR_BODY type only)",
|
||||
example: "2025-12-08"
|
||||
})
|
||||
accidentDate?: Date;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: "Time of accident (for CAR_BODY type only)",
|
||||
example: "14:30"
|
||||
})
|
||||
accidentTime?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
enum: WeatherCondition,
|
||||
description: "Weather condition at time of accident (for CAR_BODY type only)",
|
||||
example: WeatherCondition.CLEAR
|
||||
})
|
||||
weatherCondition?: WeatherCondition;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
enum: RoadCondition,
|
||||
description: "Road condition at time of accident (for CAR_BODY type only)",
|
||||
example: RoadCondition.DRY
|
||||
})
|
||||
roadCondition?: RoadCondition;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
enum: LightCondition,
|
||||
description: "Light condition at time of accident (for CAR_BODY type only)",
|
||||
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";
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
26
src/request-management/dto/expert-accident-fields.dto.ts
Normal file
26
src/request-management/dto/expert-accident-fields.dto.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { ApiProperty } from "@nestjs/swagger";
|
||||
import { AccidentWayIF, AccidentReasonIF } from "src/expert-blame/dto/reply.dto";
|
||||
|
||||
/**
|
||||
* DTO for expert to add accident fields to an expert-initiated file
|
||||
*/
|
||||
export class ExpertAccidentFieldsDto {
|
||||
@ApiProperty({
|
||||
type: AccidentWayIF,
|
||||
description: "Accident way information (id and label)",
|
||||
})
|
||||
accidentWay: AccidentWayIF;
|
||||
|
||||
@ApiProperty({
|
||||
type: AccidentReasonIF,
|
||||
description: "Accident reason information (id, label, and fanavaran)",
|
||||
})
|
||||
accidentReason: AccidentReasonIF;
|
||||
|
||||
@ApiProperty({
|
||||
type: AccidentWayIF,
|
||||
description: "Accident type information (id and label)",
|
||||
})
|
||||
accidentType: AccidentWayIF;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { ApiProperty } from "@nestjs/swagger";
|
||||
import { AddPlateDto } from "src/profile/dto/user/AddPlateDto";
|
||||
import { LocationDto } from "./create-request-management.dto";
|
||||
import { DescriptionDto } from "./create-request-management.dto";
|
||||
import { InitialFormDto, CarBodyFormDto } from "./create-request-management.dto";
|
||||
|
||||
/**
|
||||
* Comprehensive form for experts to fill all information at once for IN_PERSON CAR_BODY files
|
||||
*/
|
||||
export class ExpertCompleteCarBodyFormDto {
|
||||
// First Party Information
|
||||
@ApiProperty({
|
||||
description: "First party phone number",
|
||||
example: "09123456789",
|
||||
})
|
||||
firstPartyPhoneNumber: string;
|
||||
|
||||
@ApiProperty({ type: InitialFormDto })
|
||||
firstPartyInitialForm: InitialFormDto;
|
||||
|
||||
@ApiProperty({ type: CarBodyFormDto })
|
||||
carBodyForm: CarBodyFormDto;
|
||||
|
||||
@ApiProperty({ type: AddPlateDto })
|
||||
firstPartyPlate: AddPlateDto;
|
||||
|
||||
@ApiProperty({ type: LocationDto })
|
||||
firstPartyLocation: LocationDto;
|
||||
|
||||
@ApiProperty({ type: DescriptionDto })
|
||||
firstPartyDescription: DescriptionDto;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import { ApiProperty } from "@nestjs/swagger";
|
||||
import { AddPlateDto } from "src/profile/dto/user/AddPlateDto";
|
||||
import { LocationDto } from "./create-request-management.dto";
|
||||
import { DescriptionDto } from "./create-request-management.dto";
|
||||
import { InitialFormDto } from "./create-request-management.dto";
|
||||
|
||||
/**
|
||||
* Second party information for expert-completed THIRD_PARTY forms
|
||||
*/
|
||||
export class ExpertSecondPartyInfoDto {
|
||||
@ApiProperty({
|
||||
description: "Second party phone number",
|
||||
example: "09123456789",
|
||||
})
|
||||
phoneNumber: string;
|
||||
|
||||
@ApiProperty({ type: InitialFormDto })
|
||||
initialForm: InitialFormDto;
|
||||
|
||||
@ApiProperty({ type: AddPlateDto })
|
||||
plate: AddPlateDto;
|
||||
|
||||
@ApiProperty({ type: LocationDto })
|
||||
location: LocationDto;
|
||||
|
||||
@ApiProperty({ type: DescriptionDto })
|
||||
description: DescriptionDto;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprehensive form for experts to fill all information at once for IN_PERSON THIRD_PARTY files
|
||||
*/
|
||||
export class ExpertCompleteThirdPartyFormDto {
|
||||
// First Party Information
|
||||
@ApiProperty({
|
||||
description: "First party phone number",
|
||||
example: "09123456789",
|
||||
})
|
||||
firstPartyPhoneNumber: string;
|
||||
|
||||
@ApiProperty({ type: InitialFormDto })
|
||||
firstPartyInitialForm: InitialFormDto;
|
||||
|
||||
@ApiProperty({ type: AddPlateDto })
|
||||
firstPartyPlate: AddPlateDto;
|
||||
|
||||
@ApiProperty({ type: LocationDto })
|
||||
firstPartyLocation: LocationDto;
|
||||
|
||||
@ApiProperty({ type: DescriptionDto })
|
||||
firstPartyDescription: DescriptionDto;
|
||||
|
||||
// Second Party Information
|
||||
@ApiProperty({ type: ExpertSecondPartyInfoDto })
|
||||
secondParty: ExpertSecondPartyInfoDto;
|
||||
|
||||
// Guilty Party
|
||||
@ApiProperty({
|
||||
description: "Phone number of the guilty party. Must match either first or second party phone number.",
|
||||
example: "09123456789",
|
||||
})
|
||||
guiltyPartyPhoneNumber: string;
|
||||
}
|
||||
|
||||
39
src/request-management/dto/expert-initiated.dto.ts
Normal file
39
src/request-management/dto/expert-initiated.dto.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
||||
import { IsEnum, IsOptional, IsString } from "class-validator";
|
||||
import { CreationMethod } from "../entities/schema/request-management.schema";
|
||||
|
||||
export class CreateExpertInitiatedFileDto {
|
||||
@ApiProperty({
|
||||
description: "Type of blame file",
|
||||
enum: ["THIRD_PARTY", "CAR_BODY"],
|
||||
example: "THIRD_PARTY",
|
||||
})
|
||||
@IsEnum(["THIRD_PARTY", "CAR_BODY"])
|
||||
type: "THIRD_PARTY" | "CAR_BODY";
|
||||
|
||||
@ApiProperty({
|
||||
description: "Method of creation",
|
||||
enum: CreationMethod,
|
||||
example: CreationMethod.IN_PERSON,
|
||||
})
|
||||
@IsEnum(CreationMethod)
|
||||
creationMethod: CreationMethod;
|
||||
|
||||
// Phone numbers for LINK method - users will access files via normal login
|
||||
@ApiPropertyOptional({
|
||||
description: "First party phone number. Required for LINK method.",
|
||||
example: "09123456789",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
firstPartyPhoneNumber?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: "Second party phone number. Required for LINK method when type is THIRD_PARTY.",
|
||||
example: "09187654321",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
secondPartyPhoneNumber?: string;
|
||||
}
|
||||
|
||||
52
src/request-management/dto/user-reply.dto.ts
Normal file
52
src/request-management/dto/user-reply.dto.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { ApiProperty } from "@nestjs/swagger";
|
||||
import { RequestManagementModel } from "../entities/schema/request-management.schema";
|
||||
|
||||
export class UserReplyDto {
|
||||
public _id: string;
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
isAccept: boolean;
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
signId: string;
|
||||
|
||||
constructor(requestId: string) {
|
||||
this._id = requestId;
|
||||
}
|
||||
}
|
||||
|
||||
export class DetailsReplyDtoRs {
|
||||
public fields: Object;
|
||||
public actorFullName: string;
|
||||
public description: string;
|
||||
public dateOfReply: string;
|
||||
public timeOfReply: string;
|
||||
public isGuiltyUser: boolean;
|
||||
public firstPartyAccept: boolean;
|
||||
public secondPartyAccept: boolean;
|
||||
public status: string;
|
||||
public expertResendReply: any;
|
||||
public expertSubmitReply: any;
|
||||
public expertSubmitReplyFinal: any;
|
||||
public theParties: any;
|
||||
public type: string;
|
||||
|
||||
constructor(request: RequestManagementModel, details: any) {
|
||||
const finalReply = request.expertSubmitReply;
|
||||
|
||||
this.fields = finalReply.fields;
|
||||
this.description = finalReply.description;
|
||||
this.firstPartyAccept = finalReply?.firstPartyComment?.isAccept;
|
||||
this.secondPartyAccept = finalReply?.secondPartyComment?.isAccept;
|
||||
this.actorFullName = details.actorDetail.CheckedRequest.fullName;
|
||||
this.dateOfReply = details.actorDetail.Date.toLocaleDateString("fa-IR");
|
||||
this.timeOfReply = details.actorDetail.Date.toLocaleTimeString("fa-IR");
|
||||
this.isGuiltyUser = details.isGuilty;
|
||||
this.status = request.blameStatus;
|
||||
this.expertResendReply = request.expertResendReply;
|
||||
this.expertSubmitReply = request.expertSubmitReply;
|
||||
this.expertSubmitReplyFinal = request.expertSubmitReplyFinal;
|
||||
this.theParties = details.theParties;
|
||||
this.type = request.type || "THIRD_PARTY"; // Include type field
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user