From 5487ba28ca625d29bba3ed2aaa5940ada9823734 Mon Sep 17 00:00:00 2001 From: unakb Date: Wed, 18 Sep 2024 15:50:14 +0000 Subject: [PATCH] remove everything but caseid from create civil claimant --- .../dto/createCivilClaimant.input.ts | 52 +----------------- .../src/app/modules/case/case.service.ts | 1 + .../defendant/civilClaimant.controller.ts | 4 +- .../defendant/civilClaimant.service.ts | 7 +-- .../defendant/dto/createCivilClaimant.dto.ts | 55 ------------------- 5 files changed, 4 insertions(+), 115 deletions(-) delete mode 100644 apps/judicial-system/backend/src/app/modules/defendant/dto/createCivilClaimant.dto.ts diff --git a/apps/judicial-system/api/src/app/modules/defendant/dto/createCivilClaimant.input.ts b/apps/judicial-system/api/src/app/modules/defendant/dto/createCivilClaimant.input.ts index 8ae8624956c6..84d5c2ff7077 100644 --- a/apps/judicial-system/api/src/app/modules/defendant/dto/createCivilClaimant.input.ts +++ b/apps/judicial-system/api/src/app/modules/defendant/dto/createCivilClaimant.input.ts @@ -1,4 +1,4 @@ -import { Allow, IsOptional } from 'class-validator' +import { Allow } from 'class-validator' import { Field, ID, InputType } from '@nestjs/graphql' @@ -7,54 +7,4 @@ export class CreateCivilClaimantInput { @Allow() @Field(() => ID) readonly caseId!: string - - @Allow() - @IsOptional() - @Field(() => Boolean, { nullable: true }) - readonly noNationalId?: boolean - - @Allow() - @IsOptional() - @Field(() => String, { nullable: true }) - readonly name?: string - - @Allow() - @IsOptional() - @Field(() => String, { nullable: true }) - readonly nationalId?: string - - @Allow() - @IsOptional() - @Field(() => Boolean, { nullable: true }) - readonly hasSpokesperson?: boolean - - @Allow() - @IsOptional() - @Field(() => Boolean, { nullable: true }) - readonly spokespersonIsLawyer?: boolean - - @Allow() - @IsOptional() - @Field(() => String, { nullable: true }) - readonly spokespersonNationalId?: string - - @Allow() - @IsOptional() - @Field(() => String, { nullable: true }) - readonly spokespersonName?: string - - @Allow() - @IsOptional() - @Field(() => String, { nullable: true }) - readonly spokespersonEmail?: string - - @Allow() - @IsOptional() - @Field(() => String, { nullable: true }) - readonly spokespersonPhoneNumber?: string - - @Allow() - @IsOptional() - @Field(() => Boolean, { nullable: true }) - readonly caseFilesSharedWithSpokesperson?: boolean } diff --git a/apps/judicial-system/backend/src/app/modules/case/case.service.ts b/apps/judicial-system/backend/src/app/modules/case/case.service.ts index c565c46de435..878a7147d6b4 100644 --- a/apps/judicial-system/backend/src/app/modules/case/case.service.ts +++ b/apps/judicial-system/backend/src/app/modules/case/case.service.ts @@ -341,6 +341,7 @@ export const order: OrderItem[] = [ [{ model: IndictmentCount, as: 'indictmentCounts' }, 'created', 'ASC'], [{ model: DateLog, as: 'dateLogs' }, 'created', 'DESC'], [{ model: Notification, as: 'notifications' }, 'created', 'DESC'], + [{ model: CivilClaimant, as: 'civilClaimants' }, 'created', 'ASC'], ] export const caseListInclude: Includeable[] = [ diff --git a/apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.controller.ts b/apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.controller.ts index 94af7f86f3d3..58cff3c4941b 100644 --- a/apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.controller.ts +++ b/apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.controller.ts @@ -21,7 +21,6 @@ import { import { prosecutorRepresentativeRule, prosecutorRule } from '../../guards' import { Case, CaseExistsGuard, CaseWriteGuard, CurrentCase } from '../case' -import { CreateCivilClaimantDto } from './dto/createCivilClaimant.dto' import { UpdateCivilClaimantDto } from './dto/updateCivilClaimant.dto' import { CivilClaimant } from './models/civilClaimant.model' import { DeleteCivilClaimantResponse } from './models/deleteCivilClaimant.response' @@ -46,11 +45,10 @@ export class CivilClaimantController { async create( @Param('caseId') caseId: string, @CurrentCase() theCase: Case, - @Body() createCivilClaimantDto: CreateCivilClaimantDto, ): Promise { this.logger.debug(`Creating a new civil claimant for case ${caseId}`) - return this.civilClaimantService.create(theCase, createCivilClaimantDto) + return this.civilClaimantService.create(theCase) } @UseGuards(CaseExistsGuard, CaseWriteGuard) diff --git a/apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.service.ts b/apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.service.ts index ad43c692f933..171c3cc7ee29 100644 --- a/apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.service.ts +++ b/apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.service.ts @@ -5,7 +5,6 @@ import type { Logger } from '@island.is/logging' import { LOGGER_PROVIDER } from '@island.is/logging' import { Case } from '../case' -import { CreateCivilClaimantDto } from './dto/createCivilClaimant.dto' import { UpdateCivilClaimantDto } from './dto/updateCivilClaimant.dto' import { CivilClaimant } from './models/civilClaimant.model' @@ -17,12 +16,8 @@ export class CivilClaimantService { @Inject(LOGGER_PROVIDER) private readonly logger: Logger, ) {} - async create( - theCase: Case, - claimantToCreate: CreateCivilClaimantDto, - ): Promise { + async create(theCase: Case): Promise { return this.civilClaimantModel.create({ - ...claimantToCreate, caseId: theCase.id, }) } diff --git a/apps/judicial-system/backend/src/app/modules/defendant/dto/createCivilClaimant.dto.ts b/apps/judicial-system/backend/src/app/modules/defendant/dto/createCivilClaimant.dto.ts deleted file mode 100644 index 2d5167b8849c..000000000000 --- a/apps/judicial-system/backend/src/app/modules/defendant/dto/createCivilClaimant.dto.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { IsBoolean, IsOptional, IsString } from 'class-validator' - -import { ApiPropertyOptional } from '@nestjs/swagger' - -export class CreateCivilClaimantDto { - @IsOptional() - @IsBoolean() - @ApiPropertyOptional({ type: Boolean }) - readonly noNationalId?: boolean - - @IsOptional() - @IsString() - @ApiPropertyOptional({ type: String }) - readonly name?: string - - @IsOptional() - @IsString() - @ApiPropertyOptional({ type: String }) - readonly nationalId?: string - - @IsOptional() - @IsBoolean() - @ApiPropertyOptional({ type: Boolean }) - readonly hasSpokesperson?: boolean - - @IsOptional() - @IsBoolean() - @ApiPropertyOptional({ type: Boolean }) - readonly spokespersonIsLawyer?: boolean - - @IsOptional() - @IsString() - @ApiPropertyOptional({ type: String }) - readonly spokespersonNationalId?: string - - @IsOptional() - @IsString() - @ApiPropertyOptional({ type: String }) - readonly spokespersonName?: string - - @IsOptional() - @IsString() - @ApiPropertyOptional({ type: String }) - readonly spokespersonEmail?: string - - @IsOptional() - @IsString() - @ApiPropertyOptional({ type: String }) - readonly spokespersonPhoneNumber?: string - - @IsOptional() - @IsBoolean() - @ApiPropertyOptional({ type: Boolean }) - readonly caseFilesSharedWithSpokesperson?: boolean -}