From 532e130d9550b55a33321ba24a215ea4cb83fd4b Mon Sep 17 00:00:00 2001 From: unakb Date: Tue, 22 Oct 2024 18:01:13 +0000 Subject: [PATCH] fix(j-s): Feedback --- .../modules/subpoena/dto/updateSubpoena.dto.ts | 5 ----- .../app/modules/subpoena/subpoena.service.ts | 17 +++++++++-------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/apps/judicial-system/backend/src/app/modules/subpoena/dto/updateSubpoena.dto.ts b/apps/judicial-system/backend/src/app/modules/subpoena/dto/updateSubpoena.dto.ts index 363e2379cf7c..80603c97865d 100644 --- a/apps/judicial-system/backend/src/app/modules/subpoena/dto/updateSubpoena.dto.ts +++ b/apps/judicial-system/backend/src/app/modules/subpoena/dto/updateSubpoena.dto.ts @@ -69,9 +69,4 @@ export class UpdateSubpoenaDto { @IsBoolean() @ApiPropertyOptional({ type: Boolean }) readonly isDefenderChoiceConfirmed?: boolean - - @IsOptional() - @IsBoolean() - @ApiPropertyOptional({ type: Boolean }) - readonly caseFilesSharedWithDefender?: boolean } diff --git a/apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts b/apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts index a196ee4843cf..8949fe50ebf7 100644 --- a/apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts +++ b/apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts @@ -106,7 +106,6 @@ export class SubpoenaService { subpoena: Subpoena, update: UpdateSubpoenaDto, transaction?: Transaction, - user?: User, ): Promise { const { defenderChoice, @@ -136,12 +135,14 @@ export class SubpoenaService { }) let defenderAffectedRows = 0 - // This is added because the defender choice can only be confirmed by - // a district court user. If someone else updates it then we want to - // reset the existing confirmation (unless a court user is updating it) - const confirmDefenderChoice = Boolean( - user && isDistrictCourtUser(user) && isDefenderChoiceConfirmed === true, - ) + // If there is a change in the defender choice after the judge has confirmed the choice, + // we need to set the isDefenderChoiceConfirmed to false + const isChangingDefenderChoice = + (update.defenderChoice && + subpoena.defendant?.defenderChoice !== update.defenderChoice) || + (update.defenderNationalId && + subpoena.defendant?.defenderNationalId !== update.defenderNationalId && + subpoena.defendant?.isDefenderChoiceConfirmed) if ( defenderChoice || @@ -158,7 +159,7 @@ export class SubpoenaService { requestedDefenderChoice, requestedDefenderNationalId, requestedDefenderName, - isDefenderChoiceConfirmed: confirmDefenderChoice, + isDefenderChoiceConfirmed: isChangingDefenderChoice ? false : undefined, } const [defenderUpdateAffectedRows] = await this.defendantModel.update(