shipping and travel plan updates

This commit is contained in:
Cyril Joseph 2025-07-23 17:16:17 -03:00
parent c58b276316
commit 54a4505085
2 changed files with 16 additions and 4 deletions

View File

@ -10,7 +10,7 @@ import { Shipping } from '../../core/models/carnet/shipping';
import { Country } from '../../core/models/country';
import { State } from '../../core/models/state';
import { ZipCodeValidator } from '../../shared/validators/zipcode-validator';
import { finalize, forkJoin, map, Subject, switchMap, takeUntil, throwError } from 'rxjs';
import { finalize, forkJoin, map, of, Subject, switchMap, takeUntil, throwError } from 'rxjs';
import { DeliveryType } from '../../core/models/delivery-type';
import { DeliveryMethod } from '../../core/models/delivery-method';
import { PaymentType } from '../../core/models/payment-type';
@ -302,10 +302,11 @@ export class ShippingComponent {
loadShippingData(): void {
this.isLoading = true;
this.holderService.getHolder(this.headerid).pipe(
switchMap((holder: Holder) => {
if (!holder) {
return throwError(() => new Error('Holder not found'));
if (!holder?.holderid) {
return of(undefined);
}
return forkJoin({
@ -322,6 +323,11 @@ export class ShippingComponent {
finalize(() => this.isLoading = false)
).subscribe({
next: (results) => {
if (!results) { // do nothing if empty
return;
}
this.holderid = results.holder.holderid;
this.holderContacts = results.holderContacts;
this.holderAddress = results.holderAddress;

View File

@ -1,4 +1,4 @@
import { Component, EventEmitter, inject, Input, Output } from '@angular/core';
import { Component, EventEmitter, inject, Input, Output, SimpleChanges } from '@angular/core';
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
import { forkJoin } from 'rxjs';
import { TravelPlanService } from '../../core/services/carnet/travel-plan.service';
@ -57,6 +57,12 @@ export class TravelPlanComponent {
}
}
ngOnChanges(changes: SimpleChanges) {
if (changes['headerid'] && this.headerid > 0) {
this.loadTravelPlan();
}
}
onAvailableVisitCountrySelection(event: any) {
this.selectedAvailableVisitCountry = event.value;
}