Skip to content

Commit

Permalink
feat(id-card): updates to application (#15870)
Browse files Browse the repository at this point in the history
* new application setup

* new application setup

* continued work

* stuff

* working

* State for parent B

* adding overview section to review

* confirmation, approved and rejected file

* adding steps

* AssignParentB api action

* reject application email

* adding submit application email

* commenting out fjs code in service

* adding chargefjsv2clientmodule to id card module file

* adding rest of steps

* merge conflicst

* fixing merge issues

* changes to reject conclusion screen

* ..

* accept reject buttons and modal

* fixing conclusion screen

* added disability check

* dataschema update

* klaraði bakendaföll eins og hægt er í bili

* changes in prerequisites

* changes to typeofidsubsection

* chore: charts update dirty files

* changes to condition description

* finishing up

* changing answers

* small changes

* stuff

* payment fix

* merging

* finishing too many things for one commit

* submit application

* config update

* updates

* trying stuff

* working on this

* connection type to id call

* working on this

* rest of updates for applicatin

* removed disability from dataprovider, not only with permission

* removed space

* payment codes

* temp changes, todo finish

* changes to condition for applying to id cards

* finishind touches

* small fix

* typing iddocumenttype

* fixing comments

* fixing comments

* small updates

* fixes for build

* fixes for build

* small update to test

* small update to test

* small update to test

* small update to test

* small updates

* updates to formatText, applicationCard and types

* stuff

* payment code changes

* updates to aplication

* updates to application

* more updates

* more updates

* more updates

* lokapunktar

* cosnole log remove

* more updates

* more updates

* updates after comment

---------

Co-authored-by: Sigrún Tinna Gissurardóttir <[email protected]>
Co-authored-by: Sigrún Tinna Gissurardóttir <[email protected]>
Co-authored-by: andes-it <[email protected]>
Co-authored-by: Kristofer <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
6 people authored and jonnigs committed Sep 12, 2024
1 parent ba04a71 commit 6fe7af5
Show file tree
Hide file tree
Showing 44 changed files with 888 additions and 592 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,25 @@ export class NationalRegistryService extends BaseTemplateApiService {
await this.validateChildren(params, children)
}

//allow parents whose children are icelandic citizenships in, but if no children, then check citizenship
if (params?.allowIfChildHasCitizenship) {
const children = await this.nationalRegistryApi.getCustodyChildren(auth)
if (children.length > 0) {
let foundChildWithIcelandicCitizenship = false
for (const child of children) {
const individual = await this.getIndividual(child)
if (individual?.citizenship?.code === 'IS') {
foundChildWithIcelandicCitizenship = true
break
}
}
//if child validates with icelandic citizenship, then do not check parents citizenship
if (foundChildWithIcelandicCitizenship) {
params = { ...params, icelandicCitizenship: false }
}
}
}

// Validate individual
this.validateIndividual(individual, false, params)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,3 @@ export type DistrictCommissionerAgencies = {
address: string
key: string
}

export interface IdentityDocumentChild {
childNationalId: string
secondParent: string
secondParentName: string
childName: string
passports?: IdentityDocument[]
}

export type IdentityDocument = {
number: string
type: string
verboseType: string
subType: string
status: string
issuingDate: string
expirationDate: string
displayFirstName: string
displayLastName: string
mrzFirstName: string
mrzLastName: string
sex: string
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import { LOGGER_PROVIDER } from '@island.is/logging'
import { SharedTemplateApiService } from '../../shared'
import { TemplateApiModuleActionProps } from '../../../types'
import { coreErrorMessages, getValueViaPath } from '@island.is/application/core'
import {
DistrictCommissionerAgencies,
IdentityDocumentChild,
} from './constants'
import { DistrictCommissionerAgencies } from './constants'
import {
ChargeFjsV2ClientService,
getPaymentIdFromExternalData,
} from '@island.is/clients/charge-fjs-v2'
import { generateAssignParentBApplicationEmail } from './emailGenerators/assignParentBEmail'
import { PassportsService } from '@island.is/clients/passports'
import {
IdentityDocumentChild,
PassportsService,
} from '@island.is/clients/passports'
import { BaseTemplateApiService } from '../../base-template-api.service'
import {
ApplicationTypes,
Expand All @@ -27,7 +27,7 @@ import {
} from '@island.is/application/templates/id-card'
import { generateApplicationRejectEmail } from './emailGenerators/rejectApplicationEmail'
import { generateApplicationSubmittedEmail } from './emailGenerators/applicationSubmittedEmail'

import { info } from 'kennitala'
@Injectable()
export class IdCardService extends BaseTemplateApiService {
constructor(
Expand Down Expand Up @@ -57,41 +57,56 @@ export class IdCardService extends BaseTemplateApiService {
)
}

const expDate = identityDocument.userPassport?.expirationDate?.toString()
// if applicant has valid id that is not withinExpirationDate, then not available for application,
// otherwise available, either with no id or id within expiration limit
// applicant can have a valid ID and apply for II
const applicantIdentityWithinLimits = expDate
? isAvailableForApplication(
expDate,
'ID',
`${identityDocument.userPassport?.type}${identityDocument.userPassport?.subType}`,
)
: true
const applicantAge = info(auth.nationalId).age
const applicantInformation = {
age: applicantAge,
nationalId: auth.nationalId,
passport: identityDocument.userPassport,
children: identityDocument.childPassports,
}
const applicantIDWithinLimits = isAvailableForApplication(
'ID',
applicantInformation,
)
const applicantIIWithinLimits = isAvailableForApplication(
'II',
applicantInformation,
)

let childIdentityWithinLimits = false
identityDocument.childPassports?.map((child) => {
if (child.passports && child.passports.length > 0) {
child.passports.map((id) => {
const withinLimits = id.expirationDate
? isAvailableForApplication(
id.expirationDate.toString(),
'ID',
`${id.type}${id.subType}`,
)
: true
if (child.childNationalId) {
const childInformation = {
age: info(child.childNationalId).age,
nationalId: child.childNationalId,
passport: child.passports?.[0],
}
const withinLimits = isAvailableForApplication(
'ID',
childInformation,
)

if (withinLimits) {
// if there is any id for any child that is within limits then user should be let through dataProvider
childIdentityWithinLimits = true
if (withinLimits) {
// if there is any id for any child that is within limits then user should be let through dataProvider
childIdentityWithinLimits = true
}
}
})
} else {
childIdentityWithinLimits = true // if child has no id, then let through for application of new id
}
})

if (!applicantIdentityWithinLimits && !childIdentityWithinLimits) {
if (
!applicantIDWithinLimits &&
!applicantIIWithinLimits &&
!childIdentityWithinLimits
) {
throw new TemplateApiError(
{
title: coreErrorMessages.idCardApplicationRequirementsNotMet,
Expand Down Expand Up @@ -278,7 +293,6 @@ export class IdCardService extends BaseTemplateApiService {
guid: application.id,
appliedForPersonId: auth.nationalId,
priority: answers.priceList.priceChoice === Services.EXPRESS ? 1 : 0,
deliveryName: answers.priceList.location,
contactInfo: {
phoneAtHome: applicantInformation.phoneNumber,
phoneAtWork: applicantInformation.phoneNumber,
Expand All @@ -298,7 +312,6 @@ export class IdCardService extends BaseTemplateApiService {
guid: application.id,
appliedForPersonId: applicantInformation.nationalId,
priority: answers.priceList.priceChoice === Services.EXPRESS ? 1 : 0,
deliveryName: answers.priceList.location,
approvalA: {
personId:
firstGuardianInformation?.nationalId?.replace('-', '') || '',
Expand Down
24 changes: 12 additions & 12 deletions libs/application/templates/id-card/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
"options": {
"jestConfig": "libs/application/templates/id-card/jest.config.ts",
"passWithNoTests": true
},
"extract-strings": {
"executor": "nx:run-commands",
"options": {
"command": "yarn ts-node -P libs/localization/tsconfig.lib.json libs/localization/scripts/extract 'libs/application/templates/id-card/src/**/*.{js,ts,tsx}'"
}
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
},
"extract-strings": {
"executor": "nx:run-commands",
"options": {
"command": "yarn ts-node -P libs/localization/tsconfig.lib.json libs/localization/scripts/extract 'libs/application/templates/id-card/src/**/*.{js,ts,tsx}'"
}
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const defaultParams = {
summary: error.invalidAgeDescription,
},
icelandicCitizenship: true,
allowPassOnChild: true,
allowIfChildHasCitizenship: true,
}

export const NationalRegistryUser = NationalRegistryUserApi.configure({
Expand All @@ -45,6 +45,7 @@ export const NationalRegistryUserParentB = NationalRegistryUserApi.configure({
...defaultParams,
icelandicCitizenship: false,
},
externalDataId: 'nationalRegistryParentB',
})

export const SyslumadurPaymentCatalogApi = PaymentCatalogApi.configure({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ export const ClearAnswers: FC<React.PropsWithChildren<FieldBaseProps>> = ({
setBeforeSubmitCallback &&
setBeforeSubmitCallback(async () => {
const chosenApplicants = getValues(Routes.CHOSENAPPLICANTS)

const newAnswers = updateAnswers(application, chosenApplicants, setValue)
try {
await updateApplication({
variables: {
input: {
id: application.id,
answers: updateAnswers(application, chosenApplicants, setValue),
answers: newAnswers,
},
locale,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ export const RejectApproveButtons: FC<
input: {
id: application.id,
event: DefaultEvents.SUBMIT,
answers: {},
answers: {
...application.answers,
'secondGuardianInformation.approved': true,
},
},
},
})
Expand Down
121 changes: 70 additions & 51 deletions libs/application/templates/id-card/src/forms/Approved.ts
Original file line number Diff line number Diff line change
@@ -1,77 +1,96 @@
import {
buildForm,
buildSection,
buildMultiField,
buildAlertMessageField,
buildMessageWithLinkButtonField,
buildExpandableDescriptionField,
coreMessages,
getValueViaPath,
} from '@island.is/application/core'
import { Form, FormModes } from '@island.is/application/types'
// import { Logo } from '../../assets/Logo'
import { buildFormConclusionSection } from '@island.is/application/ui-forms'
import { reviewConfirmation } from '../lib/messages'
import { getChosenApplicant, hasSecondGuardian } from '../utils'
import { IdentityDocumentChild } from '@island.is/clients/passports'

export const Approved: Form = buildForm({
id: 'Approved',
title: '',
// logo: Logo,
mode: FormModes.APPROVED,
children: [
buildSection({
id: 'uiForms.conclusionSection',
title: reviewConfirmation.general.sectionTitle,
children: [
buildMultiField({
id: 'uiForms.conclusionMultifield',
title: reviewConfirmation.general.sectionTitle,
children: [
buildAlertMessageField({
id: 'uiForms.conclusionAlert',
title: reviewConfirmation.general.alertTitle,
alertType: 'success',
}),
buildExpandableDescriptionField({
id: 'uiForms.conclusionExpandableDescription',
title: reviewConfirmation.general.accordionTitle,
introText: '',
description: reviewConfirmation.general.accordionText,
startExpanded: true,
}),
buildAlertMessageField({
id: 'uiForms.conclusionAlertInfo1',
title: '',
alertType: 'info',
message: reviewConfirmation.general.infoMessageText2,
marginBottom: 0,
}),
buildAlertMessageField({
id: 'uiForms.conclusionAlertInfo2',
title: '',
alertType: 'info',
message: reviewConfirmation.general.infoMessageText2,
}),
buildMessageWithLinkButtonField({
id: 'uiForms.conclusionBottomLink',
title: '',
url: '/minarsidur/umsoknir',
buttonTitle: coreMessages.openServicePortalButtonTitle,
message: reviewConfirmation.general.bottomButtonMessage,
marginBottom: [4, 4, 12],
}),
],
}),
],
}),
buildFormConclusionSection({
sectionTitle: reviewConfirmation.general.sectionTitle,
multiFieldTitle: reviewConfirmation.general.sectionTitle,
alertTitle: reviewConfirmation.general.alertTitle,
alertMessage: '',
expandableHeader: reviewConfirmation.general.accordionTitle,
expandableIntro: '',
expandableDescription: reviewConfirmation.general.accordionText,
expandableDescription: (application) => {
const applicantNationalId = getValueViaPath(
application.answers,
'chosenApplicants',
'',
) as string
const chosenApplicant = getChosenApplicant(
application.answers,
application.externalData,
applicantNationalId,
)

return !chosenApplicant.isApplicant
? reviewConfirmation.general.accordionTextForChild
: reviewConfirmation.general.accordionText
},
bottomButtonMessage: reviewConfirmation.general.bottomButtonMessage,
}),
buildAlertMessageField({
id: 'uiForms.conclusionAlertInfo1',
title: '',
alertType: 'info',
message: reviewConfirmation.general.infoMessageText1,
marginBottom: 0,
condition: (formValue, externalData) => {
const applicantNationalId = getValueViaPath(
formValue,
'chosenApplicants',
'',
) as string
const chosenApplicant = getChosenApplicant(
formValue,
externalData,
applicantNationalId,
)

const applicantHasSecondGuardian = hasSecondGuardian(
formValue,
externalData,
)

return !chosenApplicant.isApplicant && applicantHasSecondGuardian
},
}),
buildAlertMessageField({
id: 'uiForms.conclusionAlertInfo2',
title: '',
alertType: 'info',
message: reviewConfirmation.general.infoMessageText2,
condition: (formValue, externalData) => {
const applicantNationalId = getValueViaPath(
formValue,
'chosenApplicants',
'',
) as string
const chosenApplicant = getChosenApplicant(
formValue,
externalData,
applicantNationalId,
)

const applicantHasSecondGuardian = hasSecondGuardian(
formValue,
externalData,
)

return !chosenApplicant.isApplicant && applicantHasSecondGuardian
},
}),
],
})
Loading

0 comments on commit 6fe7af5

Please sign in to comment.