From 38154ed30b45abd98834459d1243ab5ac5024be3 Mon Sep 17 00:00:00 2001 From: albinagu <47886428+albinagu@users.noreply.github.com> Date: Tue, 10 Sep 2024 14:21:24 +0000 Subject: [PATCH] fix(driving-license): hotfix/jurisdictionid back in dl (#15940) * fix(driving-license): digital license, no pickup (#15881) * fix(driving-license): digital license, no pickup * chore: nx format:write update dirty files --------- Co-authored-by: andes-it Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * fix(driving-license): adding back JurisdictionApi check (#15938) * fix(driving-license): adding back JurisdictionApi check * chore: nx format:write update dirty files --------- Co-authored-by: andes-it --------- Co-authored-by: andes-it Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../src/dataProviders/index.ts | 1 + .../driving-license/src/forms/draft/draft.ts | 2 + .../src/forms/draft/subSectionDelivery.ts | 51 +++++++++++++++++++ .../prerequisites/sectionExternalData.ts | 5 ++ .../src/lib/drivingLicenseTemplate.ts | 2 + .../driving-license/src/lib/messages.ts | 10 ++++ 6 files changed, 71 insertions(+) create mode 100644 libs/application/templates/driving-license/src/forms/draft/subSectionDelivery.ts diff --git a/libs/application/templates/driving-license/src/dataProviders/index.ts b/libs/application/templates/driving-license/src/dataProviders/index.ts index fe90c3829b53..c6d5f3243fa1 100644 --- a/libs/application/templates/driving-license/src/dataProviders/index.ts +++ b/libs/application/templates/driving-license/src/dataProviders/index.ts @@ -9,6 +9,7 @@ export { UserProfileApi, CurrentLicenseApi, DrivingAssessmentApi, + JurisdictionApi, QualityPhotoApi, ExistingApplicationApi, } from '@island.is/application/types' diff --git a/libs/application/templates/driving-license/src/forms/draft/draft.ts b/libs/application/templates/driving-license/src/forms/draft/draft.ts index 3757e636945a..d120dd2231c3 100644 --- a/libs/application/templates/driving-license/src/forms/draft/draft.ts +++ b/libs/application/templates/driving-license/src/forms/draft/draft.ts @@ -6,6 +6,7 @@ import { subSectionTempInfo } from './subSectionTempInfo' import { subSectionOtherCountry } from './subSectionOtherCountry' import { subSectionOtherCountryDirections } from './subSectionOtherCountryDirections' import { subSectionQualityPhoto } from './subSectionQualityPhoto' +import { subSectionDelivery } from './subSectionDelivery' import { subSectionHealthDeclaration } from './subSectionHealthDeclaration' import { subSectionSummary } from './subSectionSummary' import { subSectionPhone } from './subSectionPhone' @@ -32,6 +33,7 @@ export const draft: Form = buildForm({ subSectionOtherCountry, subSectionOtherCountryDirections, subSectionQualityPhoto, + subSectionDelivery, subSectionHealthDeclaration, subSectionSummary, ], diff --git a/libs/application/templates/driving-license/src/forms/draft/subSectionDelivery.ts b/libs/application/templates/driving-license/src/forms/draft/subSectionDelivery.ts new file mode 100644 index 000000000000..a6295a5344c5 --- /dev/null +++ b/libs/application/templates/driving-license/src/forms/draft/subSectionDelivery.ts @@ -0,0 +1,51 @@ +import { + buildDescriptionField, + buildMultiField, + buildSelectField, + buildSubSection, +} from '@island.is/application/core' +import { m } from '../../lib/messages' +import { + chooseDistrictCommissionerDescription, + hasNoDrivingLicenseInOtherCountry, +} from '../../lib/utils' + +import { Jurisdiction } from '@island.is/clients/driving-license' + +export const subSectionDelivery = buildSubSection({ + id: 'user', + title: m.informationSectionTitle, + condition: hasNoDrivingLicenseInOtherCountry, + children: [ + buildMultiField({ + id: 'info', + title: m.pickupLocationTitle, + space: 1, + children: [ + buildDescriptionField({ + id: 'afhending', + title: m.districtCommisionerTitle, + titleVariant: 'h4', + description: chooseDistrictCommissionerDescription, + }), + buildSelectField({ + id: 'jurisdiction', + title: m.districtCommisionerPickup, + disabled: false, + required: true, + options: ({ + externalData: { + jurisdictions: { data }, + }, + }) => { + return (data as Jurisdiction[]).map(({ id, name, zip }) => ({ + value: `${id}`, + label: name, + tooltip: `Póstnúmer ${zip}`, + })) + }, + }), + ], + }), + ], +}) diff --git a/libs/application/templates/driving-license/src/forms/prerequisites/sectionExternalData.ts b/libs/application/templates/driving-license/src/forms/prerequisites/sectionExternalData.ts index 5a8c4a131fdf..b920cf6deeca 100644 --- a/libs/application/templates/driving-license/src/forms/prerequisites/sectionExternalData.ts +++ b/libs/application/templates/driving-license/src/forms/prerequisites/sectionExternalData.ts @@ -10,6 +10,7 @@ import { UserProfileApi, CurrentLicenseApi, DrivingAssessmentApi, + JurisdictionApi, QualityPhotoApi, ExistingApplicationApi, } from '@island.is/application/types' @@ -56,6 +57,10 @@ export const sectionExternalData = buildSubSection({ provider: DrivingAssessmentApi, title: '', }), + buildDataProviderItem({ + provider: JurisdictionApi, + title: '', + }), buildDataProviderItem({ provider: SyslumadurPaymentCatalogApi, title: '', diff --git a/libs/application/templates/driving-license/src/lib/drivingLicenseTemplate.ts b/libs/application/templates/driving-license/src/lib/drivingLicenseTemplate.ts index 43d724e7f327..403230d3c6b1 100644 --- a/libs/application/templates/driving-license/src/lib/drivingLicenseTemplate.ts +++ b/libs/application/templates/driving-license/src/lib/drivingLicenseTemplate.ts @@ -11,6 +11,7 @@ import { ApplicationStateSchema, DefaultEvents, defineTemplateApi, + JurisdictionApi, CurrentLicenseApi, DrivingAssessmentApi, NationalRegistryUserApi, @@ -126,6 +127,7 @@ const template: ApplicationTemplate< UserProfileApi, SyslumadurPaymentCatalogApi, GlassesCheckApi, + JurisdictionApi, CurrentLicenseApi.configure({ params: { useLegacyVersion: true, diff --git a/libs/application/templates/driving-license/src/lib/messages.ts b/libs/application/templates/driving-license/src/lib/messages.ts index 8aabdf363f80..f376e0f5045b 100644 --- a/libs/application/templates/driving-license/src/lib/messages.ts +++ b/libs/application/templates/driving-license/src/lib/messages.ts @@ -105,6 +105,11 @@ export const m = defineMessages({ defaultMessage: 'Sýslumannsembætti', description: 'Information', }, + pickupLocationTitle: { + id: 'dl.application:pickuplocation', + defaultMessage: 'Afhendingarstaður', + description: 'location for pickup', + }, informationApplicant: { id: 'dl.application:information.applicant', defaultMessage: 'Umsækjandi', @@ -581,6 +586,11 @@ export const m = defineMessages({ defaultMessage: 'Sýslumannsembætti', description: 'Title for district commissioner', }, + districtCommisionerPickup: { + id: 'dl.application:districtCommisionerPickup', + defaultMessage: 'Afhending', + description: 'Pickup for district commissioner', + }, chooseDistrictCommisionerForFullLicense: { id: 'dl.application:chooseDistrictCommisionerForFullLicense', defaultMessage: