();
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 @@
+
-
+
\ 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 {