Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(driving-license): add pickup option to submit data for 65+ #16453

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
QualitySignatureResult,
NewBEDrivingLicenseInput,
DrivinglicenseDuplicateValidityStatus,
PostRenewal65AndOverInput,
} from './drivingLicense.type'
import {
CanApplyErrorCodeBFull,
Expand Down Expand Up @@ -513,8 +514,10 @@ export class DrivingLicenseService {

async renewDrivingLicense65AndOver(
auth: User['authorization'],
input: PostRenewal65AndOverInput,
): Promise<NewDrivingLicenseResult> {
const response = await this.drivingLicenseApi.postRenewLicenseOver65({
input,
auth: auth,
})
return {
Expand Down
11 changes: 11 additions & 0 deletions libs/api/domains/driving-license/src/lib/drivingLicense.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ export interface DrivingLicenseType {

export type DrivingLicenseApplicationType = 'B-full' | 'B-temp' | 'BE'

export interface PostRenewal65AndOverInput {
districtId?: number
pickupPlasticAtDistrict?: boolean | null
sendPlasticToPerson?: boolean | null
}

export enum Pickup {
'POST' = 'post',
'DISTRICT' = 'district',
}

export interface NewDrivingLicenseInput {
jurisdictionId: number
needsToPresentHealthCertificate: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
DrivingLicenseCategory,
DrivingLicenseService,
NewDrivingLicenseResult,
Pickup,
} from '@island.is/api/domains/driving-license'

import { SharedTemplateApiService } from '../../shared'
Expand Down Expand Up @@ -148,6 +149,7 @@ export class DrivingLicenseSubmissionService extends BaseTemplateApiService {
const jurisdictionId = answers.jurisdiction
const teacher = answers.drivingInstructor as string
const email = answers.email as string
const pickup = answers.pickup ? (answers.pickup as Pickup) : undefined
const phone = formatPhoneNumber(answers.phone as string)

const postHealthDeclaration = async (
Expand All @@ -173,6 +175,15 @@ export class DrivingLicenseSubmissionService extends BaseTemplateApiService {
if (applicationFor === 'B-full-renewal-65') {
return this.drivingLicenseService.renewDrivingLicense65AndOver(
auth.authorization.replace('Bearer ', ''),
{
...(jurisdictionId && { districtId: jurisdictionId as number }),
...(pickup
? {
pickupPlasticAtDistrict: pickup === Pickup.DISTRICT,
sendPlasticToPerson: pickup === Pickup.POST,
}
: {}),
},
)
} else if (applicationFor === 'B-full') {
return this.drivingLicenseService.newDrivingLicense(nationalId, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
} from '../../lib/utils'

import { Jurisdiction } from '@island.is/clients/driving-license'
import { B_FULL_RENEWAL_65, Pickup } from '../../lib/constants'
import { B_FULL_RENEWAL_65 } from '../../lib/constants'
import { Pickup } from '../../lib/types'

export const subSectionDelivery = buildSubSection({
id: 'user',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
BE,
CHARGE_ITEM_CODES,
DELIVERY_FEE,
Pickup,
YES,
} from '../../lib/constants'
import {
Expand All @@ -29,6 +28,7 @@ import {
needsHealthCertificateCondition,
} from '../../lib/utils'
import { formatPhoneNumber } from '@island.is/application/ui-components'
import { Pickup } from '../../lib/types'

export const subSectionSummary = buildSubSection({
id: 'overview',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ export const B_FULL_RENEWAL_65 = 'B-full-renewal-65'
export const BE = 'BE'
export const DELIVERY_FEE = 'deliveryFee'

export enum Pickup {
'POST' = 'post',
'DISTRICT' = 'district',
}

export const CHARGE_ITEM_CODES: Record<string, string> = {
[B_TEMP]: 'AY114',
[B_FULL]: 'AY110',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { z } from 'zod'
import { YES, NO, B_FULL_RENEWAL_65, BE, B_TEMP, B_FULL } from './constants'
import { parsePhoneNumberFromString } from 'libphonenumber-js'
import { Pickup } from './types'

const isValidPhoneNumber = (phoneNumber: string) => {
const phone = parsePhoneNumberFromString(phoneNumber, 'IS')
Expand All @@ -11,6 +12,7 @@ export const dataSchema = z.object({
type: z.array(z.enum(['car', 'trailer', 'motorcycle'])).nonempty(),
approveExternalData: z.boolean().refine((v) => v),
jurisdiction: z.string().min(1),
pickup: z.enum([Pickup.POST, Pickup.DISTRICT]).optional(),
healthDeclaration: z.object({
usesContactGlasses: z.enum([YES, NO]),
hasReducedPeripheralVision: z.enum([YES, NO]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {
B_FULL,
B_FULL_RENEWAL_65,
ApiActions,
Pickup,
CHARGE_ITEM_CODES,
DELIVERY_FEE,
} from './constants'
Expand All @@ -46,6 +45,7 @@ import { m } from './messages'
import { hasCompletedPrerequisitesStep } from './utils'
import { GlassesCheckApi, SyslumadurPaymentCatalogApi } from '../dataProviders'
import { buildPaymentState } from '@island.is/application/utils'
import { Pickup } from './types'

const getCodes = (application: Application) => {
const applicationFor = getValueViaPath<
Expand Down
5 changes: 5 additions & 0 deletions libs/application/templates/driving-license/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ export type HasQualityPhotoData = {
}
}

export enum Pickup {
'POST' = 'post',
'DISTRICT' = 'district',
}

export type ConditionFn = (answer: FormValue) => boolean

export type DrivingLicenseCategory = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,12 +509,16 @@ export class DrivingLicenseApi {
return handledResponse.success
}

async postRenewLicenseOver65(params: { auth: string }) {
async postRenewLicenseOver65(params: {
input: v5.PostRenewal65AndOver
auth: string
}) {
return await this.v5.apiDrivinglicenseV5ApplicationsRenewal65Post({
apiVersion: v5.DRIVING_LICENSE_API_VERSION_V5,
apiVersion2: v5.DRIVING_LICENSE_API_VERSION_V5,
jwttoken: params.auth,
postRenewal65AndOver: {
...params.input,
renewalDate: new Date(),
userId: v5.DRIVING_LICENSE_API_USER_ID,
},
Expand Down
10 changes: 10 additions & 0 deletions libs/clients/driving-license/src/v5/clientConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3649,6 +3649,16 @@
"type": "string",
"description": "Healt certificate",
"nullable": true
},
"pickupPlasticAtDistrict": {
"type": "boolean",
"description": "Will person pick plastic up at district",
"nullable": true
},
"sendPlasticToPerson": {
"type": "boolean",
"description": "Person requests plastic to be sent to him",
"nullable": true
}
},
"additionalProperties": false,
Expand Down
Loading