Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE] SPDBT-3500 Fix licence lookup bug #2066

Merged
merged 6 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,7 @@ export class CommonApplicationService {
const selServiceTypeCodeDesc = this.optionsPipe.transform(serviceTypeCode, 'ServiceTypes');
if (licence) {
if (licence.serviceTypeCode !== serviceTypeCode) {
// ServiceTypeCode does not match
messageError = `This licence number is not a ${selServiceTypeCodeDesc}.`;
messageError = this.getLicenceLookupServiceTypeCodeMismatchErrorMessage(selServiceTypeCodeDesc);
} else {
if (!isExpired) {
const securityIndustryLicensingUrl = SPD_CONSTANTS.urls.securityIndustryLicensingUrl;
Expand All @@ -683,16 +682,27 @@ export class CommonApplicationService {
}
}
} else {
if (serviceTypeCode === ServiceTypeCode.SecurityBusinessLicence) {
messageError = `This ${selServiceTypeCodeDesc} number does not match any existing ${selServiceTypeCodeDesc}s for your business in BC.`;
} else {
messageError = `This ${selServiceTypeCodeDesc} number does not match any existing ${selServiceTypeCodeDesc}s.`;
}
messageError = this.getLicenceLookupNoMatchErrorMessage(serviceTypeCode, selServiceTypeCodeDesc);
}

return [messageWarn, messageError];
}

setLicenceLookupMessage(licence: LicenceResponse | null, serviceTypeCode: ServiceTypeCode): string | null {
let messageError = null;

const selServiceTypeCodeDesc = this.optionsPipe.transform(serviceTypeCode, 'ServiceTypes');
if (licence) {
if (licence.serviceTypeCode !== serviceTypeCode) {
messageError = this.getLicenceLookupServiceTypeCodeMismatchErrorMessage(selServiceTypeCodeDesc);
}
} else {
messageError = this.getLicenceLookupNoMatchErrorMessage(serviceTypeCode, selServiceTypeCodeDesc);
}

return messageError;
}

getApplicationIsInProgress(appls: Array<MainApplicationResponse>): boolean {
return !!appls.find(
(item: MainApplicationResponse) =>
Expand Down Expand Up @@ -872,6 +882,21 @@ export class CommonApplicationService {
}
}

private getLicenceLookupServiceTypeCodeMismatchErrorMessage(selServiceTypeCodeDesc: string): string {
return `This licence number is not a ${selServiceTypeCodeDesc}.`;
}

private getLicenceLookupNoMatchErrorMessage(
serviceTypeCode: ServiceTypeCode,
selServiceTypeCodeDesc: string
): string {
if (serviceTypeCode === ServiceTypeCode.SecurityBusinessLicence) {
return `This ${selServiceTypeCodeDesc} number does not match any existing ${selServiceTypeCodeDesc}s for your business in BC.`;
} else {
return `This ${selServiceTypeCodeDesc} number does not match any existing ${selServiceTypeCodeDesc}s.`;
}
}

private setApplicationFlags(item: MainApplicationResponse) {
const applicationNotSubmittedWarningDays = SPD_CONSTANTS.periods.applicationNotSubmittedWarningDays;
const applicationNotSubmittedErrorDays = SPD_CONSTANTS.periods.applicationNotSubmittedErrorDays;
Expand Down Expand Up @@ -906,7 +931,7 @@ export class CommonApplicationService {
isFoundValid = this.isLicenceActive(licence.licenceStatusCode);
}

const isExpired = !isFoundValid;
const isExpired = isFound && !isFoundValid;
const isInRenewalPeriod = !isFoundValid
? false
: this.getIsInRenewalPeriod(licence.expiryDate, licence.licenceTermCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ import { Component, ContentChild, ElementRef, Input } from '@angular/core';
export type AlertType = 'success' | 'warning' | 'danger' | 'info';

@Component({
selector: 'app-alert',
template: `
selector: 'app-alert',
template: `
<div class="alert d-flex d-inline-flex align-items-center w-100" role="alert" [ngClass]="getType()">
<mat-icon class="d-none d-lg-block alert-icon me-3" *ngIf="icon">{{ icon }}</mat-icon>
<div style="width: inherit;" class="my-2" [ngClass]="getText()">
<ng-content #alertContent> </ng-content>
</div>
</div>
`,
styles: [
`
styles: [
`
.alert-info {
border: 1px solid rgba(217, 234, 247, 1);
background-color: rgba(217, 234, 247, 1);
border: 1px solid #b6d4fe;
background-color: #d9eaf7;
border-radius: 5px;
font-weight: 500;
font-style: normal;
Expand All @@ -26,7 +26,7 @@ export type AlertType = 'success' | 'warning' | 'danger' | 'info';
}

.alert-success {
border: 1px solid #e8f5eb;
border: 1px solid #badbcc;
background-color: #e8f5eb;
border-radius: 5px;
font-weight: 500;
Expand All @@ -37,8 +37,8 @@ export type AlertType = 'success' | 'warning' | 'danger' | 'info';
}

.alert-warning {
border: 1px solid rgba(250, 235, 204, 1);
background-color: rgba(249, 241, 198, 1);
border: 1px solid #ffecb5;
background-color: #f9f1c6;
border-radius: 5px;
font-weight: 500;
font-style: normal;
Expand All @@ -48,8 +48,8 @@ export type AlertType = 'success' | 'warning' | 'danger' | 'info';
}

.alert-danger {
border: 1px solid rgba(235, 204, 209, 1);
background-color: rgba(242, 222, 222, 1);
border: 1px solid #f5c2c7;
background-color: #f2dede;
border-radius: 5px;
font-weight: 500;
font-style: normal;
Expand All @@ -58,8 +58,8 @@ export type AlertType = 'success' | 'warning' | 'danger' | 'info';
line-height: 1.5 !important;
}
`,
],
standalone: false
],
standalone: false,
})
export class AlertComponent {
@Input() public type: AlertType = 'warning';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,21 @@ export interface LookupByLicenceNumberDialogData {
}

@Component({
selector: 'app-modal-lookup-by-licence-number',
template: `
selector: 'app-modal-lookup-by-licence-number',
template: `
<div mat-dialog-title class="mat-dialog-title">{{ title }}</div>
<mat-dialog-content class="mat-dialog-content" class="pb-0">
<div class="fs-6 fw-normal pb-3" *ngIf="subtitle">{{ subtitle }}</div>
<form [formGroup]="form" novalidate>
<ng-container *ngIf="isLoggedIn; else notLoggedInMsg">
<app-alert type="info" icon="info"> Enter the Licence Number and click the search button. </app-alert>
</ng-container>
<ng-template #notLoggedInMsg>
<app-alert type="info" icon="info">
Enter the Licence Number, perform the reCaptcha and then click the search button.
</app-alert>
</ng-template>

<div class="row">
<div class="col-lg-12" [ngClass]="isLoggedIn ? 'col-xl-10' : 'col-xl-6'">
<mat-form-field>
Expand Down Expand Up @@ -68,17 +77,6 @@ export interface LookupByLicenceNumberDialogData {
</div>
</div>

<ng-container *ngIf="!isSearchPerformed">
<ng-container *ngIf="isLoggedIn; else notLoggedInMsg">
<app-alert type="info" icon="info"> Enter the Licence Number and click the search button. </app-alert>
</ng-container>
<ng-template #notLoggedInMsg>
<app-alert type="info" icon="info">
Enter the Licence Number, perform the reCaptcha and then click the search button.
</app-alert>
</ng-template>
</ng-container>

<ng-container *ngIf="isSearchPerformed">
<ng-container *ngIf="isFound; else IsNotFound">
<div *ngIf="isFoundValid" @showHideTriggerSlideAnimation>
Expand Down Expand Up @@ -122,7 +120,7 @@ export interface LookupByLicenceNumberDialogData {

<ng-template #LicenceSearchNotValid>
<div class="mt-3">
<app-alert type="warning" icon="">
<app-alert type="danger" icon="">
<div class="fs-5 mb-2">
This licence is not valid {{ lookupServiceTypeCode | options: 'ServiceTypes' }}
</div>
Expand Down Expand Up @@ -171,9 +169,9 @@ export interface LookupByLicenceNumberDialogData {
</div>
</mat-dialog-actions>
`,
styles: [],
animations: [showHideTriggerSlideAnimation],
standalone: false
styles: [],
animations: [showHideTriggerSlideAnimation],
standalone: false,
})
export class ModalLookupByLicenceNumberComponent implements OnInit {
form = this.businessApplicationService.swlLookupLicenceFormGroup;
Expand Down Expand Up @@ -274,17 +272,18 @@ export class ModalLookupByLicenceNumberComponent implements OnInit {
}

private handleSearchResults(resp: LicenceLookupResult) {
this.messageError = this.commonApplicationService.setLicenceLookupMessage(
resp.searchResult,
this.lookupServiceTypeCode
);

this.isSearchPerformed = true;
this.isFound = resp.isFound;
this.isFoundValid = resp.isFoundValid;
this.messageWarn = null;

if (resp.searchResult) {
if (resp.searchResult.serviceTypeCode !== this.lookupServiceTypeCode) {
this.isFoundValid = false;
}
this.searchResultDisplay = resp.searchResult;

this.searchResultDisplay = resp.searchResult;
}
this.isFoundValid = !!this.searchResultDisplay && !resp.isExpired && !this.messageError;
}

private handlexpiredLicenceSearchResults(resp: LicenceLookupResult) {
Expand Down
Loading