Skip to content

Commit

Permalink
🔀 🐛 Correct issue causing crash if offenderDetail request fails (#572)
Browse files Browse the repository at this point in the history
* 🐛 Correct issue causing crash if offenderDetail request fails

Signed-off-by: theDustRoom <paul.massey@digital.justice.gov.uk>

* ♻️ Refactor

Signed-off-by: theDustRoom <paul.massey@digital.justice.gov.uk>
  • Loading branch information
theDustRoom committed May 18, 2022
1 parent 243bf85 commit 394ff58
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,13 +538,13 @@ module.exports = function Index ({ authenticationMiddleware }) {
const probationStatusDetails = await getProbationStatusDetails(crn)
return await updateOffender(defendantId, {
probationStatus: probationStatusDetails.status,
crn: offenderDetail.otherIds && offenderDetail.otherIds.crn,
crn: offenderDetail && offenderDetail.otherIds ? offenderDetail.otherIds.crn : undefined,
previouslyKnownTerminationDate: probationStatusDetails.previouslyKnownTerminationDate,
breach: probationStatusDetails.inBreach,
preSentenceActivity: probationStatusDetails.preSentenceActivity,
awaitingPsr: probationStatusDetails.awaitingPsr,
pnc: sendPncAndCroWithOffenderUpdates && offenderDetail.otherIds ? offenderDetail.otherIds.pncNumber : undefined,
cro: sendPncAndCroWithOffenderUpdates && offenderDetail.otherIds ? offenderDetail.otherIds.croNumber : undefined
pnc: sendPncAndCroWithOffenderUpdates && offenderDetail && offenderDetail.otherIds ? offenderDetail.otherIds.pncNumber : undefined,
cro: sendPncAndCroWithOffenderUpdates && offenderDetail && offenderDetail.otherIds ? offenderDetail.otherIds.croNumber : undefined
})
}

Expand Down

0 comments on commit 394ff58

Please sign in to comment.