From 174e65570bae7dca174171eef50061576634c734 Mon Sep 17 00:00:00 2001 From: simranjeetgit Date: Tue, 3 Dec 2024 11:12:43 -0800 Subject: [PATCH] LCSD-6320 (#4328) Licensing- SEP - Portal allows for more people to be in the service area than should be allowed --- .../event/event.component.html | 5 ++++ .../event/event.component.scss | 7 +++++- .../sep-application/event/event.component.ts | 25 ++++++++++++++++++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/cllc-public-app/ClientApp/src/app/components/sep/sep-application/event/event.component.html b/cllc-public-app/ClientApp/src/app/components/sep/sep-application/event/event.component.html index 62262f351d..7eb98f5422 100644 --- a/cllc-public-app/ClientApp/src/app/components/sep/sep-application/event/event.component.html +++ b/cllc-public-app/ClientApp/src/app/components/sep/sep-application/event/event.component.html @@ -166,11 +166,16 @@

Service Areas

+
+ Maximum number of guests in the service area exceeds maximum number of guests at location +
+ diff --git a/cllc-public-app/ClientApp/src/app/components/sep/sep-application/event/event.component.scss b/cllc-public-app/ClientApp/src/app/components/sep/sep-application/event/event.component.scss index f5aaaf9518..20740e7eb3 100644 --- a/cllc-public-app/ClientApp/src/app/components/sep/sep-application/event/event.component.scss +++ b/cllc-public-app/ClientApp/src/app/components/sep/sep-application/event/event.component.scss @@ -21,4 +21,9 @@ td { .setting-select { width: 200px; -} \ No newline at end of file +} + +.error-text { + color: #d8292f; + font-size: 14px; + } \ No newline at end of file diff --git a/cllc-public-app/ClientApp/src/app/components/sep/sep-application/event/event.component.ts b/cllc-public-app/ClientApp/src/app/components/sep/sep-application/event/event.component.ts index e8f3aaab79..4f056adef0 100644 --- a/cllc-public-app/ClientApp/src/app/components/sep/sep-application/event/event.component.ts +++ b/cllc-public-app/ClientApp/src/app/components/sep/sep-application/event/event.component.ts @@ -32,6 +32,7 @@ export class EventComponent extends FormBase implements OnInit { faQuestionCircle = faQuestionCircle; form: FormGroup; showValidationMessages: boolean; + showAmountExceedValidation: boolean; validationMessages: string[]; previewCities: AutoCompleteItem[] = []; autocompleteCities: AutoCompleteItem[] = []; @@ -360,6 +361,9 @@ export class EventComponent extends FormBase implements OnInit { this.markControlsAsTouched(this.form); this.form.updateValueAndValidity(); this.validationMessages = this.listControlsWithErrors(this.form, {}); + if (this.showAmountExceedValidation) { + this.validationMessages.push("Maximum number of guests in the service area exceeds maximum number of guests at location"); + } const valid = this.form.valid; return valid; } @@ -498,7 +502,7 @@ export class EventComponent extends FormBase implements OnInit { next() { this.showValidationMessages = false; - if (this.isValid() && this.form.get('sepCity')?.value?.id) { + if (this.isValid() && this.form.get('sepCity')?.value?.id && !this.showAmountExceedValidation) { this.saveComplete.emit(this.getFormValue()); //console.log("saving...") } else { @@ -507,4 +511,23 @@ export class EventComponent extends FormBase implements OnInit { } } + isMaxGuestExceed(locationNumber, locationIndex: number): Boolean { + + if (locationNumber === undefined) { + return true; + } + let sum = 0; + let areas = this.getServiceAreas(locationIndex); + areas.controls.forEach((area) => { + const value = area.get('licencedAreaMaxNumberOfGuests').value; + if (!isNaN(value)) { + sum += (Number(value)); + } + }); + + let totalGuestOnLocation = locationNumber; + this.showAmountExceedValidation = Number(sum) > Number(totalGuestOnLocation); + return this.showAmountExceedValidation; + } + }