From a701374dc8785afa69ebd3875f224950e62d2b75 Mon Sep 17 00:00:00 2001 From: pbardy2000 <146740183+pbardy2000@users.noreply.github.com> Date: Thu, 28 Nov 2024 12:35:48 +0000 Subject: [PATCH] fix(cb2-15343): submit after gross laden weight calculation when brake code is not entered --- .../psv-brakes/psv-brakes.component.ts | 3 ++- .../technical-record-service.reducer.ts | 11 +++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/app/forms/custom-sections/psv-brakes/psv-brakes.component.ts b/src/app/forms/custom-sections/psv-brakes/psv-brakes.component.ts index c84acd246..a16a08766 100644 --- a/src/app/forms/custom-sections/psv-brakes/psv-brakes.component.ts +++ b/src/app/forms/custom-sections/psv-brakes/psv-brakes.component.ts @@ -101,7 +101,8 @@ export class PsvBrakesComponent implements OnInit, OnChanges, OnDestroy { } get brakeCode(): string { - return `${this.brakeCodePrefix}${this.form.get('techRecord_brakes_brakeCodeOriginal')?.value}`; + const suffix = this.form.get('techRecord_brakes_brakeCodeOriginal')?.value; + return suffix ? `${this.brakeCodePrefix}${suffix}` : '-'; } get brakesForm(): FormGroup { diff --git a/src/app/store/technical-records/technical-record-service.reducer.ts b/src/app/store/technical-records/technical-record-service.reducer.ts index d69fd98f9..2af9410a5 100644 --- a/src/app/store/technical-records/technical-record-service.reducer.ts +++ b/src/app/store/technical-records/technical-record-service.reducer.ts @@ -228,13 +228,12 @@ function handleUpdateBrakeForces( } if (data.grossLadenWeight) { - const prefix = `${Math.round(data.grossLadenWeight / 100)}`; + if (newState.editingTechRecord.techRecord_brakes_brakeCodeOriginal) { + const prefix = `${Math.round(data.grossLadenWeight / 100)}`; + newState.editingTechRecord.techRecord_brakes_brakeCode = + (prefix.length <= 2 ? `0${prefix}` : prefix) + newState.editingTechRecord.techRecord_brakes_brakeCodeOriginal; + } - newState.editingTechRecord.techRecord_brakes_brakeCode = - (prefix.length <= 2 - ? `0${prefix}` - : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - prefix) + newState.editingTechRecord.techRecord_brakes_brakeCodeOriginal!; newState.editingTechRecord.techRecord_brakes_brakeForceWheelsNotLocked_serviceBrakeForceA = Math.round( (data.grossLadenWeight * 16) / 100 );