Skip to content

Commit

Permalink
fix(driving-license-application): Name mapping and formatting (#8711)
Browse files Browse the repository at this point in the history
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
alexdiljar and kodiakhq[bot] authored Oct 17, 2022
1 parent 9131761 commit 78bbee6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const hasLocalResidence = (
({ dateOfChange: a }, { dateOfChange: b }) =>
compareDesc(new Date(a), new Date(b)),
)
return sorted[0].country === 'IS'
return sorted[0]?.country === 'IS' || false
}
return false
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { YES } from '../../lib/constants'
import { B_TEMP } from '../../shared/constants'
import {
hasNoDrivingLicenseInOtherCountry,
isApplicationForCondition,
needsHealthCertificateCondition,
} from '../../lib/utils'

Expand Down Expand Up @@ -46,7 +47,10 @@ export const subSectionSummary = buildSubSection({
}),
buildKeyValueField({
label: m.overviewSubType,
value: ({ answers: { subType } }) => subType as string[],
value: ({ answers: { applicationFor } }) =>
applicationFor === B_TEMP
? m.applicationForTempLicenseTitle
: m.applicationForFullLicenseTitle,
}),
buildDividerField({}),
buildKeyValueField({
Expand All @@ -55,62 +59,63 @@ export const subSectionSummary = buildSubSection({
value: ({ externalData: { nationalRegistry } }) =>
(nationalRegistry.data as NationalRegistryUser).fullName,
}),
buildKeyValueField({
label: m.overviewNationalId,
width: 'half',
value: ({ externalData: { nationalRegistry } }) =>
formatKennitala(
(nationalRegistry.data as NationalRegistryUser).nationalId,
),
}),
buildKeyValueField({
label: m.overviewPhoneNumber,
width: 'half',
condition: (answers) => !!answers?.phone,
value: ({ answers: { phone } }) => phone as string,
}),
buildKeyValueField({
label: m.overviewStreetAddress,
label: m.overviewEmail,
width: 'half',
value: ({ externalData: { nationalRegistry } }) =>
(nationalRegistry.data as NationalRegistryUser).address
?.streetAddress,
condition: (answers) => !!answers?.email,
value: ({ answers: { email } }) => email as string,
}),
buildKeyValueField({
label: m.overviewNationalId,
label: m.overviewStreetAddress,
width: 'half',
value: ({ externalData: { nationalRegistry } }) =>
formatKennitala(
(nationalRegistry.data as NationalRegistryUser).nationalId,
),
(nationalRegistry.data as NationalRegistryUser).address
?.streetAddress,
}),
buildKeyValueField({
label: m.overviewPostalCode,
width: 'half',
value: ({ externalData: { nationalRegistry } }) =>
(nationalRegistry.data as NationalRegistryUser).address?.postalCode,
}),
buildKeyValueField({
label: m.overviewEmail,
width: 'half',
value: ({ answers: { email } }) => email as string,
}),
buildKeyValueField({
label: m.overviewCity,
width: 'half',
value: ({ externalData: { nationalRegistry } }) =>
(nationalRegistry.data as NationalRegistryUser).address?.city,
}),
buildDividerField({}),
buildDividerField({
condition: isApplicationForCondition(B_TEMP),
}),
buildKeyValueField({
label: m.overviewTeacher,
width: 'half',
condition: isApplicationForCondition(B_TEMP),
value: ({
externalData: {
studentAssessment,
teachers: { data },
},
answers,
}) => {
if (answers.applicationFor === B_TEMP) {
const teacher = (data as Teacher[]).find(
({ nationalId }) =>
getValueViaPath(answers, 'drivingInstructor') === nationalId,
)
return teacher?.name
}
return (studentAssessment.data as StudentAssessment).teacherName
const teacher = (data as Teacher[]).find(
({ nationalId }) =>
getValueViaPath(answers, 'drivingInstructor') === nationalId,
)
return teacher?.name
},
}),
buildDividerField({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const isValidPhoneNumber = (phoneNumber: string) => {

export const dataSchema = z.object({
type: z.array(z.enum(['car', 'trailer', 'motorcycle'])).nonempty(),
subType: z.array(z.string()).nonempty(),
approveExternalData: z.boolean().refine((v) => v),
juristiction: z.string(),
healthDeclaration: z.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const get24HFormatTime = (value: string) => {
}
const { hours, minutes } = getHoursMinutes(value)

return `${hours}:${minutes}`
return `${hours}:${minutes > 10 ? minutes : '0' + minutes}`
}

const vskNrRegex = /([0-9]){6}/
Expand Down

0 comments on commit 78bbee6

Please sign in to comment.