Skip to content

Commit

Permalink
LCSD-6320 (#4328)
Browse files Browse the repository at this point in the history
Licensing- SEP - Portal allows for more people to be in the service area than should be allowed
  • Loading branch information
simranjeetgit authored Dec 3, 2024
1 parent 3c538ad commit 174e655
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,16 @@ <h3>Service Areas</h3>
<app-field
label="Maximum number of guests in the service area at any given time"
errorMessage="Please enter a value"
[required]="true"
[valid]="!area.get('licencedAreaMaxNumberOfGuests').touched || area.get('licencedAreaMaxNumberOfGuests').valid">
<input type="number"
formControlName="licencedAreaMaxNumberOfGuests"
class="form-control">
<div class="error-text" *ngIf="isMaxGuestExceed( location.get('maximumNumberOfGuests').value, i )">
Maximum number of guests in the service area exceeds maximum number of guests at location
</div>
</app-field>

<app-field label="Will minors be in the service area?"
errorMessage="Please enter a value"
[valid]="!area.get('minorPresent').touched || area.get('minorPresent').valid">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,9 @@ td {

.setting-select {
width: 200px;
}
}

.error-text {
color: #d8292f;
font-size: 14px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [];
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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;
}

}

0 comments on commit 174e655

Please sign in to comment.