Skip to content

Commit

Permalink
fix(CB2-14953) (#1630)
Browse files Browse the repository at this point in the history
* fix(cb2-14953): do not save body declaration when its not applicable

* fix(cb2-14953): update comment
  • Loading branch information
pbardy2000 authored Nov 4, 2024
1 parent 02fda73 commit bbda541
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,25 @@ function handleClearADRDetails(state: TechnicalRecordServiceState) {
sanitisedEditingTechRecord = { ...sanitisedEditingTechRecord, ...nulledWeight };
}

// If ADR body type does not require a body declaration or explosives type 3 is not selected, null the body declaration field
const bodyTypesRequiringDeclaration: string[] = [
ADRBodyType.RIGID_BOX_BODY,
ADRBodyType.FULL_DRAWBAR_BOX_BODY,
ADRBodyType.CENTRE_AXLE_BOX_BODY,
ADRBodyType.SEMI_TRAILER_BOX_BODY,
];

const adrBodyType = sanitisedEditingTechRecord.techRecord_adrDetails_vehicleDetails_type;
const permittedDangerousGoods = sanitisedEditingTechRecord.techRecord_adrDetails_permittedDangerousGoods;

if (
(adrBodyType && !bodyTypesRequiringDeclaration.includes(adrBodyType)) ||
!permittedDangerousGoods?.includes(ADRDangerousGood.EXPLOSIVES_TYPE_3)
) {
// @TO-DO: use null instead of undefined. This is a workaround for the type definitions validation rule
sanitisedEditingTechRecord.techRecord_adrDetails_bodyDeclaration_type = undefined;
}

return { ...state, editingTechRecord: sanitisedEditingTechRecord };
}
}
Expand Down

0 comments on commit bbda541

Please sign in to comment.