Skip to content

Commit

Permalink
fix(driving-license): Prevent temp license holders from applying for …
Browse files Browse the repository at this point in the history
…BE license (#15278)

* prevent temp license holders from applying for BE license

* update be license endpoint

* update text

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
juni-haukur and kodiakhq[bot] authored Jun 24, 2024
1 parent 92ff090 commit bc4b637
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
NewTemporaryDrivingLicenseInput,
ApplicationEligibilityRequirement,
QualitySignatureResult,
NewBEDrivingLicenseInput,
} from './drivingLicense.type'
import {
CanApplyErrorCodeBFull,
Expand Down Expand Up @@ -459,12 +460,15 @@ export class DrivingLicenseService {
async applyForBELicense(
nationalId: User['nationalId'],
auth: User['authorization'],
jurisdiction: number,
input: NewBEDrivingLicenseInput,
): Promise<NewDrivingLicenseResult> {
const response = await this.drivingLicenseApi.postApplyForBELicense({
nationalIdApplicant: nationalId,
token: auth,
jurisdictionId: jurisdiction,
jurisdictionId: input.jurisdiction,
instructorSSN: input.instructorSSN,
email: input.studentEmail,
phoneNumber: input.primaryPhoneNumber,
})

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ export interface NewTemporaryDrivingLicenseInput {
phone: string
}

export interface NewBEDrivingLicenseInput {
jurisdiction: number
instructorSSN: string
primaryPhoneNumber: string
studentEmail: string
}

export interface NewDrivingLicenseResult {
success: boolean
errorMessage: string | null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,21 @@ export class DrivingLicenseSubmissionService extends BaseTemplateApiService {
},
)
} else if (applicationFor === 'BE') {
const instructorSSN = getValueViaPath<string>(
answers,
'drivingInstructor',
)
const email = getValueViaPath<string>(answers, 'email')
const phone = getValueViaPath<string>(answers, 'phone')
return this.drivingLicenseService.applyForBELicense(
nationalId,
auth.authorization,
jurisdictionId as number,
{
jurisdiction: jurisdictionId as number,
instructorSSN: instructorSSN ?? '',
primaryPhoneNumber: phone ?? '',
studentEmail: email ?? '',
},
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,16 @@ export const sectionApplicationFor = (allowBELicense = false) =>
if (fakeData?.useFakeData === 'yes') {
currentLicense = fakeData.currentLicense ?? null
categories =
fakeData.currentLicense === 'full'
? [{ nr: 'B' }]
fakeData.currentLicense === 'temp'
? [{ nr: 'B', validToCode: 8 }]
: fakeData.currentLicense === 'full'
? [{ nr: 'B', validToCode: 9 }]
: fakeData.currentLicense === 'BE'
? [{ nr: 'B' }, { nr: 'BE' }]
: null
? [
{ nr: 'B', validToCode: 9 },
{ nr: 'BE', validToCode: 9 },
]
: []
}

let options = [
Expand Down Expand Up @@ -80,7 +85,10 @@ export const sectionApplicationFor = (allowBELicense = false) =>
!currentLicense ||
age < 18 ||
categories?.some((c) => c.nr.toUpperCase() === 'BE') ||
!categories?.some((c) => c.nr.toUpperCase() === 'B'),
// validToCode === 8 is temporary license and should not be applicable for BE
!categories?.some(
(c) => c.nr.toUpperCase() === 'B' && c.validToCode !== 8,
),
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ export const m = defineMessages({
},
applicationForBELicenseTitle: {
id: 'dl.application:applicationForBELicenseTitle',
defaultMessage: 'Kerruréttindi BE',
defaultMessage: 'Eftirvagn BE',
description: 'Option title for selecting to apply for trailer license',
},
applicationForBELicenseDescription: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type ConditionFn = (answer: FormValue) => boolean

export type DrivingLicenseCategory = {
nr: string
validToCode: number
}

export type DrivingLicense = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,9 @@ export class DrivingLicenseApi {
nationalIdApplicant: string
token: string
jurisdictionId: number
instructorSSN: string
phoneNumber: string
email: string
}): Promise<boolean> {
const response = await this.applicationV5.apiApplicationsV5ApplyforBePost({
apiVersion: v5.DRIVING_LICENSE_API_VERSION_V5,
Expand All @@ -488,6 +491,9 @@ export class DrivingLicenseApi {
postApplicationForBEModel: {
districtId: params.jurisdictionId,
userId: v5.DRIVING_LICENSE_API_USER_ID,
instructorSSN: params.instructorSSN,
primaryPhoneNumber: params.phoneNumber,
studentEmail: params.email,
},
})

Expand Down
25 changes: 25 additions & 0 deletions libs/clients/driving-license/src/v5/clientConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2987,6 +2987,11 @@
"type": "string",
"description": "Origin of creation",
"nullable": true
},
"districtId": {
"type": "integer",
"description": "District id",
"format": "int32"
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -3406,6 +3411,21 @@
"description": "UserId",
"nullable": true
},
"instructorSSN": {
"type": "string",
"description": "Driving instructor social security number",
"nullable": true
},
"primaryPhoneNumber": {
"type": "string",
"description": "Primary phone number",
"nullable": true
},
"studentEmail": {
"type": "string",
"description": "Student email",
"nullable": true
},
"districtId": {
"type": "integer",
"description": "Ordering district",
Expand Down Expand Up @@ -3850,6 +3870,11 @@
"type": "string",
"description": "Origin of creation",
"nullable": true
},
"districtId": {
"type": "integer",
"description": "District id",
"format": "int32"
}
},
"additionalProperties": false,
Expand Down

0 comments on commit bc4b637

Please sign in to comment.