Skip to content

Commit

Permalink
prevent temp license holders from applying for BE license
Browse files Browse the repository at this point in the history
  • Loading branch information
juni-haukur committed Jun 19, 2024
1 parent 0ece477 commit ca0923b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
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 @@ -10,6 +10,7 @@ export type ConditionFn = (answer: FormValue) => boolean

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

export type DrivingLicense = {
Expand Down

0 comments on commit ca0923b

Please sign in to comment.