param and service provider updates

This commit is contained in:
Cyril Joseph 2025-08-15 22:34:20 -03:00
parent ac3e7165e5
commit 4bbbb8f1bc
19 changed files with 539 additions and 25 deletions

View File

@ -0,0 +1,6 @@
import { ParamProperties } from "./parameters";
export interface CountryMessage extends ParamProperties {
countryMessage: string | null;
isInactive: boolean;
}

View File

@ -5,18 +5,18 @@ export interface ParamProperties {
paramType: string; paramType: string;
paramDesc: string; paramDesc: string;
paramValue: string; paramValue: string;
addlParamValue1: string | null; addlParamValue1?: string | null;
addlParamValue2: string | null; addlParamValue2?: string | null;
addlParamValue3: string | null; addlParamValue3?: string | null;
addlParamValue4: string | null; addlParamValue4?: string | null;
addlParamValue5: string | null; addlParamValue5?: string | null;
sortSeq?: number; sortSeq?: number;
inactiveCodeFlag: 'Y' | 'N' | null; inactiveCodeFlag?: 'Y' | 'N' | null;
inactiveDate: string | null; inactiveDate?: string | null;
createdBy: string; createdBy?: string;
dateCreated: string; dateCreated?: string;
lastUpdatedBy: string | null; lastUpdatedBy?: string | null;
lastUpdatedDate: string | null; lastUpdatedDate?: string | null;
errorMesg: string | null; errorMesg?: string | null;
userId?: string; userId?: string;
} }

View File

@ -0,0 +1,4 @@
export interface ContactLogin {
spid: number;
emailAddress: string;
}

View File

@ -16,4 +16,5 @@ export interface Contact {
lastUpdatedDate?: Date | null; lastUpdatedDate?: Date | null;
isInactive?: boolean | null; isInactive?: boolean | null;
inactivatedDate?: Date | null; inactivatedDate?: Date | null;
hasLogin?: boolean | null;
} }

View File

@ -36,7 +36,12 @@ export class ApiErrorHandlerService {
return this.genericErrorMessage; return this.genericErrorMessage;
} }
return messageString.slice(0, -1); // slice off the last pipe character only if the last character is a pipe
if (messageString.endsWith('|')) {
return messageString.slice(0, -1);
}
return messageString;
// .split('|') // .split('|')
// .map(msg => msg.trim()) // .map(msg => msg.trim())
// .filter(msg => msg.length > 0); // .filter(msg => msg.length > 0);

View File

@ -42,7 +42,6 @@ export class ParamService {
lastUpdatedDate: paramValue.LASTUPDATEDDATE, lastUpdatedDate: paramValue.LASTUPDATEDDATE,
errorMesg: paramValue.ERRORMESG, errorMesg: paramValue.ERRORMESG,
})); }));
} }
createTableRecord(description: string): Observable<any> { createTableRecord(description: string): Observable<any> {

View File

@ -4,6 +4,7 @@ import { map, Observable } from 'rxjs';
import { environment } from '../../../../environments/environment'; import { environment } from '../../../../environments/environment';
import { Contact } from '../../models/service-provider/contact'; import { Contact } from '../../models/service-provider/contact';
import { UserService } from '../common/user.service'; import { UserService } from '../common/user.service';
import { ContactLogin } from '../../models/service-provider/contact-login';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -38,7 +39,8 @@ export class ContactService {
lastUpdatedBy: contact.LASTUPDATEDBY || null, lastUpdatedBy: contact.LASTUPDATEDBY || null,
lastUpdatedDate: contact.LASTUPDATEDDATE || null, lastUpdatedDate: contact.LASTUPDATEDDATE || null,
isInactive: contact.INACTIVEFLAG === 'Y' || false, isInactive: contact.INACTIVEFLAG === 'Y' || false,
inactivatedDate: contact.INACTIVEDATE || null inactivatedDate: contact.INACTIVEDATE || null,
hasLogin: contact.LOGINFLAG === 'Y' || false
})); }));
} }
@ -82,4 +84,18 @@ export class ContactService {
deleteContact(spContactId: string): Observable<any> { deleteContact(spContactId: string): Observable<any> {
return this.http.patch(`${this.apiUrl}/${this.apiDb}/InactivateSPContact/${spContactId}`, null); return this.http.patch(`${this.apiUrl}/${this.apiDb}/InactivateSPContact/${spContactId}`, null);
} }
createContactLogin(data: ContactLogin): Observable<any> {
const contact = {
P_SPID: data.spid,
P_EMAILADDR: data.emailAddress,
P_ENABLEPASSWORDPOLICY: 'Y',
P_DOMAIN: 'test',
P_LOOKUPCODE: 'test',
P_USERID: this.userService.getUser()
}
return this.http.post(`${this.apiUrl}/${this.apiDb}/CreateSPLogins`, contact);
}
} }

View File

@ -0,0 +1,81 @@
<h2 class="page-header">Manage Country Messages</h2>
<div class="manage-container">
<!-- Country Messages Form -->
<div class="form-container">
<form [formGroup]="countryForm" (ngSubmit)="saveRecord()">
<div class="form-row">
<mat-form-field appearance="outline">
<mat-label>Country</mat-label>
<mat-select (selectionChange)="onCountrySelectionChanged($event)">
<mat-option *ngFor="let country of countries" [value]="country.paramId">
{{ country.paramDesc }}
</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="form-row">
<mat-form-field appearance="outline">
<mat-label>Message</mat-label>
<textarea matInput formControlName="countryMessage" placeholder="Enter a message" rows="10"
required></textarea>
<mat-error *ngIf="countryForm.get('countryMessage')?.errors?.['required']">
Message is required
</mat-error>
</mat-form-field>
</div>
<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">
<label>Action Type</label>
<div class="readonly-value">
{{paramReadOnlyFields.actionType || 'N/A'}}
</div>
</div>
</div>
<div class="field-column">
<div class="readonly-field">
<label>Action </label>
<div class="readonly-value">
{{paramReadOnlyFields.action || 'N/A'}}
</div>
</div>
</div>
</div>
</div> -->
<div class="form-actions">
<button mat-raised-button color="primary" type="submit"
[disabled]="countryForm.invalid || changeInProgress">
Save
</button>
<button mat-raised-button color="primary" type="button" *ngIf="!currentCountry?.isInactive"
(click)="inActivateParamRecord()">Inactivate
Record</button>
<button mat-raised-button color="primary" type="button" *ngIf="currentCountry?.isInactive"
(click)="reActivateParamRecord()">Reactivate
Record</button>
</div>
</form>
</div>
</div>

View File

@ -0,0 +1,105 @@
.page-header {
margin: 0.5rem 0px;
color: var(--mat-sys-primary);
font-weight: 500;
}
.manage-container {
display: flex;
flex-direction: column;
gap: 0.5rem;
width: 100%;
}
.form-container {
margin-top: 0.5rem;
.form-header {
margin-bottom: 24px;
h3 {
margin: 0;
color: var(--mat-sys-primary);
font-weight: 500;
}
}
form {
display: flex;
flex-direction: column;
gap: 16px;
.form-row {
display: flex;
gap: 16px;
align-items: start;
mat-form-field {
flex: 1;
}
.small-field {
max-width: 120px;
}
}
.form-actions {
display: flex;
justify-content: flex-end;
gap: 16px;
margin-top: 16px;
}
.readonly-section {
padding-top: 0.5rem;
border-top: 1px solid #eee;
.readonly-fields {
display: flex;
gap: 2rem;
.field-column {
flex: 1;
display: flex;
flex-direction: column;
gap: 1.5rem;
}
}
.readonly-field {
label {
display: block;
font-size: 0.875rem;
color: #666;
margin-bottom: 0.25rem;
}
.readonly-value {
padding: 0.25rem;
font-size: 0.875rem;
display: flex;
align-items: center;
}
}
}
}
}
.results-section {
position: relative;
overflow: auto;
border-radius: 8px;
.loading-shade {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(255, 255, 255, 0.7);
z-index: 1;
display: flex;
align-items: center;
justify-content: center;
}
}

View File

@ -0,0 +1,258 @@
import { CommonModule } from '@angular/common';
import { Component, inject } from '@angular/core';
import { ReactiveFormsModule, FormGroup, Validators, FormBuilder } from '@angular/forms';
import { finalize, forkJoin } from 'rxjs';
import { ParamProperties } from '../../core/models/param/parameters';
import { ApiErrorHandlerService } from '../../core/services/common/api-error-handler.service';
import { NotificationService } from '../../core/services/common/notification.service';
import { ParamService } from '../../core/services/param/param.service';
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
import { MatSelectChange } from '@angular/material/select';
import { CountryMessage } from '../../core/models/param/country-message';
import { MatDialog } from '@angular/material/dialog';
import { ConfirmDialogComponent } from '../../shared/components/confirm-dialog/confirm-dialog.component';
@Component({
selector: 'app-manage-country',
imports: [AngularMaterialModule, CommonModule, ReactiveFormsModule],
templateUrl: './manage-country.component.html',
styleUrl: './manage-country.component.scss'
})
export class ManageCountryComponent {
isLoading: boolean = false;
changeInProgress: boolean = false;
countries: CountryMessage[] = [];
countriesWithMessages: ParamProperties[] = [];
currentCountryId: number = 0;
currentCountry: CountryMessage | undefined | null = null;
actionTypes: string[] = ['WARN', 'FYI', 'ACTION'];
private paramService = inject(ParamService);
private errorHandler = inject(ApiErrorHandlerService);
private notificationService = inject(NotificationService);
private fb = inject(FormBuilder);
private dialog = inject(MatDialog);
countryForm: FormGroup;
constructor() {
this.countryForm = this.initializeForm();
}
initializeForm(): FormGroup {
return this.fb.group({
countryMessage: ['', [Validators.required]],
actionType: [{ value: '' }],
action: [{ value: '', disabled: true }]
});
}
ngOnInit(): void {
this.getCountries();
}
onCountrySelectionChanged(event: MatSelectChange) {
this.renderCountry(+event.value);
}
renderCountry(countryid: number): void {
this.currentCountry = this.countries.find(c => c.paramId === countryid);
this.currentCountryId = this.countriesWithMessages.find(c => c.paramValue === this.currentCountry?.paramValue)?.paramId ?? 0;
this.patchCountryData();
}
onActionTypeSelectionChanged(event: MatSelectChange) {
if (event.value === 'ACTION') {
this.countryForm.get('action')?.setValue('TRANSIT');
}
}
getCountries(): void {
this.isLoading = true;
forkJoin({
countries: this.paramService.getParameters('002'),
countriesWithMessages: this.paramService.getParameters('014')
}).pipe(finalize(() => {
this.isLoading = false;
})).subscribe({
next: (results) => {
this.countries = this.joinCountriesWithMessages(results.countries, results.countriesWithMessages);
this.countriesWithMessages = results.countriesWithMessages;
if (this.currentCountry) {
this.renderCountry(this.currentCountry.paramId!);
}
},
error: (error) => {
console.error('Error loading countries messages data', error);
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load countries messages data');
this.notificationService.showError(errorMessage);
}
});
}
patchCountryData(): void {
if (!this.currentCountry) {
return;
}
this.countryForm.patchValue({
countryMessage: this.currentCountry.countryMessage,
actionType: this.currentCountry.addlParamValue1,
action: this.currentCountry.addlParamValue2
});
if (this.currentCountry.addlParamValue1 === 'ACTION') {
this.countryForm.get('action')?.setValue('TRANSIT');
} else {
this.countryForm.get('action')?.setValue('');
}
}
saveRecord(): void {
if (this.countryForm.invalid) {
this.countryForm.markAllAsTouched();
return;
}
const paramData: ParamProperties = {
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
};
const saveObservable = this.currentCountryId > 0
? this.paramService.updateParamRecord(paramData)
: this.paramService.createParamRecord(paramData);
this.changeInProgress = true;
saveObservable.pipe(finalize(() => {
this.changeInProgress = false;
})).subscribe({
next: () => {
this.notificationService.showSuccess(`Country message updated successfully`);
this.getCountries();
},
error: (error) => {
let errorMessage = this.errorHandler.handleApiError(error, `Failed to update country message`);
this.notificationService.showError(errorMessage);
console.error('Error saving country message:', error);
}
});
}
inActivateParamRecord(): void {
if (this.currentCountryId === 0) {
this.notificationService.showError('Not a valid country to inactivate');
return;
}
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
width: '350px',
data: {
title: 'Inactivate Country Message',
message: 'Are you sure you want to inactivate this message?',
confirmText: 'Yes',
cancelText: 'Cancel'
}
});
dialogRef.afterClosed().subscribe(result => {
if (result) {
this.paramService.inActivateParamRecord(this.currentCountryId).subscribe(
{
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`);
this.notificationService.showError(errorMessage);
console.error('Error inactivating country message:', error);
}
}
);
}
});
}
reActivateParamRecord(): void {
if (this.currentCountryId === 0) {
this.notificationService.showError('Not a valid country to reactivate');
return;
}
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
width: '350px',
data: {
title: 'Reactivate Country Message',
message: 'Are you sure you want to reactivate this message?',
confirmText: 'Yes',
cancelText: 'Cancel'
}
});
dialogRef.afterClosed().subscribe(result => {
if (result) {
this.paramService.reActivateParamRecord(this.currentCountryId).subscribe(
{
next: (data: any) => {
this.notificationService.showSuccess(`Country message reactivated successfully`)
this.getCountries();
},
error: (error: any) => {
let errorMessage = this.errorHandler.handleApiError(error, `Failed to reactivate country message`);
this.notificationService.showError(errorMessage);
console.error('Error reactivating country message:', error);
}
}
);
}
});
}
joinCountriesWithMessages(countries: ParamProperties[], countryMessages: ParamProperties[]): CountryMessage[] {
// Group messages by paramvalue
const messagesByCountry = countryMessages.reduce((acc, message) => {
if (!acc[message.paramValue]) {
acc[message.paramValue] = {
messages: [],
// paramId: message.paramId, // Store one paramid from messages
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;
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,
addlParamValue1: null,
addlParamValue2: null
};
return {
...country,
countryMessage: countryMessages.messages.join(' '),
isInactive: countryMessages.isInactive,
addlParamValue1: countryMessages.addlParamValue1,
addlParamValue2: countryMessages.addlParamValue2,
paramType: '014',
};
});
}
}

View File

@ -98,7 +98,7 @@ export class BasicFeeComponent {
renderRecods(): void { renderRecods(): void {
if (this.showExpiredRecords) { if (this.showExpiredRecords) {
this.dataSource.data = this.basicFees; this.dataSource.data = this.basicFees.filter(record => record.expired);
} else { } else {
this.dataSource.data = this.basicFees.filter(record => !record.expired); this.dataSource.data = this.basicFees.filter(record => !record.expired);
} }

View File

@ -1,5 +1,5 @@
.fee-commission-container { .fee-commission-container {
padding: 24px; padding: 0.5rem;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 24px; gap: 24px;

View File

@ -100,7 +100,7 @@ export class CarnetFeeComponent implements OnInit {
renderRecods(): void { renderRecods(): void {
if (this.showExpiredRecords) { if (this.showExpiredRecords) {
this.dataSource.data = this.carnetFees; this.dataSource.data = this.carnetFees.filter(record => record.expired);
} else { } else {
this.dataSource.data = this.carnetFees.filter(record => !record.expired); this.dataSource.data = this.carnetFees.filter(record => !record.expired);
} }

View File

@ -66,6 +66,11 @@
<button mat-icon-button color="primary" (click)="editContact(contact)" matTooltip="Edit"> <button mat-icon-button color="primary" (click)="editContact(contact)" matTooltip="Edit">
<mat-icon>edit</mat-icon> <mat-icon>edit</mat-icon>
</button> </button>
<button mat-icon-button color="primary" *ngIf="!contact.isInactive || !contact.hasLogin"
[hidden]="contact.isInactive || contact.hasLogin" (click)="createLogin(contact.email)"
matTooltip="Login">
<mat-icon>person</mat-icon>
</button>
<button mat-icon-button color="warn" *ngIf="!contact.defaultContact || !contact.isInactive" (click)=" <button mat-icon-button color="warn" *ngIf="!contact.defaultContact || !contact.isInactive" (click)="
deleteContact(contact.spContactId)" [hidden]="contact.defaultContact || contact.isInactive" deleteContact(contact.spContactId)" [hidden]="contact.defaultContact || contact.isInactive"
matTooltip="Delete"> matTooltip="Delete">

View File

@ -15,6 +15,7 @@ import { ApiErrorHandlerService } from '../../core/services/common/api-error-han
import { NotificationService } from '../../core/services/common/notification.service'; import { NotificationService } from '../../core/services/common/notification.service';
import { ContactService } from '../../core/services/service-provider/contact.service'; import { ContactService } from '../../core/services/service-provider/contact.service';
import { finalize } from 'rxjs'; import { finalize } from 'rxjs';
import { ContactLogin } from '../../core/models/service-provider/contact-login';
@Component({ @Component({
selector: 'app-contacts', selector: 'app-contacts',
@ -103,7 +104,7 @@ export class ContactsComponent implements OnInit {
renderContacts(): void { renderContacts(): void {
if (this.showInactiveContacts) { if (this.showInactiveContacts) {
this.dataSource.data = this.contacts; this.dataSource.data = this.contacts.filter(contact => contact.isInactive);
} else { } else {
this.dataSource.data = this.contacts.filter(contact => !contact.isInactive); this.dataSource.data = this.contacts.filter(contact => !contact.isInactive);
} }
@ -215,6 +216,39 @@ export class ContactsComponent implements OnInit {
this.contactForm.reset(); this.contactForm.reset();
} }
createLogin(emailAddress: string): void {
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
width: '450px',
data: {
title: 'Confirm Login Creation',
message: 'Are you sure you want to create a login for this contact?',
confirmText: 'Yes',
cancelText: 'Cancel'
}
});
dialogRef.afterClosed().subscribe(result => {
if (result) {
const contactLoginData: ContactLogin = {
spid: this.spid,
emailAddress: emailAddress
};
this.contactService.createContactLogin(contactLoginData).subscribe({
next: () => {
this.notificationService.showSuccess(`Login created successfully`);
this.loadContacts();
this.cancelEdit();
},
error: (error) => {
let errorMessage = this.errorHandler.handleApiError(error, `Failed to create login`);
this.notificationService.showError(errorMessage);
console.error('Error saving login:', error);
}
});
}
});
}
// setDefaultContact(contactId: string): void { // setDefaultContact(contactId: string): void {
// this.contactService.setDefaultServiceProviderContact(this.spid, contactId).subscribe({ // this.contactService.setDefaultServiceProviderContact(this.spid, contactId).subscribe({
// next: () => { // next: () => {

View File

@ -110,7 +110,7 @@ export class ContinuationSheetFeeComponent implements OnInit {
renderRecods(): void { renderRecods(): void {
if (this.showExpiredRecords) { if (this.showExpiredRecords) {
this.dataSource.data = this.continuationSheets; this.dataSource.data = this.continuationSheets.filter(record => record.expired);
} else { } else {
this.dataSource.data = this.continuationSheets.filter(record => !record.expired); this.dataSource.data = this.continuationSheets.filter(record => !record.expired);
} }

View File

@ -129,7 +129,7 @@ export class CounterfoilFeeComponent implements OnInit {
renderRecods(): void { renderRecods(): void {
if (this.showExpiredRecords) { if (this.showExpiredRecords) {
this.dataSource.data = this.counterfoilFees; this.dataSource.data = this.counterfoilFees.filter(record => record.expired);
} else { } else {
this.dataSource.data = this.counterfoilFees.filter(record => !record.expired); this.dataSource.data = this.counterfoilFees.filter(record => !record.expired);
} }

View File

@ -125,7 +125,7 @@ export class ExpeditedFeeComponent implements OnInit, OnDestroy {
renderRecods(): void { renderRecods(): void {
if (this.showExpiredRecords) { if (this.showExpiredRecords) {
this.dataSource.data = this.expeditedFees; this.dataSource.data = this.expeditedFees.filter(record => record.expired);
} else { } else {
this.dataSource.data = this.expeditedFees.filter(record => !record.expired); this.dataSource.data = this.expeditedFees.filter(record => !record.expired);
} }

View File

@ -90,7 +90,7 @@ export class SecurityDepositComponent implements OnInit {
loadSecurityDeposits(): void { loadSecurityDeposits(): void {
this.isLoading = true; this.isLoading = true;
this.securityDepositService.getSecurityDeposits(this.spid).pipe(finalize(() => { this.securityDepositService.getSecurityDeposits(this.spid).pipe(finalize(() => {
this.changeInProgress = false; this.isLoading = false;
})).subscribe({ })).subscribe({
next: (deposits) => { next: (deposits) => {
this.securityDeposits = deposits; this.securityDeposits = deposits;
@ -112,7 +112,7 @@ export class SecurityDepositComponent implements OnInit {
renderRecods(): void { renderRecods(): void {
if (this.showExpiredRecords) { if (this.showExpiredRecords) {
this.dataSource.data = this.securityDeposits; this.dataSource.data = this.securityDeposits.filter(record => record.expired);
} else { } else {
this.dataSource.data = this.securityDeposits.filter(record => !record.expired); this.dataSource.data = this.securityDeposits.filter(record => !record.expired);
} }