Skip to content

Commit

Permalink
fix(j-s): Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
unakb committed Oct 22, 2024
1 parent 9e7d46f commit 532e130
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,4 @@ export class UpdateSubpoenaDto {
@IsBoolean()
@ApiPropertyOptional({ type: Boolean })
readonly isDefenderChoiceConfirmed?: boolean

@IsOptional()
@IsBoolean()
@ApiPropertyOptional({ type: Boolean })
readonly caseFilesSharedWithDefender?: boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ export class SubpoenaService {
subpoena: Subpoena,
update: UpdateSubpoenaDto,
transaction?: Transaction,
user?: User,
): Promise<Subpoena> {
const {
defenderChoice,
Expand Down Expand Up @@ -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 ||
Expand All @@ -158,7 +159,7 @@ export class SubpoenaService {
requestedDefenderChoice,
requestedDefenderNationalId,
requestedDefenderName,
isDefenderChoiceConfirmed: confirmDefenderChoice,
isDefenderChoiceConfirmed: isChangingDefenderChoice ? false : undefined,
}

const [defenderUpdateAffectedRows] = await this.defendantModel.update(
Expand Down

0 comments on commit 532e130

Please sign in to comment.