1
1
import { Injectable } from '@angular/core' ;
2
+ import { FormBuilder , FormControl , FormGroup } from '@angular/forms' ;
2
3
import { MatDialog } from '@angular/material/dialog' ;
3
4
import { Router } from '@angular/router' ;
4
5
import {
@@ -43,6 +44,7 @@ import { DialogComponent, DialogOptions } from '@app/shared/components/dialog.co
43
44
import { OptionsPipe } from '@app/shared/pipes/options.pipe' ;
44
45
import moment from 'moment' ;
45
46
import { BehaviorSubject , Observable , forkJoin , map , of , switchMap } from 'rxjs' ;
47
+ import { FormControlValidators } from '../validators/form-control.validators' ;
46
48
import { AuthProcessService } from './auth-process.service' ;
47
49
import { AuthUserBceidService } from './auth-user-bceid.service' ;
48
50
import { AuthUserBcscService } from './auth-user-bcsc.service' ;
@@ -97,7 +99,20 @@ export class CommonApplicationService {
97
99
'Security Services Application' ,
98
100
] ) ;
99
101
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
+
100
114
constructor (
115
+ private formBuilder : FormBuilder ,
101
116
private router : Router ,
102
117
private dialog : MatDialog ,
103
118
private optionsPipe : OptionsPipe ,
@@ -722,6 +737,21 @@ export class CommonApplicationService {
722
737
) ;
723
738
}
724
739
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
+
725
755
getLicenceNumberLookup ( licenceNumber : string ) : Observable < LicenceLookupResult > {
726
756
return this . licenceService . apiLicenceLookupLicenceNumberGet ( { licenceNumber } ) . pipe (
727
757
switchMap ( ( resp : LicenceResponse ) => {
@@ -735,7 +765,8 @@ export class CommonApplicationService {
735
765
licence : LicenceResponse | null ,
736
766
serviceTypeCode : ServiceTypeCode ,
737
767
isExpired : boolean ,
738
- isInRenewalPeriod : boolean
768
+ isInRenewalPeriod : boolean ,
769
+ useAccessCode : boolean = false
739
770
) : [ string | null , string | null ] {
740
771
let messageWarn = null ;
741
772
let messageError = null ;
@@ -755,21 +786,25 @@ export class CommonApplicationService {
755
786
}
756
787
}
757
788
} else {
758
- messageError = this . getLicenceLookupNoMatchErrorMessage ( serviceTypeCode ) ;
789
+ messageError = this . getLicenceLookupNoMatchErrorMessage ( serviceTypeCode , useAccessCode ) ;
759
790
}
760
791
761
792
return [ messageWarn , messageError ] ;
762
793
}
763
794
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 {
765
800
let messageError = null ;
766
801
767
802
if ( licence ) {
768
803
if ( licence . serviceTypeCode !== serviceTypeCode ) {
769
804
messageError = this . getLicenceLookupServiceTypeCodeMismatchErrorMessage ( serviceTypeCode ) ;
770
805
}
771
806
} else {
772
- messageError = this . getLicenceLookupNoMatchErrorMessage ( serviceTypeCode ) ;
807
+ messageError = this . getLicenceLookupNoMatchErrorMessage ( serviceTypeCode , useAccessCode ) ;
773
808
}
774
809
775
810
return messageError ;
@@ -1004,9 +1039,16 @@ export class CommonApplicationService {
1004
1039
return `The ${ typeLabel } number you entered is not a ${ serviceTypeCodeDesc } .` ;
1005
1040
}
1006
1041
1007
- private getLicenceLookupNoMatchErrorMessage ( serviceTypeCode : ServiceTypeCode ) : string {
1042
+ private getLicenceLookupNoMatchErrorMessage (
1043
+ serviceTypeCode : ServiceTypeCode ,
1044
+ useAccessCode : boolean = false
1045
+ ) : string {
1008
1046
const typeLabel = this . getLicenceTypeName ( serviceTypeCode ) ;
1009
1047
1048
+ if ( useAccessCode ) {
1049
+ return `This ${ typeLabel } number and access code are not a valid combination.` ;
1050
+ }
1051
+
1010
1052
if ( serviceTypeCode === ServiceTypeCode . SecurityBusinessLicence ) {
1011
1053
return `The ${ typeLabel } number you entered does not match any existing records in our system for your business in BC.` ;
1012
1054
} else {
0 commit comments