Skip to content

Commit

Permalink
feat(citizenship): added busetuskilyrdi and nationality of children (#…
Browse files Browse the repository at this point in the history
…14923)

* added busetuskilyrdi and nationality of children

* formatting clientconfig

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
berglindoma13 and kodiakhq[bot] authored May 24, 2024
1 parent c6dcf8f commit 2a32a55
Show file tree
Hide file tree
Showing 15 changed files with 171 additions and 153 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ export class CitizenshipService extends BaseTemplateApiService {
super(ApplicationTypes.CITIZENSHIP)
}

async getResidenceConditionInfo({
auth,
}: TemplateApiModuleActionProps): Promise<ApplicantResidenceConditionViewModel> {
async getResidenceConditionInfo(
auth: Auth,
): Promise<ApplicantResidenceConditionViewModel> {
return this.directorateOfImmigrationClient.getCitizenshipResidenceConditionInfo(
auth,
)
Expand Down Expand Up @@ -78,7 +78,7 @@ export class CitizenshipService extends BaseTemplateApiService {
throw new TemplateApiError(
{
title: errorMessages.applicationConditionsNotMet,
summary: '',
summary: errorMessages.applicationConditionsNotMet,
},
400,
)
Expand All @@ -87,17 +87,29 @@ export class CitizenshipService extends BaseTemplateApiService {
const applicantInformationItem: ApplicantInformation = {}

if (validApplicant.applicantExists === true) {
const [countryOfResidenceList, passportItem, staysAbroadList] =
await Promise.all([
this.getCurrentCountryOfResidenceList(auth),
this.getCurrentPassportItem(auth),
this.getCurrentStayAbroadList(auth),
])
const [
countryOfResidenceList,
passportItem,
staysAbroadList,
residenceConditionInfo,
] = await Promise.all([
this.getCurrentCountryOfResidenceList(auth),
this.getCurrentPassportItem(auth),
this.getCurrentStayAbroadList(auth),
this.getResidenceConditionInfo(auth),
])

applicantInformationItem.currentCountryOfResidenceList =
countryOfResidenceList
applicantInformationItem.currentPassportItem = passportItem
applicantInformationItem.currentStaysAbroadList = staysAbroadList
applicantInformationItem.residenceConditionInfo = residenceConditionInfo
} else {
applicantInformationItem.eesNordicCitizen =
validApplicant.eesNordicCitizen
applicantInformationItem.eesResidenceCondition =
validApplicant.eesResidenceCondition
applicantInformationItem.spouseIsCitizen = validApplicant.spouseIsCitizen
}

return applicantInformationItem
Expand Down Expand Up @@ -154,24 +166,12 @@ export class CitizenshipService extends BaseTemplateApiService {
application,
auth,
}: TemplateApiModuleActionProps) {
const answers = application.answers as CitizenshipAnswers

const residenceConditionInfo =
await this.directorateOfImmigrationClient.getCitizenshipResidenceConditionInfo(
auth,
)

// throw error in case the residence condition list changed since prerequisite step and
// user does not fulfill any other condition
if (
!residenceConditionInfo.isAnyResConValid &&
answers.parentInformation?.hasValidParents !== YES &&
answers.formerIcelander !== YES
) {
const validApplicant = await this.getApplicantValidity(auth)
if (!validApplicant.applicantExists && !validApplicant.isEESCitizen) {
throw new TemplateApiError(
{
title: errorMessages.noResidenceConditionPossible,
summary: errorMessages.noResidenceConditionPossible,
title: errorMessages.applicationConditionsNotMet,
summary: errorMessages.applicationConditionsNotMet,
},
400,
)
Expand Down Expand Up @@ -270,14 +270,25 @@ export class CitizenshipService extends BaseTemplateApiService {
auth,
{
selectedChildren:
answers.selectedChildrenExtraData?.map((c) => ({
nationalId: c.nationalId,
otherParentNationalId: c.otherParentNationalId,
otherParentBirtDate: c.otherParentBirtDate
? new Date(c.otherParentBirtDate)
: undefined,
otherParentName: c.otherParentName,
})) || [],
answers.selectedChildrenExtraData?.map((c) => {
const childrenCustodyInformation = application.externalData
.childrenCustodyInformation
.data as ApplicantChildCustodyInformation[]

const thisChild = childrenCustodyInformation.find(
(x) => x.nationalId === c.nationalId,
)

return {
nationalId: c.nationalId,
otherParentNationalId: c.otherParentNationalId,
otherParentBirtDate: c.otherParentBirtDate
? new Date(c.otherParentBirtDate)
: undefined,
otherParentName: c.otherParentName,
citizenship: thisChild?.citizenship?.code || '',
}
}) || [],
isFormerIcelandicCitizen: answers.formerIcelander === YES,
givenName: individual?.givenName,
familyName: individual?.familyName,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
ApplicantResidenceConditionViewModel,
CountryOfResidenceViewModel,
ResidenceAbroadViewModel,
TravelDocumentViewModel,
Expand All @@ -8,4 +9,8 @@ export interface ApplicantInformation {
currentCountryOfResidenceList?: CountryOfResidenceViewModel[]
currentPassportItem?: TravelDocumentViewModel
currentStaysAbroadList?: ResidenceAbroadViewModel[]
residenceConditionInfo?: ApplicantResidenceConditionViewModel
eesNordicCitizen?: boolean
eesResidenceCondition?: boolean
spouseIsCitizen?: boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ export const ApplicantInformationApi = defineTemplateApi({
externalDataId: 'applicantInformation',
})

export const ResidenceConditionInfoApi = defineTemplateApi({
action: ApiActions.getResidenceConditionInfo,
externalDataId: 'residenceConditionInfo',
})

export const ResidenceInIcelandLastChangeDateApi = defineTemplateApi({
action: ApiActions.getResidenceInIcelandLastChangeDate,
externalDataId: 'residenceInIcelandLastChangeDate',
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ export { Parents } from './Parents'
export { StaysAbroad } from './StaysAbroad'
export { CriminalRecords } from './CriminalRecords'
export { Review } from './Review'
export { FormerIcelander } from './FormerIcelander'
export { HiddenTextInput } from './HiddenTextInput'
export { MoreChildInfo } from './SelectedChildrenExtra'
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,46 @@ import {
getValueViaPath,
} from '@island.is/application/core'
import { information } from '../../../lib/messages'
import { Answer, YES } from '@island.is/application/types'
import { Answer, FormValue, YES } from '@island.is/application/types'
import { Citizenship } from '../../../lib/dataSchema'
import { ApplicantResidenceConditionViewModel } from '@island.is/clients/directorate-of-immigration'
import { ApplicantInformation, ParentsToApplicant } from '../../../shared'

export const FormerIcelanderSubSection = buildSubSection({
id: 'formerIcelander',
title: information.labels.formerIcelander.subSectionTitle,
condition: (answer: Answer, externalData) => {
const answers = answer as Citizenship
const hasValidParents = answers?.parentInformation?.hasValidParents === YES

condition: (formValue: FormValue, externalData) => {
const residenceConditionInfo = getValueViaPath(
externalData,
'residenceConditionInfo.data',
'applicantInformation.data.residenceConditionInfo',
{},
) as ApplicantResidenceConditionViewModel
const isAnyResConValid = residenceConditionInfo.isAnyResConValid
) as ApplicantInformation

const parentAnswer = getValueViaPath(
formValue,
'parentInformation.parents',
[],
) as Array<ParentsToApplicant>

const totalParentsInAnswer = parentAnswer.filter(
(x) => x.wasRemoved === 'false',
)
const hasResConMaritalStatus =
residenceConditionInfo.cohabitationISCitizen5YearDomicile ||
residenceConditionInfo.cohabitationISCitizen5YrsDomicileMissingDate ||
residenceConditionInfo.marriedISCitizenDomicile4Years ||
residenceConditionInfo.marriedISCitizenDomicile4YrsMissingDate

const hasOtherValidResidenceConditions =
residenceConditionInfo.domicileResidence7Years ||
residenceConditionInfo.asylumSeekerOrHumanitarianResPerm5year ||
residenceConditionInfo.noNationalityAnd5YearsDomicile ||
residenceConditionInfo.nordicCitizenship4YearDomicile

// TODO revert
// return !isAnyResConValid && !hasValidParents
return !hasValidParents
return (
!hasResConMaritalStatus &&
!hasOtherValidResidenceConditions &&
totalParentsInAnswer.length === 0
)
},
children: [
buildMultiField({
Expand All @@ -49,24 +68,23 @@ export const FormerIcelanderSubSection = buildSubSection({
{ value: NO, label: information.labels.radioButtons.radioOptionNo },
],
}),
// TODO revert
// buildAlertMessageField({
// id: 'formerIcelanderAlert',
// title: information.labels.formerIcelander.alertTitle,
// alertType: 'error',
// message: information.labels.formerIcelander.alertDescription,
// condition: (answer: Answer) => {
// const answers = answer as Citizenship
// return answers?.formerIcelander === NO
// },
// links: [
// {
// title: information.labels.formerIcelander.alertLinkTitle,
// url: information.labels.formerIcelander.alertLinkUrl,
// isExternal: true,
// },
// ],
// }),
buildAlertMessageField({
id: 'formerIcelanderAlert',
title: information.labels.formerIcelander.alertTitle,
alertType: 'error',
message: information.labels.formerIcelander.alertDescription,
condition: (answer: Answer) => {
const answers = answer as Citizenship
return answers?.formerIcelander === NO
},
links: [
{
title: information.labels.formerIcelander.alertLinkTitle,
url: information.labels.formerIcelander.alertLinkUrl,
isExternal: true,
},
],
}),
],
}),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,45 @@ import {
} from '@island.is/application/core'
import { information } from '../../../lib/messages'
import { Application } from '@island.is/api/schema'
import { ApplicantResidenceConditionViewModel } from '@island.is/clients/directorate-of-immigration'
import { formatDate } from '../../../utils'
import { Routes } from '../../../lib/constants'
import {
NationalRegistryIndividual,
NationalRegistrySpouse,
} from '@island.is/application/types'
import { ApplicantInformation } from '../../../shared'

export const MaritalStatusSubSection = buildSubSection({
id: Routes.MARITALSTATUS,
title: information.labels.maritalStatus.subSectionTitle,
condition: (_, externalData) => {
const spouseDetails = getValueViaPath(
externalData,
'spouseDetails.data',
undefined,
) as NationalRegistrySpouse | undefined
const maritalStatus = spouseDetails?.maritalStatus
const hasSpouse = !!spouseDetails?.nationalId
const isMarriedOrCohabitation =
maritalStatus === '3' || (maritalStatus === '1' && hasSpouse)

// Check if the only residence condition that the applicant can apply for, is related to marital status
const residenceConditionInfo = getValueViaPath(
externalData,
'residenceConditionInfo.data',
'applicantInformation.data.residenceConditionInfo',
{},
) as ApplicantResidenceConditionViewModel
const hasOnlyResConMaritalStatus =
residenceConditionInfo.isAnyResConValid &&
residenceConditionInfo.isOnlyMarriedOrCohabitationWithISCitizen
) as ApplicantInformation

const hasResConMaritalStatus =
residenceConditionInfo.cohabitationISCitizen5YearDomicile ||
residenceConditionInfo.cohabitationISCitizen5YrsDomicileMissingDate ||
residenceConditionInfo.marriedISCitizenDomicile4Years ||
residenceConditionInfo.marriedISCitizenDomicile4YrsMissingDate

const hasOtherValidResidenceConditions =
residenceConditionInfo.domicileResidence7Years ||
residenceConditionInfo.asylumSeekerOrHumanitarianResPerm5year ||
residenceConditionInfo.noNationalityAnd5YearsDomicile ||
residenceConditionInfo.nordicCitizenship4YearDomicile

const spouseIsCitizen = residenceConditionInfo.spouseIsCitizen
const eesResidenceCondition = residenceConditionInfo.eesResidenceCondition
const showThisPage = spouseIsCitizen && !eesResidenceCondition

// TODO revert
// return isMarriedOrCohabitation && hasOnlyResConMaritalStatus
return isMarriedOrCohabitation
return (
(!!hasResConMaritalStatus && !hasOtherValidResidenceConditions) ||
!!showThisPage
)
},
children: [
buildMultiField({
Expand Down
Loading

0 comments on commit 2a32a55

Please sign in to comment.