feedback updates
This commit is contained in:
parent
2d78a2e7f4
commit
ba29cd99fb
@ -3,7 +3,7 @@
|
||||
<mat-spinner diameter="50"></mat-spinner>
|
||||
</div>
|
||||
|
||||
<form [formGroup]="shippingForm" (ngSubmit)="onSubmit()">
|
||||
<form [formGroup]="shippingForm" (ngSubmit)="onSubmit(false)">
|
||||
<!-- Insurance Section -->
|
||||
<div class="section">
|
||||
<h3>Insurance & Bond</h3>
|
||||
|
||||
@ -143,7 +143,7 @@ export class ShippingComponent {
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
onSubmit(): void {
|
||||
onSubmit(submitApp: boolean): void {
|
||||
if (this.shippingForm.invalid) {
|
||||
this.shippingForm.markAllAsTouched();
|
||||
return;
|
||||
@ -157,12 +157,23 @@ export class ShippingComponent {
|
||||
shippingData.contact = shippingData.shipTo === 'PREPARER' ? this.preparerContact ?? undefined : this.holderContact ?? undefined;
|
||||
}
|
||||
|
||||
if (this.holder?.holderType.trim() === 'GOV') {
|
||||
shippingData.formOfSecurity = this.govFormOfSecurities?.[0].value;
|
||||
}
|
||||
|
||||
this.shippingService.saveShippingDetails(this.headerid, shippingData).pipe(finalize(() => {
|
||||
this.changeInProgress = false;
|
||||
})).subscribe({
|
||||
next: () => {
|
||||
this.notificationService.showSuccess('Shipping & payments information saved successfully');
|
||||
this.completed.emit(true);
|
||||
|
||||
if (this.enableSubmitButton && this.headerid && submitApp) {
|
||||
let currentApplicationDetails = { headerid: this.headerid, applicationName: this.applicationName }
|
||||
this.storageService.set("currentapplication", currentApplicationDetails);
|
||||
|
||||
this.navigationService.navigate(["terms"])
|
||||
}
|
||||
},
|
||||
error: (error) => {
|
||||
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to save shipping and payment information');
|
||||
@ -678,12 +689,7 @@ export class ShippingComponent {
|
||||
}
|
||||
|
||||
submitApplication(): void {
|
||||
if (this.headerid) {
|
||||
let currentApplicationDetails = { headerid: this.headerid, applicationName: this.applicationName }
|
||||
this.storageService.set("currentapplication", currentApplicationDetails);
|
||||
}
|
||||
|
||||
this.navigationService.navigate(["terms"])
|
||||
this.onSubmit(true);
|
||||
}
|
||||
|
||||
returnToHome(): void {
|
||||
|
||||
@ -7,73 +7,10 @@
|
||||
<mat-divider></mat-divider>
|
||||
|
||||
<mat-card-content class="terms-content">
|
||||
<!-- Comprehensive Carnet Terms Content -->
|
||||
<h3>1. Definitions</h3>
|
||||
<p><strong>ATA Carnet:</strong> An international customs document that permits the tax-free and duty-free
|
||||
temporary export and import of goods for up to one year.</p>
|
||||
<p><strong>Holder:</strong> The individual or entity in whose name the carnet is issued and who is
|
||||
responsible for complying with all terms.</p>
|
||||
<p><strong>Goods:</strong> Merchandise, equipment, or products covered by the carnet.</p>
|
||||
|
||||
<h3>2. Carnet Usage</h3>
|
||||
<p>2.1 The carnet may be used for:</p>
|
||||
<p>Agreement language will go here</p>
|
||||
<h3>Fees and Charges</h3>
|
||||
<p> The following fees apply:</p>
|
||||
<ul>
|
||||
<li>Commercial samples</li>
|
||||
<li>Professional equipment</li>
|
||||
<li>Goods for exhibitions and fairs</li>
|
||||
<li>Goods for scientific, educational, or cultural purposes</li>
|
||||
</ul>
|
||||
|
||||
<p>2.2 The carnet cannot be used for:</p>
|
||||
<ul>
|
||||
<li>Consumable or disposable items</li>
|
||||
<li>Goods for processing or repair</li>
|
||||
<li>Goods intended for sale or permanent export</li>
|
||||
<li>Prohibited or restricted items under any applicable laws</li>
|
||||
</ul>
|
||||
|
||||
<h3>3. Holder Responsibilities</h3>
|
||||
<p>3.1 The holder must:</p>
|
||||
<ul>
|
||||
<li>Present the carnet to customs when crossing borders</li>
|
||||
<li>Ensure all goods listed in the carnet are returned by the expiration date</li>
|
||||
<li>Pay all applicable duties and taxes if goods are not re-exported</li>
|
||||
<li>Notify the issuing association immediately of any lost or stolen carnets</li>
|
||||
</ul>
|
||||
|
||||
<h3>4. Validity Period</h3>
|
||||
<p>4.1 The carnet is valid for one year from the date of issue.</p>
|
||||
<p>4.2 Goods must be re-exported before the carnet expires.</p>
|
||||
<p>4.3 Extensions may be granted in exceptional circumstances with approval from all relevant customs
|
||||
authorities.</p>
|
||||
|
||||
<h3>5. Customs Procedures</h3>
|
||||
<p>5.1 The holder must present the carnet to customs:</p>
|
||||
<ul>
|
||||
<li>When first exporting goods from the home country</li>
|
||||
<li>When entering each foreign country</li>
|
||||
<li>When re-exporting goods from each foreign country</li>
|
||||
<li>When finally re-importing goods to the home country</li>
|
||||
</ul>
|
||||
|
||||
<h3>6. Security Requirements</h3>
|
||||
<p>6.1 The issuing association may require security up to 40% of the total value of goods.</p>
|
||||
<p>6.2 Security will be refunded when the carnet is fully discharged.</p>
|
||||
<p>6.3 The security may be forfeited if terms are violated.</p>
|
||||
|
||||
<h3>7. Liability and Insurance</h3>
|
||||
<p>7.1 The holder is solely responsible for:</p>
|
||||
<ul>
|
||||
<li>All customs duties and taxes if goods are not re-exported</li>
|
||||
<li>Any damage to goods while in transit</li>
|
||||
<li>Compliance with all import/export regulations</li>
|
||||
</ul>
|
||||
<p>7.2 We recommend obtaining comprehensive insurance coverage for all goods.</p>
|
||||
|
||||
<h3>8. Fees and Charges</h3>
|
||||
<p>8.1 The following fees apply:</p>
|
||||
<ul>
|
||||
|
||||
<li *ngIf="estimatedFees.basicFee">Basic fee: {{estimatedFees.basicFee | currency}}</li>
|
||||
<li *ngIf="estimatedFees.counterFoilFee">Counterfoil Fee: {{estimatedFees.counterFoilFee | currency}}
|
||||
</li>
|
||||
@ -85,15 +22,6 @@
|
||||
<li *ngIf="estimatedFees.cargoPremium">Cargo Premium: {{estimatedFees.cargoPremium | currency}}</li>
|
||||
<li *ngIf="estimatedFees.ldiPremium">LDI Premium: {{estimatedFees.ldiPremium | currency}}</li>
|
||||
</ul>
|
||||
|
||||
<h3>9. Dispute Resolution</h3>
|
||||
<p>9.1 Any disputes shall be resolved through arbitration in the jurisdiction of the issuing association.
|
||||
</p>
|
||||
<p>9.2 The holder agrees to be bound by the arbitration decision.</p>
|
||||
|
||||
<h3>10. Governing Law</h3>
|
||||
<p>These terms shall be governed by the laws of the country where the carnet was issued.</p>
|
||||
|
||||
<mat-checkbox [(ngModel)]="hasReadAllTerms" color="primary" class="read-checkbox">
|
||||
I have read and agree to all terms and conditions above
|
||||
</mat-checkbox>
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
<span>{{ userEmail }}</span>
|
||||
</div>
|
||||
|
||||
<button mat-menu-item (click)="navigateTo('/usersettings')">
|
||||
<button mat-menu-item (click)="navigateTo('usersettings')">
|
||||
<mat-icon>settings</mat-icon>
|
||||
<span>User Preferences</span>
|
||||
</button>
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
export interface HolderFilter {
|
||||
holderName?: string;
|
||||
holderId?: number;
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ export class TravelPlanService {
|
||||
private userService = inject(UserService);
|
||||
|
||||
getCountriesAndMessages(): Observable<Country[]> {
|
||||
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetCountriesAndMessages`).pipe(
|
||||
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetCountriesAndMessages/${this.userService.getUserSpid()}`).pipe(
|
||||
map((response) =>
|
||||
response.map((item) => ({
|
||||
name: item.COUNTRYNAME,
|
||||
|
||||
@ -17,7 +17,17 @@ export class HolderService {
|
||||
private userService = inject(UserService);
|
||||
|
||||
getHolders(filter: HolderFilter): Observable<BasicDetail[]> {
|
||||
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/SearchHolder/${this.userService.getUserSpid()}/${this.userService.getSafeUser()}?P_HOLDERNAME=${filter.holderName}`).pipe(
|
||||
|
||||
// add query parameters to the URL based on the filter
|
||||
let queryParams = ``;
|
||||
if (filter.holderName) {
|
||||
queryParams += `P_HOLDERNAME=${filter.holderName}`;
|
||||
}
|
||||
if (filter.holderId) {
|
||||
queryParams += `P_HOLDERID=${filter.holderId}`;
|
||||
}
|
||||
|
||||
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/SearchHolder/${this.userService.getUserSpid()}/${this.userService.getSafeUser()}?${queryParams}`).pipe(
|
||||
map(response => this.mapToHolders(response))
|
||||
)
|
||||
}
|
||||
|
||||
@ -60,11 +60,29 @@ export class HomeService {
|
||||
return this.http.patch(`${this.apiUrl}/${this.apiDb}/ResetCarnet`, data);
|
||||
}
|
||||
|
||||
printCarnet(headerid: number): Observable<any> {
|
||||
voidCarnet(headerid: number): Observable<any> {
|
||||
const data = {
|
||||
P_USERID: this.userService.getUser(),
|
||||
P_HEADERID: headerid
|
||||
}
|
||||
return this.http.patch(`${this.apiUrl}/${this.apiDb}/UpdatePrintCarnet`, data);
|
||||
return this.http.patch(`${this.apiUrl}/${this.apiDb}/VoidCarnet`, data);
|
||||
}
|
||||
|
||||
printCarnet(headerid: number): Observable<any> {
|
||||
const data = {
|
||||
P_SPID: this.userService.getUserSpid(),
|
||||
P_HEADERID: headerid,
|
||||
P_PRINTGL: 'N'
|
||||
}
|
||||
return this.http.post(`${this.apiUrl}/${this.apiDb}/PrintCarnet`, data);
|
||||
}
|
||||
|
||||
printGeneralList(headerid: number): Observable<any> {
|
||||
const data = {
|
||||
P_SPID: this.userService.getUserSpid(),
|
||||
P_HEADERID: headerid,
|
||||
P_PRINTGL: 'Y'
|
||||
}
|
||||
return this.http.post(`${this.apiUrl}/${this.apiDb}/PrintCarnet`, data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<div class="manage-holder-container">
|
||||
<h3 class="page-header">Search Holders</h3>
|
||||
<div class="search-section">
|
||||
<h3 class="page-header" *ngIf="allowActions">Search Holders</h3>
|
||||
<div class="search-section" *ngIf="allowActions">
|
||||
<form class="search-form" [formGroup]="searchForm" (ngSubmit)="onSearch()">
|
||||
<div class="search-fields">
|
||||
<div class="form-row">
|
||||
@ -22,7 +22,7 @@
|
||||
Clear Search
|
||||
</button>
|
||||
|
||||
<button mat-raised-button color="primary" *ngIf="!isViewMode" (click)="addNewHolder()">
|
||||
<button mat-raised-button color="primary" (click)="addNewHolder()">
|
||||
<mat-icon>add</mat-icon>
|
||||
Add New Holder
|
||||
</button>
|
||||
@ -35,7 +35,7 @@
|
||||
<mat-spinner diameter="50"></mat-spinner>
|
||||
</div>
|
||||
|
||||
<div class="actions-bar">
|
||||
<div class="actions-bar" *ngIf="allowActions">
|
||||
<mat-slide-toggle (change)="toggleShowInactiveHolders()" [disabled]="holders.length === 0">
|
||||
Show Inactive Holders
|
||||
</mat-slide-toggle>
|
||||
@ -78,7 +78,7 @@
|
||||
|
||||
<div class="actions-icons">
|
||||
<mat-radio-button matTooltip="Select Holder" class="selectHolder" [value]="holder.holderid"
|
||||
[checked]="selectedHolderId === holder.holderid" *ngIf="!isViewMode"
|
||||
[checked]="selectedHolderId === holder.holderid" *ngIf="allowActions"
|
||||
(change)="onHolderSelection(holder)" aria-label="Select row" [hidden]="holder.isInactive">
|
||||
</mat-radio-button>
|
||||
|
||||
@ -87,11 +87,11 @@
|
||||
<mat-icon>edit</mat-icon>
|
||||
</button>
|
||||
|
||||
<button mat-icon-button color="warn" *ngIf="!holder.isInactive && !isViewMode"
|
||||
<button mat-icon-button color="warn" *ngIf="!holder.isInactive && allowActions"
|
||||
matTooltip="Inactivate" (click)="inactivateHolder(holder.holderid)">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button color="warn" *ngIf="holder.isInactive && !isViewMode"
|
||||
<button mat-icon-button color="warn" *ngIf="holder.isInactive && allowActions"
|
||||
matTooltip="Reactivate" (click)="reactivateHolder(holder.holderid)">
|
||||
<mat-icon>loupe</mat-icon>
|
||||
</button>
|
||||
|
||||
@ -19,6 +19,7 @@ import { ConfirmDialogComponent } from '../../shared/components/confirm-dialog/c
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { StorageService } from '../../core/services/common/storage.service';
|
||||
import { finalize } from 'rxjs';
|
||||
import { environment } from '../../../environments/environment';
|
||||
|
||||
@Component({
|
||||
selector: 'app-holder-search',
|
||||
@ -51,6 +52,8 @@ export class SearchHolderComponent {
|
||||
|
||||
@Output() holderSelectionCompleted = new EventEmitter<boolean>();
|
||||
|
||||
allowActions: boolean = environment.appType === 'client' && !this.isViewMode;
|
||||
|
||||
showInactiveHolders: boolean = false;
|
||||
holders: BasicDetail[] = []
|
||||
isLoading: boolean = false;
|
||||
@ -91,14 +94,24 @@ export class SearchHolderComponent {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.searchHolders();
|
||||
if (this.allowActions) {
|
||||
this.searchHolders();
|
||||
}
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes['selectedHolderId'] && this.paginator) {
|
||||
if (this.selectedHolderId && this.dataSource.data.length) {
|
||||
if (changes['selectedHolderId']) {
|
||||
if (this.selectedHolderId && this.paginator && this.dataSource.data.length && this.allowActions) {
|
||||
this.goToItemPage(this.selectedHolderId);
|
||||
}
|
||||
|
||||
if (!this.allowActions && this.selectedHolderId) {
|
||||
this.showSelectedHolder(this.selectedHolderId);
|
||||
}
|
||||
}
|
||||
|
||||
if (changes['isViewMode'] && this.isViewMode) {
|
||||
this.allowActions = environment.appType === 'client' && !this.isViewMode;
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,6 +143,27 @@ export class SearchHolderComponent {
|
||||
this.renderHolders();
|
||||
}
|
||||
|
||||
showSelectedHolder(holderid: number): void {
|
||||
this.isLoading = true;
|
||||
const filterData: HolderFilter = {
|
||||
holderId: holderid
|
||||
}
|
||||
|
||||
this.holderService.getHolders(filterData).pipe(finalize(() => {
|
||||
this.isLoading = false;
|
||||
})).subscribe({
|
||||
next: (holders: BasicDetail[]) => {
|
||||
this.dataSource.data = this.holders = holders;
|
||||
this.renderHolders()
|
||||
},
|
||||
error: (error: any) => {
|
||||
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load selected holder');
|
||||
this.notificationService.showError(errorMessage);
|
||||
console.error('Error loading selected holder:', error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
searchHolders(): void {
|
||||
this.isLoading = true;
|
||||
const filterData: HolderFilter = this.searchForm.value;
|
||||
|
||||
@ -93,10 +93,7 @@
|
||||
matTooltip="Process">
|
||||
<mat-icon>pending_actions</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button color="primary" (click)="viewCarnet(item)"
|
||||
*ngIf="getCarnetStatusLabel(item.carnetStatus) === 'Submitted'"
|
||||
[hidden]="getCarnetStatusLabel(item.carnetStatus) !== 'Submitted'"
|
||||
matTooltip="View">
|
||||
<button mat-icon-button color="primary" (click)="viewCarnet(item)" matTooltip="View">
|
||||
<mat-icon>article</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button color="primary" (click)="resetClient(item.headerid)"
|
||||
@ -105,18 +102,22 @@
|
||||
matTooltip="Reset to Client">
|
||||
<mat-icon>assignment_return</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button color="primary" (click)="deleteCarnet(item.headerid)"
|
||||
*ngIf="getCarnetStatusLabel(item.carnetStatus) === 'Submitted'"
|
||||
[hidden]="getCarnetStatusLabel(item.carnetStatus) !== 'Submitted'"
|
||||
matTooltip="Delete">
|
||||
<button mat-icon-button color="primary" (click)="deleteCarnet(item.headerid)" *ngIf="getCarnetStatusLabel(item.carnetStatus) === 'Submitted' ||
|
||||
getCarnetStatusLabel(item.carnetStatus) === 'Not Submitted'" matTooltip="Delete">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button color="primary" (click)="printCarnet(item.headerid)"
|
||||
*ngIf="getCarnetStatusLabel(item.carnetStatus) === 'Submitted'"
|
||||
[hidden]="getCarnetStatusLabel(item.carnetStatus) !== 'Submitted'"
|
||||
matTooltip="Print">
|
||||
<button mat-icon-button color="primary" (click)="printGeneralList(item.headerid)"
|
||||
matTooltip="Print General List">
|
||||
<mat-icon>print</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button color="primary" (click)="printCarnet(item.headerid)"
|
||||
*ngIf="getCarnetStatusLabel(item.carnetStatus) === 'Valid'" matTooltip="Print">
|
||||
<mat-icon>print</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button color="primary" (click)="voidCarnet(item.headerid)"
|
||||
*ngIf="getCarnetStatusLabel(item.carnetStatus) === 'Valid'" matTooltip="Void">
|
||||
<mat-icon>delete_forever</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
@ -211,6 +211,23 @@ export class HomeComponent {
|
||||
}
|
||||
}
|
||||
|
||||
printGeneralList(headerId: number): void {
|
||||
if (headerId) {
|
||||
this.homeService.printGeneralList(headerId).subscribe({
|
||||
next: () => {
|
||||
|
||||
},
|
||||
error: (error) => {
|
||||
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to print general list');
|
||||
this.notificationService.showError(errorMessage);
|
||||
console.error('Error printing general list:', error);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.notificationService.showError('Invalid carnet data');
|
||||
}
|
||||
}
|
||||
|
||||
deleteCarnet(headerId: number): void {
|
||||
if (headerId) {
|
||||
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
||||
@ -275,6 +292,38 @@ export class HomeComponent {
|
||||
}
|
||||
}
|
||||
|
||||
voidCarnet(headerId: number): void {
|
||||
if (headerId) {
|
||||
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
||||
width: '350px',
|
||||
data: {
|
||||
title: 'Void Carnet',
|
||||
message: 'Are you sure you want to void the carnet?',
|
||||
confirmText: 'Yes',
|
||||
cancelText: 'Cancel'
|
||||
}
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe(result => {
|
||||
if (result) {
|
||||
this.homeService.voidCarnet(headerId).subscribe({
|
||||
next: () => {
|
||||
this.notificationService.showSuccess('Carnet voided successfully');
|
||||
this.loadCarnetData();
|
||||
},
|
||||
error: (error) => {
|
||||
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to void carnet');
|
||||
this.notificationService.showError(errorMessage);
|
||||
console.error('Error void carnet:', error);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.notificationService.showError('Invalid carnet data');
|
||||
}
|
||||
}
|
||||
|
||||
navigateTo(route: any[], extras?: any): void {
|
||||
this.navigationService.navigate(route, extras);
|
||||
}
|
||||
|
||||
@ -25,7 +25,24 @@
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="readonly-section top-divider">
|
||||
|
||||
<div class="form-row">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Type of Action</mat-label>
|
||||
<mat-select (selectionChange)="onActionTypeSelectionChanged($event)" formControlName="actionType">
|
||||
<mat-option *ngFor="let actionType of actionTypes" [value]="actionType">
|
||||
{{ actionType }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Action </mat-label>
|
||||
<input matInput formControlName="action">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
<!-- <div class="readonly-section top-divider">
|
||||
<div class="readonly-fields">
|
||||
<div class="field-column">
|
||||
<div class="readonly-field">
|
||||
@ -44,7 +61,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="form-actions">
|
||||
<button mat-raised-button color="primary" type="submit"
|
||||
|
||||
@ -25,6 +25,7 @@ export class ManageCountryComponent {
|
||||
countriesWithMessages: ParamProperties[] = [];
|
||||
currentCountryId: number = 0;
|
||||
currentCountry: CountryMessage | undefined | null = null;
|
||||
actionTypes: string[] = ['WARN', 'FYI', 'ACTION'];
|
||||
|
||||
private paramService = inject(ParamService);
|
||||
private errorHandler = inject(ApiErrorHandlerService);
|
||||
@ -34,18 +35,15 @@ export class ManageCountryComponent {
|
||||
|
||||
countryForm: FormGroup;
|
||||
|
||||
paramReadOnlyFields: any = {
|
||||
actionType: null,
|
||||
action: null
|
||||
};
|
||||
|
||||
constructor() {
|
||||
this.countryForm = this.initializeForm();
|
||||
}
|
||||
|
||||
initializeForm(): FormGroup {
|
||||
return this.fb.group({
|
||||
countryMessage: ['', [Validators.required]]
|
||||
countryMessage: ['', [Validators.required]],
|
||||
actionType: [{ value: '' }],
|
||||
action: [{ value: '', disabled: true }]
|
||||
});
|
||||
}
|
||||
|
||||
@ -62,6 +60,12 @@ export class ManageCountryComponent {
|
||||
this.patchCountryData();
|
||||
}
|
||||
|
||||
onActionTypeSelectionChanged(event: MatSelectChange) {
|
||||
if (event.value === 'ACTION') {
|
||||
this.countryForm.get('action')?.setValue('TRANSIT');
|
||||
}
|
||||
}
|
||||
|
||||
getCountries(): void {
|
||||
this.isLoading = true;
|
||||
|
||||
@ -89,11 +93,16 @@ export class ManageCountryComponent {
|
||||
}
|
||||
|
||||
this.countryForm.patchValue({
|
||||
countryMessage: this.currentCountry.countryMessage
|
||||
countryMessage: this.currentCountry.countryMessage,
|
||||
actionType: this.currentCountry.addlParamValue1,
|
||||
action: this.currentCountry.addlParamValue2
|
||||
});
|
||||
|
||||
this.paramReadOnlyFields.actionType = this.currentCountry.addlParamValue1;
|
||||
this.paramReadOnlyFields.action = this.currentCountry.addlParamValue2;
|
||||
if (this.currentCountry.addlParamValue1 === 'ACTION') {
|
||||
this.countryForm.get('action')?.setValue('TRANSIT');
|
||||
} else {
|
||||
this.countryForm.get('action')?.setValue('');
|
||||
}
|
||||
}
|
||||
|
||||
saveRecord(): void {
|
||||
@ -106,6 +115,8 @@ export class ManageCountryComponent {
|
||||
paramDesc: this.countryForm.value.countryMessage,
|
||||
paramType: '014',
|
||||
paramValue: this.currentCountry?.paramValue ?? '',
|
||||
addlParamValue1: this.countryForm.value.actionType,
|
||||
addlParamValue2: this.countryForm.value.actionType === 'ACTION' ? 'TRANSIT' : null,
|
||||
sortSeq: 1,
|
||||
paramId: this.currentCountryId ?? 0
|
||||
};
|
||||
@ -152,6 +163,7 @@ export class ManageCountryComponent {
|
||||
{
|
||||
next: (data: any) => {
|
||||
this.notificationService.showSuccess(`Country message inactivated successfully`);
|
||||
this.getCountries();
|
||||
},
|
||||
error: (error: any) => {
|
||||
let errorMessage = this.errorHandler.handleApiError(error, `Failed to inactivate country message`);
|
||||
@ -184,7 +196,8 @@ export class ManageCountryComponent {
|
||||
this.paramService.reActivateParamRecord(this.currentCountryId).subscribe(
|
||||
{
|
||||
next: (data: any) => {
|
||||
this.notificationService.showSuccess(`Country message reactivated successfully`);
|
||||
this.notificationService.showSuccess(`Country message reactivated successfully`)
|
||||
this.getCountries();
|
||||
},
|
||||
error: (error: any) => {
|
||||
let errorMessage = this.errorHandler.handleApiError(error, `Failed to reactivate country message`);
|
||||
@ -204,27 +217,35 @@ export class ManageCountryComponent {
|
||||
acc[message.paramValue] = {
|
||||
messages: [],
|
||||
// paramId: message.paramId, // Store one paramid from messages
|
||||
isInactive: message.inactiveCodeFlag === 'N'
|
||||
isInactive: message.inactiveCodeFlag === 'N',
|
||||
addlParamValue1: message.addlParamValue1,
|
||||
addlParamValue2: message.addlParamValue2
|
||||
};
|
||||
}
|
||||
acc[message.paramValue].messages.push(message.paramDesc);
|
||||
return acc;
|
||||
}, {} as Record<string, {
|
||||
messages: string[]; //paramId?: number;
|
||||
isInactive: boolean
|
||||
isInactive: boolean;
|
||||
addlParamValue1?: string | null;
|
||||
addlParamValue2?: string | null;
|
||||
}>);
|
||||
|
||||
// Join countries with their messages
|
||||
return countries.map(country => {
|
||||
const countryMessages = messagesByCountry[country.paramValue] || {
|
||||
messages: [], //paramId: null,
|
||||
isInactive: false
|
||||
isInactive: false,
|
||||
addlParamValue1: null,
|
||||
addlParamValue2: null
|
||||
};
|
||||
|
||||
return {
|
||||
...country,
|
||||
countryMessage: countryMessages.messages.join(' '),
|
||||
isInactive: countryMessages.isInactive,
|
||||
addlParamValue1: countryMessages.addlParamValue1,
|
||||
addlParamValue2: countryMessages.addlParamValue2,
|
||||
paramType: '014',
|
||||
};
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user