preparer location updates

This commit is contained in:
Cyril Joseph 2025-07-29 08:09:54 -03:00
parent 7c6a9996bc
commit 7bbb633cd7
5 changed files with 27 additions and 7 deletions

View File

@ -7,7 +7,7 @@
<ng-template matStepLabel>Basic Details</ng-template>
<app-basic-details [isEditMode]="isEditMode" (clientidCreated)="onBasicDetailsSaved($event)"
(showLocations)="onShowLocations($event)">
(showLocations)="onShowLocations($event)"(locationAdded)="onLocationAdded($event)">
</app-basic-details>
</mat-step>
@ -16,7 +16,8 @@
<ng-template matStepLabel>Locations</ng-template>
<app-location *ngIf="clientid" [clientid]="clientid" (hasLocations)="onLocationSaved($event)"
(updated)="onLocationUpdated($event)" [userPreferences]="userPreferences">
(updated)="onLocationUpdated($event)" [userPreferences]="userPreferences"
[refreshLocationData]="refreshLocationData">
</app-location>
</mat-step>

View File

@ -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;
}

View File

@ -27,6 +27,7 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
@Output() clientidCreated = new EventEmitter<string>();
@Output() clientName = new EventEmitter<string>();
@Output() showLocations = new EventEmitter<boolean>();
@Output() locationAdded = new EventEmitter<boolean>();
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');

View File

@ -280,6 +280,7 @@
<!-- Contact Login Form -->
<div class="form-container" *ngIf="showLoginForm">
<!-- <form [formGroup]="contactLoginForm" (ngSubmit)="saveLogin()"> -->
<form>
<div class="form-header">
<h3>Create Login</h3>
</div>
@ -315,6 +316,6 @@
</button>
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
</div>
<!-- </form> -->
</form>
</div>
</div>

View File

@ -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<boolean>();
@Output() updated = new EventEmitter<boolean>();
@ -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 {