diff --git a/src/app/carnet/checkout/checkout.component.ts b/src/app/carnet/checkout/checkout.component.ts index 7572591..f8e1926 100644 --- a/src/app/carnet/checkout/checkout.component.ts +++ b/src/app/carnet/checkout/checkout.component.ts @@ -47,7 +47,7 @@ export class CheckoutComponent { constructor() { this.currentApplicationDetails = this.storageService.get<{ headerid: number, applicationName: string, applicationType: string }>('currentapplication') - this.orderDetails.description = ` 'Carnet Application - ${this.currentApplicationDetails?.applicationName}` + this.orderDetails.description = ` 'Carnet Application - ${this.currentApplicationDetails?.headerid} - ${this.currentApplicationDetails?.applicationName}` } ngOnInit(): void { @@ -114,8 +114,6 @@ export class CheckoutComponent { // data.orderID is the ID of the transaction from PayPal const captureDetails = await this.paymentService.completePayment(data.orderID); - // console.log('Capture details:', captureDetails); - // You can now redirect the user or update the UI this.changeInProgress = true; this.carnetService.submitApplication(this.currentApplicationDetails?.headerid!).pipe(finalize(() => { @@ -146,6 +144,7 @@ export class CheckoutComponent { // 4. Handle cancellation onCancel: (data: any) => { + this.onCancel(); } }).render(this.paypalElement.nativeElement) .catch((error: any) => { @@ -158,5 +157,29 @@ export class CheckoutComponent { (fee): fee is number => typeof fee === 'number' ); this.orderTotal = validFees.reduce((total, fee) => total + fee, 0); + this.orderDetails.price = this.orderTotal?.toString() ?? '0.00'; + } + + onCancel(): void { + this.storageService.removeItem('currentapplication'); + + let route: string = 'edit-carnet'; + if (this.currentApplicationDetails?.applicationType === 'duplicate') { + route = 'duplicate-carnet'; + } + else if (this.currentApplicationDetails?.applicationType === 'extend') { + route = 'extend-carnet'; + } else if (this.currentApplicationDetails?.applicationType === 'additional') { + route = 'additional-sets'; + } + + this.navigationService.navigate([route, this.currentApplicationDetails?.headerid], + { + state: { isEditMode: true }, + queryParams: { + applicationname: this.currentApplicationDetails?.applicationName, + return: 'shipping' + } + }) } } \ No newline at end of file diff --git a/src/app/carnet/shipping/shipping.component.html b/src/app/carnet/shipping/shipping.component.html index eee792c..03f98d2 100644 --- a/src/app/carnet/shipping/shipping.component.html +++ b/src/app/carnet/shipping/shipping.component.html @@ -289,7 +289,7 @@ Delivery Type is required - + {{ deliveryEstimate }} diff --git a/src/app/carnet/travel-plan/travel-plan.component.ts b/src/app/carnet/travel-plan/travel-plan.component.ts index e399f3d..0ba69f8 100644 --- a/src/app/carnet/travel-plan/travel-plan.component.ts +++ b/src/app/carnet/travel-plan/travel-plan.component.ts @@ -129,7 +129,7 @@ export class TravelPlanComponent { title: 'For your information', message: country.actionMessage, confirmText: 'Ok', - cancelText: 'Cancel' + hideCancel: true } }); @@ -147,8 +147,8 @@ export class TravelPlanComponent { data: { title: 'Warning', message: country.actionMessage, - confirmText: 'Ok', - cancelText: 'Cancel' + confirmText: 'Yes', + cancelText: 'No' } }); @@ -171,8 +171,8 @@ export class TravelPlanComponent { data: { title: 'Act', message: country.actionMessage, - confirmText: 'Ok', - cancelText: 'Cancel' + confirmText: 'Yes', + cancelText: 'No' } }); diff --git a/src/app/common/footer/footer.component.html b/src/app/common/footer/footer.component.html index 01d4752..18c48a7 100644 --- a/src/app/common/footer/footer.component.html +++ b/src/app/common/footer/footer.component.html @@ -7,7 +7,7 @@ \ No newline at end of file diff --git a/src/app/common/footer/footer.component.ts b/src/app/common/footer/footer.component.ts index ba744bb..2f94b31 100644 --- a/src/app/common/footer/footer.component.ts +++ b/src/app/common/footer/footer.component.ts @@ -1,8 +1,6 @@ -import { Component, effect, inject, Input } from '@angular/core'; +import { Component, Input } from '@angular/core'; import { AngularMaterialModule } from '../../shared/module/angular-material.module'; import { CommonModule } from '@angular/common'; -import { User } from '../../core/models/user'; -import { UserService } from '../../core/services/common/user.service'; @Component({ selector: 'app-footer', @@ -12,20 +10,5 @@ import { UserService } from '../../core/services/common/user.service'; }) export class FooterComponent { currentYear = new Date().getFullYear(); - currentServiceProviderName: string = ''; - userDetails: User | null = {}; - @Input() isUserLoggedIn = false; - - private userService = inject(UserService); - - constructor( - ) { - effect(() => { - this.userDetails = this.userService.userDetailsSignal(); - if (this.userDetails?.userDetails) { - this.currentServiceProviderName = this.userDetails.userDetails.serviceProviderName || ''; - } - }); - } } \ No newline at end of file diff --git a/src/app/core/models/industry-type.ts b/src/app/core/models/industry-type.ts new file mode 100644 index 0000000..31c35dd --- /dev/null +++ b/src/app/core/models/industry-type.ts @@ -0,0 +1,5 @@ +export interface IndustryType { + name: string; + id: string; + value: string; +} diff --git a/src/app/core/models/preparer/basic-detail.ts b/src/app/core/models/preparer/basic-detail.ts index 4aca4fa..5685c1d 100644 --- a/src/app/core/models/preparer/basic-detail.ts +++ b/src/app/core/models/preparer/basic-detail.ts @@ -11,4 +11,5 @@ export interface BasicDetail { zip: string; carnetIssuingRegion: string; revenueLocation: string; + industryType: string; } diff --git a/src/app/core/services/carnet/payment.service.ts b/src/app/core/services/carnet/payment.service.ts index 1218014..0635983 100644 --- a/src/app/core/services/carnet/payment.service.ts +++ b/src/app/core/services/carnet/payment.service.ts @@ -13,8 +13,13 @@ export class PaymentService { private http = inject(HttpClient); createOrder(orderDetails: any): Promise { + const data = { + P_PRICE: orderDetails.price, + P_DESCRIPTION: orderDetails.description + } + return firstValueFrom( - this.http.post<{ id: string }>(`${this.apiUrl}/${this.apiDb}/InitiatePayment`, {}) + this.http.post<{ id: string }>(`${this.apiUrl}/${this.apiDb}/InitiatePayment`, data) ).then(order => order.id); } diff --git a/src/app/core/services/common/auth.service.ts b/src/app/core/services/common/auth.service.ts index 1f34416..2d7f032 100644 --- a/src/app/core/services/common/auth.service.ts +++ b/src/app/core/services/common/auth.service.ts @@ -14,6 +14,7 @@ import { ApiErrorHandlerService } from './api-error-handler.service'; }) export class AuthService { private apiUrl = environment.apiUrl; + private applicationName = environment.appType; private http = inject(HttpClient); private userService = inject(UserService); @@ -24,7 +25,7 @@ export class AuthService { private errorHandler = inject(ApiErrorHandlerService); login(username: string, password: string): Observable { - return this.http.post(`${this.apiUrl}/login`, { p_emailaddr: username, p_password: password }); + return this.http.post(`${this.apiUrl}/login`, { p_emailaddr: username, p_password: password, P_APPLICATIONNAME: this.applicationName }); } refreshToken(): Observable { diff --git a/src/app/core/services/common/common.service.ts b/src/app/core/services/common/common.service.ts index 7dc83d6..330b05a 100644 --- a/src/app/core/services/common/common.service.ts +++ b/src/app/core/services/common/common.service.ts @@ -18,6 +18,7 @@ import { FormOfSecurity } from '../../models/formofsecurity'; import { PaymentType } from '../../models/payment-type'; import { UnitOfMeasure } from '../../models/unitofmeasure'; import { ExtensionReason } from '../../models/extension-reason'; +import { IndustryType } from '../../models/industry-type'; @Injectable({ providedIn: 'root' @@ -59,7 +60,7 @@ export class CommonService { } getRegions(): Observable { - return this.http.get(`${this.apiUrl}/${this.apiDb}/GetRegions`).pipe( + return this.http.get(`${this.apiUrl}/${this.apiDb}/GetRegions/${this.userService.getUserSpid()}`).pipe( map((response) => response.map((item) => ({ id: item.REGIONID, @@ -218,6 +219,18 @@ export class CommonService { ); } + getIndustryTypes(): Observable { + return this.http.get(`${this.apiUrl}/${this.apiDb}/GetParamValues?P_PARAMTYPE=018&P_SPID=${this.userService.getUserSpid()}`).pipe( + map((response) => + response.map((item) => ({ + name: item.PARAMDESC, + id: item.PARAMID, + value: item.PARAMVALUE, + })) + ) + ); + } + formatUSDate(datetime: Date): string { const date = new Date(datetime); const month = String(date.getUTCMonth() + 1).padStart(2, '0'); diff --git a/src/app/core/services/preparer/basic-detail.service.ts b/src/app/core/services/preparer/basic-detail.service.ts index 7fc8421..2dd8381 100644 --- a/src/app/core/services/preparer/basic-detail.service.ts +++ b/src/app/core/services/preparer/basic-detail.service.ts @@ -34,6 +34,7 @@ export class BasicDetailService { carnetIssuingRegion: basicDetails.ISSUINGREGION, revenueLocation: basicDetails.REVENUELOCATION, zip: basicDetails.ZIP, + industryType: ""// basicDetails.INDUSTRYTYPE }; } @@ -50,6 +51,7 @@ export class BasicDetailService { P_ZIP: data.zip, P_ISSUINGREGION: data.carnetIssuingRegion, P_REVENUELOCATION: data.revenueLocation, + P_INDUSTRYTYPE: data.industryType, P_USERID: this.userService.getUser(), } @@ -69,6 +71,7 @@ export class BasicDetailService { P_COUNTRY: data.country, P_ZIP: data.zip, P_REVENUELOCATION: data.revenueLocation, + P_INDUSTRYTYPE: data.industryType, P_USERID: this.userService.getUser(), } diff --git a/src/app/core/services/preparer/client.service.ts b/src/app/core/services/preparer/client.service.ts index 2747936..4326f58 100644 --- a/src/app/core/services/preparer/client.service.ts +++ b/src/app/core/services/preparer/client.service.ts @@ -35,6 +35,7 @@ export class ClientService { carnetIssuingRegion: basicDetails.ISSUINGREGION, revenueLocation: basicDetails.REVENUELOCATION, zip: basicDetails.ZIP, + industryType: "" // createdBy: basicDetails.CREATEDBY || null, // dateCreated: basicDetails.DATECREATED || null, // lastUpdatedBy: basicDetails.LASTUPDATEDBY || null, diff --git a/src/app/core/services/preparer/contact.service.ts b/src/app/core/services/preparer/contact.service.ts index dbcf251..ec2145f 100644 --- a/src/app/core/services/preparer/contact.service.ts +++ b/src/app/core/services/preparer/contact.service.ts @@ -103,4 +103,8 @@ export class ContactService { reactivateContact(clientContactId: string): Observable { return this.http.patch(`${this.apiUrl}/${this.apiDb}/ReactivateClientContacts/${this.userService.getUserSpid()}/${clientContactId}/${this.userService.getUser()}`, null); } + + setDefaultServiceProviderContact(clientContactId: string): Observable { + return this.http.patch(`${this.apiUrl}/${this.apiDb}/ReactivateClientContacts/${this.userService.getUserSpid()}/${clientContactId}/${this.userService.getUser()}`, null); + } } diff --git a/src/app/holder/basic-details/basic-details.component.ts b/src/app/holder/basic-details/basic-details.component.ts index 5bd96e8..2a15886 100644 --- a/src/app/holder/basic-details/basic-details.component.ts +++ b/src/app/holder/basic-details/basic-details.component.ts @@ -15,6 +15,7 @@ import { BasicDetail } from '../../core/models/holder/basic-detail'; import { StorageService } from '../../core/services/common/storage.service'; import { NavigationService } from '../../core/services/common/navigation.service'; import { environment } from '../../../environments/environment'; +import { HolderService } from '../../core/services/carnet/holder.service'; @Component({ selector: 'app-basic-detail', @@ -49,6 +50,7 @@ export class BasicDetailComponent implements OnInit, OnDestroy { private errorHandler = inject(ApiErrorHandlerService); private storageService = inject(StorageService); private navigationService = inject(NavigationService); + private carnetHolderService = inject(HolderService); constructor() { this.basicDetailsForm = this.createForm(); @@ -133,6 +135,9 @@ export class BasicDetailComponent implements OnInit, OnDestroy { if (!this.isEditMode) { this.holderIdCreated.emit(basicData.HOLDERID); + // save the created holder for the current application + this.saveHolderToApplication(basicData.HOLDERID); + // change to edit mode after creation this.isEditMode = true; this.holderid = basicData.HOLDERID; @@ -226,4 +231,22 @@ export class BasicDetailComponent implements OnInit, OnDestroy { } }) } + + saveHolderToApplication(holderid: number): void { + this.changeInProgress = true; + const saveObservable = this.carnetHolderService.saveApplicationHolder(this.currentApplicationDetails?.headerid!, holderid); + + saveObservable.pipe(finalize(() => { + this.changeInProgress = false; + })).subscribe({ + next: (basicData: any) => { + }, + error: (error: any) => { + let errorMessage = this.errorHandler.handleApiError(error, `Failed to save holder details`); + this.notificationService.showError(errorMessage); + console.error('Error saving holder details:', error); + } + }); + } + } diff --git a/src/app/param/table/param-table.component.html b/src/app/param/table/param-table.component.html index 50a2df6..7f55792 100644 --- a/src/app/param/table/param-table.component.html +++ b/src/app/param/table/param-table.component.html @@ -85,8 +85,9 @@ chevron_right - diff --git a/src/app/param/table/param-table.component.ts b/src/app/param/table/param-table.component.ts index 2207bc7..7f31f25 100644 --- a/src/app/param/table/param-table.component.ts +++ b/src/app/param/table/param-table.component.ts @@ -38,6 +38,7 @@ export class ParamTableComponent { paramData: any = []; showInactiveData: boolean = false; isEditing: boolean = false; + allowEdit: boolean = true; showForm: boolean = false; currentParamid: number | null = null; @@ -116,6 +117,7 @@ export class ParamTableComponent { ngOnInit(): void { this.paramType = this.route.snapshot.paramMap.get('id'); + this.allowEdit = this.paramType !== '014'; this.getParameters(); } diff --git a/src/app/preparer/basic-details/basic-details.component.html b/src/app/preparer/basic-details/basic-details.component.html index 0c55eee..518843b 100644 --- a/src/app/preparer/basic-details/basic-details.component.html +++ b/src/app/preparer/basic-details/basic-details.component.html @@ -111,8 +111,19 @@ -
+ + Industry Type + + + {{ industryType.name }} + + + + Industry Type is required + + + Carnet Issuing Region diff --git a/src/app/preparer/basic-details/basic-details.component.scss b/src/app/preparer/basic-details/basic-details.component.scss index 515264a..ade6d00 100644 --- a/src/app/preparer/basic-details/basic-details.component.scss +++ b/src/app/preparer/basic-details/basic-details.component.scss @@ -57,7 +57,8 @@ } .carnet-issuing-region, - .revenue-location { + .revenue-location, + .industry-type { grid-column: span 1; } } diff --git a/src/app/preparer/basic-details/basic-details.component.ts b/src/app/preparer/basic-details/basic-details.component.ts index ce672dc..014c706 100644 --- a/src/app/preparer/basic-details/basic-details.component.ts +++ b/src/app/preparer/basic-details/basic-details.component.ts @@ -14,6 +14,7 @@ import { BasicDetail } from '../../core/models/preparer/basic-detail'; import { ZipCodeValidator } from '../../shared/validators/zipcode-validator'; import { LocationService } from '../../core/services/preparer/location.service'; import { Location } from '../../core/models/preparer/location'; +import { IndustryType } from '../../core/models/industry-type'; @Component({ selector: 'app-basic-details', @@ -33,6 +34,7 @@ export class BasicDetailsComponent implements OnInit, OnDestroy { countries: Country[] = []; regions: Region[] = []; states: State[] = []; + industryTypes: IndustryType[] = []; isLoading = true; changeInProgress = false; @@ -93,6 +95,7 @@ export class BasicDetailsComponent implements OnInit, OnDestroy { zip: ['', [Validators.required, ZipCodeValidator('country')]], carnetIssuingRegion: ['', Validators.required], revenueLocation: ['', Validators.required], + industryType: ['', Validators.required], hasAdditionalLocations: [false] }); } @@ -110,6 +113,7 @@ export class BasicDetailsComponent implements OnInit, OnDestroy { }); this.loadRegions(); + this.loadIndustryTypes(); } loadRegions(): void { @@ -125,6 +129,19 @@ export class BasicDetailsComponent implements OnInit, OnDestroy { }); } + loadIndustryTypes(): void { + this.commonService.getIndustryTypes() + .pipe(takeUntil(this.destroy$)) + .subscribe({ + next: (industryTypes) => { + this.industryTypes = industryTypes; + }, + error: (error) => { + console.error('Failed to load industry types', error); + } + }); + } + loadStates(country: string): void { this.isLoading = true; country = this.countriesHasStates.includes(country) ? country : 'FN'; @@ -164,7 +181,8 @@ export class BasicDetailsComponent implements OnInit, OnDestroy { state: data.state, zip: data.zip, carnetIssuingRegion: data.carnetIssuingRegion, - revenueLocation: data.revenueLocation + revenueLocation: data.revenueLocation, + industryType: data.industryType }); if (data.country) { diff --git a/src/app/preparer/contacts/contacts.component.html b/src/app/preparer/contacts/contacts.component.html index 6fc64d5..b1fc2ef 100644 --- a/src/app/preparer/contacts/contacts.component.html +++ b/src/app/preparer/contacts/contacts.component.html @@ -82,10 +82,11 @@ reactivateContact(contact.clientContactId)" [hidden]="!contact.isInactive" matTooltip="Reactivate"> loupe - + diff --git a/src/app/preparer/contacts/contacts.component.ts b/src/app/preparer/contacts/contacts.component.ts index a116704..20feee9 100644 --- a/src/app/preparer/contacts/contacts.component.ts +++ b/src/app/preparer/contacts/contacts.component.ts @@ -302,16 +302,32 @@ export class ContactsComponent { // this.contactLoginForm.reset(); } - // setDefaultContact(contactId: string): void { - // this.contactService.setDefaultServiceProviderContact(this.spid, contactId).subscribe({ - // next: () => { - // this.notificationService.showSuccess('Default contact updated successfully'); - // this.loadContacts(); - // }, - // error: (error) => { - // this.notificationService.showError('Failed to set default contact'); - // console.error('Error setting default contact:', error); - // } - // }); - // } + setDefaultContact(contactId: string): void { + + const dialogRef = this.dialog.open(ConfirmDialogComponent, { + width: '450px', + data: { + title: 'Confirm Default Contact', + message: 'Are you sure you want to set this contact as default contact?', + confirmText: 'Yes', + cancelText: 'Cancel' + } + }); + + dialogRef.afterClosed().subscribe(result => { + if (result) { + this.contactService.setDefaultServiceProviderContact(contactId).subscribe({ + next: () => { + this.notificationService.showSuccess('Default contact updated successfully'); + this.loadContacts(); + }, + error: (error) => { + let errorMessage = this.errorHandler.handleApiError(error, 'Failed to set default contact'); + this.notificationService.showError(errorMessage); + console.error('Error setting default contact:', error); + } + }); + } + }); + } } diff --git a/src/app/preparer/manage/manage-preparer.component.html b/src/app/preparer/manage/manage-preparer.component.html index 569feeb..b1b7e9b 100644 --- a/src/app/preparer/manage/manage-preparer.component.html +++ b/src/app/preparer/manage/manage-preparer.component.html @@ -94,6 +94,12 @@ {{client.country}} + + + Industry Type + {{client.industryType}} + + Carnet Issuing region diff --git a/src/app/preparer/manage/manage-preparer.component.ts b/src/app/preparer/manage/manage-preparer.component.ts index 747ca3f..01accd3 100644 --- a/src/app/preparer/manage/manage-preparer.component.ts +++ b/src/app/preparer/manage/manage-preparer.component.ts @@ -39,7 +39,7 @@ export class ManagePreparerComponent implements OnInit, OnDestroy, AfterViewInit isLoading = false; userPreferences: UserPreferences; - displayedColumns: string[] = ['name', 'address', 'city', 'state', 'country', 'carnetIssuingRegion', 'revenueLocation', 'actions']; + displayedColumns: string[] = ['name', 'address', 'city', 'state', 'country', 'industryType', 'carnetIssuingRegion', 'revenueLocation', 'actions']; dataSource = new MatTableDataSource([]); private destroy$ = new Subject(); diff --git a/src/app/service-provider/security-deposit/security-deposit.component.ts b/src/app/service-provider/security-deposit/security-deposit.component.ts index 3121b5e..d6cf92b 100644 --- a/src/app/service-provider/security-deposit/security-deposit.component.ts +++ b/src/app/service-provider/security-deposit/security-deposit.component.ts @@ -71,7 +71,7 @@ export class SecurityDepositComponent implements OnInit { holderType: ['CORP', Validators.required], uscibMember: ['Y', Validators.required], specialCommodity: [''], - specialCountry: ['US'], + specialCountry: [''], rate: [0, [Validators.required, Validators.min(0)]], effectiveDate: ['', Validators.required] }); @@ -145,7 +145,7 @@ export class SecurityDepositComponent implements OnInit { this.depositForm.reset({ holderType: 'CORP', uscibMember: 'N', - specialCountry: 'US', + specialCountry: '', }); this.depositForm.patchValue({ rate: 0 }); @@ -245,7 +245,7 @@ export class SecurityDepositComponent implements OnInit { this.depositForm.reset({ holderType: 'CORP', uscibMember: 'N', - specialCountry: 'US', + specialCountry: '', }); }