Skip to content

Commit 17b3f81

Browse files
[SPDBT-4370] New/Expired License Flow to ask for Access Code (#2843)
# Description This PR includes the following proposed change(s): - {List all the changes, if possible add the jira ticket #} Co-authored-by: Peggy <peggy.zhang@quartech.com>
1 parent 80d5cb7 commit 17b3f81

File tree

8 files changed

+435
-54
lines changed

8 files changed

+435
-54
lines changed

src/Spd.Presentation.Licensing/ClientApp/src/app/core/services/business-application.helper.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ export abstract class BusinessApplicationHelper extends CommonApplicationHelper
8181
}
8282
);
8383

84-
swlLookupLicenceFormGroup: FormGroup = this.formBuilder.group({
85-
licenceNumberLookup: new FormControl('', [FormControlValidators.required]),
86-
});
87-
8884
soleProprietorFormGroup: FormGroup = this.formBuilder.group({
8985
licenceNumberLookup: new FormControl('', [FormControlValidators.required]),
9086
});

src/Spd.Presentation.Licensing/ClientApp/src/app/core/services/common-application.service.ts

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Injectable } from '@angular/core';
2+
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
23
import { MatDialog } from '@angular/material/dialog';
34
import { Router } from '@angular/router';
45
import {
@@ -43,6 +44,7 @@ import { DialogComponent, DialogOptions } from '@app/shared/components/dialog.co
4344
import { OptionsPipe } from '@app/shared/pipes/options.pipe';
4445
import moment from 'moment';
4546
import { BehaviorSubject, Observable, forkJoin, map, of, switchMap } from 'rxjs';
47+
import { FormControlValidators } from '../validators/form-control.validators';
4648
import { AuthProcessService } from './auth-process.service';
4749
import { AuthUserBceidService } from './auth-user-bceid.service';
4850
import { AuthUserBcscService } from './auth-user-bcsc.service';
@@ -97,7 +99,20 @@ export class CommonApplicationService {
9799
'Security Services Application',
98100
]);
99101

102+
swlLookupLicenceFormGroup: FormGroup = this.formBuilder.group({
103+
licenceNumberLookup: new FormControl('', [FormControlValidators.required]),
104+
});
105+
106+
swlLookupLicenceAnonymousFormGroup: FormGroup = this.formBuilder.group({
107+
licenceNumberLookup: new FormControl('', [FormControlValidators.required]),
108+
accessCode: new FormControl('', [FormControlValidators.required]),
109+
captchaFormGroup: new FormGroup({
110+
token: new FormControl('', FormControlValidators.required),
111+
}),
112+
});
113+
100114
constructor(
115+
private formBuilder: FormBuilder,
101116
private router: Router,
102117
private dialog: MatDialog,
103118
private optionsPipe: OptionsPipe,
@@ -722,6 +737,21 @@ export class CommonApplicationService {
722737
);
723738
}
724739

740+
getLicenceNumberAccessCodeLookupAnonymous(
741+
licenceNumber: string,
742+
accessCode: string,
743+
recaptchaCode: string
744+
): Observable<LicenceLookupResult> {
745+
return this.licenceService
746+
.apiLicenceLookupAnonymousLicenceNumberPost({ licenceNumber, accessCode, body: { recaptchaCode } })
747+
.pipe(
748+
switchMap((resp: LicenceResponse) => {
749+
const lookupResp = this.getLicenceSearchFlags(resp);
750+
return of(lookupResp);
751+
})
752+
);
753+
}
754+
725755
getLicenceNumberLookup(licenceNumber: string): Observable<LicenceLookupResult> {
726756
return this.licenceService.apiLicenceLookupLicenceNumberGet({ licenceNumber }).pipe(
727757
switchMap((resp: LicenceResponse) => {
@@ -735,7 +765,8 @@ export class CommonApplicationService {
735765
licence: LicenceResponse | null,
736766
serviceTypeCode: ServiceTypeCode,
737767
isExpired: boolean,
738-
isInRenewalPeriod: boolean
768+
isInRenewalPeriod: boolean,
769+
useAccessCode: boolean = false
739770
): [string | null, string | null] {
740771
let messageWarn = null;
741772
let messageError = null;
@@ -755,21 +786,25 @@ export class CommonApplicationService {
755786
}
756787
}
757788
} else {
758-
messageError = this.getLicenceLookupNoMatchErrorMessage(serviceTypeCode);
789+
messageError = this.getLicenceLookupNoMatchErrorMessage(serviceTypeCode, useAccessCode);
759790
}
760791

761792
return [messageWarn, messageError];
762793
}
763794

764-
setLicenceLookupMessage(licence: LicenceResponse | null, serviceTypeCode: ServiceTypeCode): string | null {
795+
setLicenceLookupMessage(
796+
licence: LicenceResponse | null,
797+
serviceTypeCode: ServiceTypeCode,
798+
useAccessCode: boolean = false
799+
): string | null {
765800
let messageError = null;
766801

767802
if (licence) {
768803
if (licence.serviceTypeCode !== serviceTypeCode) {
769804
messageError = this.getLicenceLookupServiceTypeCodeMismatchErrorMessage(serviceTypeCode);
770805
}
771806
} else {
772-
messageError = this.getLicenceLookupNoMatchErrorMessage(serviceTypeCode);
807+
messageError = this.getLicenceLookupNoMatchErrorMessage(serviceTypeCode, useAccessCode);
773808
}
774809

775810
return messageError;
@@ -1004,9 +1039,16 @@ export class CommonApplicationService {
10041039
return `The ${typeLabel} number you entered is not a ${serviceTypeCodeDesc}.`;
10051040
}
10061041

1007-
private getLicenceLookupNoMatchErrorMessage(serviceTypeCode: ServiceTypeCode): string {
1042+
private getLicenceLookupNoMatchErrorMessage(
1043+
serviceTypeCode: ServiceTypeCode,
1044+
useAccessCode: boolean = false
1045+
): string {
10081046
const typeLabel = this.getLicenceTypeName(serviceTypeCode);
10091047

1048+
if (useAccessCode) {
1049+
return `This ${typeLabel} number and access code are not a valid combination.`;
1050+
}
1051+
10101052
if (serviceTypeCode === ServiceTypeCode.SecurityBusinessLicence) {
10111053
return `The ${typeLabel} number you entered does not match any existing records in our system for your business in BC.`;
10121054
} else {

src/Spd.Presentation.Licensing/ClientApp/src/app/modules/personal-licence-application/components/shared/worker-licence-wizard-step-components/step-worker-licence-expired.component.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, Input } from '@angular/core';
1+
import { Component, Input, OnInit } from '@angular/core';
22
import { FormGroup } from '@angular/forms';
33
import { ServiceTypeCode } from '@app/api/models';
44
import { SPD_CONSTANTS } from '@app/core/constants/constants';
@@ -25,14 +25,16 @@ import { WorkerApplicationService } from '@app/core/services/worker-application.
2525
[form]="form"
2626
[isLoggedIn]="isLoggedIn"
2727
[serviceTypeCode]="securityWorkerLicenceCode"
28+
[useAccessCode]="useAccessCode"
2829
></app-form-expired-licence>
2930
</app-step-section>
3031
`,
3132
styles: [],
3233
standalone: false,
3334
})
34-
export class StepWorkerLicenceExpiredComponent implements LicenceChildStepperStepComponent {
35+
export class StepWorkerLicenceExpiredComponent implements OnInit, LicenceChildStepperStepComponent {
3536
spdPhoneNumber = SPD_CONSTANTS.phone.spdPhoneNumber;
37+
useAccessCode!: boolean;
3638

3739
form: FormGroup = this.workerApplicationService.expiredLicenceFormGroup;
3840
securityWorkerLicenceCode = ServiceTypeCode.SecurityWorkerLicence;
@@ -41,6 +43,10 @@ export class StepWorkerLicenceExpiredComponent implements LicenceChildStepperSte
4143

4244
constructor(private workerApplicationService: WorkerApplicationService) {}
4345

46+
ngOnInit(): void {
47+
this.useAccessCode = !this.isLoggedIn;
48+
}
49+
4450
isFormValid(): boolean {
4551
this.form.markAllAsTouched();
4652
return this.form.valid;

src/Spd.Presentation.Licensing/ClientApp/src/app/shared/components/form-access-code-anonymous.component.ts

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -148,46 +148,15 @@ export class FormAccessCodeAnonymousComponent implements OnInit {
148148
return;
149149
}
150150

151-
switch (this.serviceTypeCode) {
152-
case ServiceTypeCode.SecurityWorkerLicence: {
153-
this.commonApplicationService
154-
.getLicenceWithAccessCodeAnonymous(licenceNumber, accessCode, recaptchaCode)
155-
.pipe(
156-
tap((resp: LicenceResponseExt | null) => {
157-
this.handleLookupResponse(resp);
158-
}),
159-
take(1)
160-
)
161-
.subscribe();
162-
break;
163-
}
164-
// SPDBT-3425 - Remove anonymous permit flows
165-
// case ServiceTypeCode.ArmouredVehiclePermit:
166-
// case ServiceTypeCode.BodyArmourPermit: {
167-
// this.commonApplicationService
168-
// .getLicenceWithAccessCodeAnonymous(licenceNumber, accessCode, recaptchaCode)
169-
// .pipe(
170-
// tap((resp: LicenceResponse) => {
171-
// this.handleLookupResponse(resp);
172-
// }),
173-
// take(1)
174-
// )
175-
// .subscribe();
176-
// break;
177-
// }
178-
case ServiceTypeCode.Mdra: {
179-
this.commonApplicationService
180-
.getLicenceWithAccessCodeAnonymous(licenceNumber, accessCode, recaptchaCode)
181-
.pipe(
182-
tap((resp: LicenceResponseExt | null) => {
183-
this.handleLookupResponse(resp);
184-
}),
185-
take(1)
186-
)
187-
.subscribe();
188-
break;
189-
}
190-
}
151+
this.commonApplicationService
152+
.getLicenceWithAccessCodeAnonymous(licenceNumber, accessCode, recaptchaCode)
153+
.pipe(
154+
tap((resp: LicenceResponseExt | null) => {
155+
this.handleLookupResponse(resp);
156+
}),
157+
take(1)
158+
)
159+
.subscribe();
191160
}
192161

193162
onCreateNewLicence(): void {

src/Spd.Presentation.Licensing/ClientApp/src/app/shared/components/form-expired-licence.component.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { BooleanTypeCode } from '@app/core/code-types/model-desc.models';
77
import { SPD_CONSTANTS } from '@app/core/constants/constants';
88
import { CommonApplicationService } from '@app/core/services/common-application.service';
99
import { OptionsPipe } from '@app/shared/pipes/options.pipe';
10+
import { ModalLookupByLicenceNumberAccessCodeComponent } from './modal-lookup-by-licence-number-access-code.component';
1011
import {
1112
LookupByLicenceNumberDialogData,
1213
ModalLookupByLicenceNumberComponent,
@@ -100,6 +101,7 @@ export class FormExpiredLicenceComponent implements OnInit {
100101
@Input() isLoggedIn!: boolean;
101102
@Input() form!: FormGroup;
102103
@Input() serviceTypeCode!: ServiceTypeCode;
104+
@Input() useAccessCode = false;
103105

104106
constructor(
105107
private dialog: MatDialog,
@@ -120,6 +122,32 @@ export class FormExpiredLicenceComponent implements OnInit {
120122
typeLabel: this.typeLabel,
121123
isLoggedIn: this.isLoggedIn,
122124
};
125+
126+
if (this.useAccessCode) {
127+
this.dialog
128+
.open(ModalLookupByLicenceNumberAccessCodeComponent, {
129+
width: '800px',
130+
data: dialogOptions,
131+
autoFocus: true,
132+
})
133+
.afterClosed()
134+
.subscribe((resp: any) => {
135+
if (resp?.data) {
136+
this.form.patchValue(
137+
{
138+
expiredLicenceId: resp.data.licenceId,
139+
expiredLicenceHolderName: resp.data.licenceHolderName,
140+
expiredLicenceNumber: resp.data.licenceNumber,
141+
expiredLicenceExpiryDate: resp.data.expiryDate,
142+
expiredLicenceStatusCode: resp.data.licenceStatusCode,
143+
},
144+
{ emitEvent: false }
145+
);
146+
}
147+
});
148+
return;
149+
}
150+
123151
this.dialog
124152
.open(ModalLookupByLicenceNumberComponent, {
125153
width: '800px',

0 commit comments

Comments
 (0)