diff --git a/src/app/preparer/add/add-preparer.component.html b/src/app/preparer/add/add-preparer.component.html index 0f0d45a..1aca873 100644 --- a/src/app/preparer/add/add-preparer.component.html +++ b/src/app/preparer/add/add-preparer.component.html @@ -7,7 +7,7 @@ Basic Details + (showLocations)="onShowLocations($event)"(locationAdded)="onLocationAdded($event)"> @@ -16,7 +16,8 @@ Locations + (updated)="onLocationUpdated($event)" [userPreferences]="userPreferences" + [refreshLocationData]="refreshLocationData"> diff --git a/src/app/preparer/add/add-preparer.component.ts b/src/app/preparer/add/add-preparer.component.ts index 0679b7c..dd379cd 100644 --- a/src/app/preparer/add/add-preparer.component.ts +++ b/src/app/preparer/add/add-preparer.component.ts @@ -44,14 +44,18 @@ export class AddPreparerComponent { this.locationCompleted = event; } - onLocationUpdated(updated: boolean): void { - this.refreshLocationData = updated; + onLocationUpdated(event: boolean): void { + this.refreshLocationData = event; } onShowLocations(event: boolean): void { this.showLocation = event; } + onLocationAdded(event: boolean): void { + this.refreshLocationData = event; + } + onStepChange(event: StepperSelectionEvent): void { this.currentStep = event.selectedIndex; } diff --git a/src/app/preparer/basic-details/basic-details.component.ts b/src/app/preparer/basic-details/basic-details.component.ts index 97db8b2..c712b56 100644 --- a/src/app/preparer/basic-details/basic-details.component.ts +++ b/src/app/preparer/basic-details/basic-details.component.ts @@ -27,6 +27,7 @@ export class BasicDetailsComponent implements OnInit, OnDestroy { @Output() clientidCreated = new EventEmitter(); @Output() clientName = new EventEmitter(); @Output() showLocations = new EventEmitter(); + @Output() locationAdded = new EventEmitter(); basicDetailsForm: FormGroup; countries: Country[] = []; @@ -254,6 +255,7 @@ export class BasicDetailsComponent implements OnInit, OnDestroy { this.locationService.createLocation(clientid, locationData).subscribe({ next: () => { //this.notificationService.showSuccess('Location added successfully'); + this.locationAdded.emit(true); }, error: (error) => { let errorMessage = this.errorHandler.handleApiError(error, 'Failed to add location'); diff --git a/src/app/preparer/contacts/contacts.component.html b/src/app/preparer/contacts/contacts.component.html index 6a178c2..3a7dd55 100644 --- a/src/app/preparer/contacts/contacts.component.html +++ b/src/app/preparer/contacts/contacts.component.html @@ -280,6 +280,7 @@
+

Create Login

@@ -315,6 +316,6 @@
- + \ No newline at end of file diff --git a/src/app/preparer/location/location.component.ts b/src/app/preparer/location/location.component.ts index 4c01ad0..93ae3ab 100644 --- a/src/app/preparer/location/location.component.ts +++ b/src/app/preparer/location/location.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, inject, Input, Output, ViewChild } from '@angular/core'; +import { Component, EventEmitter, inject, Input, Output, SimpleChanges, ViewChild } from '@angular/core'; import { AngularMaterialModule } from '../../shared/module/angular-material.module'; import { CommonModule } from '@angular/common'; import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms'; @@ -47,6 +47,7 @@ export class LocationComponent { @Input() clientid: number = 0; @Input() userPreferences: UserPreferences = {}; + @Input() refreshLocationData: boolean = false; @Output() hasLocations = new EventEmitter(); @Output() updated = new EventEmitter(); @@ -67,7 +68,7 @@ export class LocationComponent { address2: ['', [Validators.maxLength(100)]], city: ['', [Validators.required, Validators.maxLength(50)]], state: ['', Validators.required], - country: ['', Validators.required], + country: ['US', Validators.required], zip: ['', [Validators.required, ZipCodeValidator('country')]], }); } @@ -87,6 +88,12 @@ export class LocationComponent { this.destroy$.complete(); } + ngOnChanges(changes: SimpleChanges) { + if (changes['refreshLocationData']) { + this.loadLocations(); + } + } + loadLocations(): void { this.isLoading = true; @@ -119,6 +126,11 @@ export class LocationComponent { this.isEditing = false; this.currentLocationId = null; this.locationForm.reset(); + + this.locationForm.patchValue({ + country: 'US' + }); + this.loadStates('US'); } editLocation(location: Location): void {