Skip to content

Commit

Permalink
feat(new-primary-school): Data implementation and remove not used pag…
Browse files Browse the repository at this point in the history
…es (#16096)

* Added latest version of clientConfig and latest endpoints from Juni

* testing

* Rollback test

* feat(new-primary-school): Allergies and intolerances - Data implementation (#15319)

* [TS-806] Implement Allergies and intolerances page - Data implementation

* Updated function name

* Refactor/new primary school data implementation (#15381)

* refactor: updated apitags

* fix? clean

* chore: nx format:write update dirty files

---------

Co-authored-by: Alex Diljar <[email protected]>
Co-authored-by: andes-it <[email protected]>

* Comment out UserApi

* feat(new-primary-school): Move child page to prerequisites (#15394)

* Move child page to prerequisites

* Update clientConfig

* Updated Api module action name

* feat(new-primary-school): Relatives - Data implementation (#15403)

* Relatives - Data implementation

* Fixed after review

* feat(new-primary-school): pronoun (#15408)

* feat(new-primary-school): Pronoun Select Field

Added a select field for selecting pronoun

https://dit-iceland.atlassian.net/browse/TS-811

* Make pronoun full width and change place with preferred name

* Use gender data from Júní

* Review comment fixes

* use defaultValue for pronouns

---------

Co-authored-by: hfhelgason <[email protected]>

* Update Frigg service path

* Update clientConfig

* feat(new-primary-school): Implement no children found page (#15909)

* [TS-816] Implement no children found page

* Remove comments

* feat(new-primary): Update new primary school application (#15849)

* [TS-883] Remove 'Má sækja barn' - Relatives page

* [TS-884] Remove gender - Child info page

* [TS-885] Remove use of footage page

* Update Child in Review

* [TS-904] Remove Allergies and intolerances page (#15923)

Co-authored-by: bkristmundsson <[email protected]>

* Remove duplicated translations

* feat(new-primary-school): New school - Data implementation (#15437)

* New school - Data implementation

* testing build problems

* testing build problems

* build problem testing

* build problem testing

* Rollback build test

---------

Co-authored-by: bkristmundsson <[email protected]>

* Fixed codegen error?

* Updated loadOptions in FriggOptionsAsyncSelectField

* Updated clientConfig

* Updated other parent address

* Allow children to pass through for testing

* chore: nx format:write update dirty files

* feat(new-primary-school): Current school (#16125)

* Implement current school

* Fixed message namespace error

* Updated messages

* Remove unnecessary data providers and their associated functions

* Removed unused stateMachine action

* feat(new-primary-school): Send application (#15489)

* Send application - Not ready

* Update sendApplication - Not ready

* Update sendApplication - Not ready

* chore: nx format:write update dirty files

* Removed logo

* Updated languages in transformApplicationToNewPrimarySchoolDTO

* Updated text in Review

* [TS-814] Implement send application

---------

Co-authored-by: andes-it <[email protected]>

* Simplified nested ternary operator used to calculate noIcelandic

* Removed otherParentName - unused

* Fix after coderabbit

* Fixed formatGrade() after review from coderabbitai

* Update nationalRegistry text in externalData

* Fix after coderabbit

* Fix after coderabbit

* Fix after coderabbit, added default values

* Fix after coderabbit, added default values

* Fix after coderabbit, added null checks

---------

Co-authored-by: veronikasif <[email protected]>
Co-authored-by: Alex Diljar Birkisbur Hellsing <[email protected]>
Co-authored-by: Alex Diljar <[email protected]>
Co-authored-by: andes-it <[email protected]>
Co-authored-by: Veronika Sif <[email protected]>
Co-authored-by: helgifr <[email protected]>
Co-authored-by: hfhelgason <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
9 people authored Oct 4, 2024
1 parent fa8f276 commit f1b145f
Show file tree
Hide file tree
Showing 53 changed files with 1,620 additions and 1,548 deletions.
4 changes: 2 additions & 2 deletions charts/islandis/values.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ api:
XROAD_INNA_PATH: 'IS-DEV/GOV/10066/MMS-Protected/inna-v1'
XROAD_INTELLECTUAL_PROPERTIES_PATH: 'IS-DEV/GOV/10030/WebAPI-Public/HUG-webAPI/'
XROAD_JUDICIAL_SYSTEM_SP_PATH: 'IS-DEV/GOV/10014/Rettarvorslugatt-Private/judicial-system-mailbox-api'
XROAD_MMS_FRIGG_PATH: 'IS-DEV/GOV/10066/MMS-Protected/frigg-api'
XROAD_MMS_FRIGG_PATH: 'IS-DEV/GOV/10066/MMS-Protected/frigg-form-service'
XROAD_MMS_GRADE_SERVICE_ID: 'IS-DEV/GOV/10066/MMS-Protected/grade-api-v1'
XROAD_MMS_LICENSE_SERVICE_ID: 'IS-DEV/GOV/10066/MMS-Protected/license-api-v1'
XROAD_NATIONAL_REGISTRY_REDIS_NODES: '["clustercfg.general-redis-cluster-group.5fzau3.euw1.cache.amazonaws.com:6379"]'
Expand Down Expand Up @@ -649,7 +649,7 @@ application-system-api:
XROAD_HOLAR_UNIVERSITY_PATH: 'IS-DEV/EDU/10055/Holar-Protected/brautskraning-v1'
XROAD_ICELAND_UNIVERSITY_OF_THE_ARTS_PATH: 'IS-DEV/EDU/10049/LHI-Protected/brautskraning-v1'
XROAD_INNA_PATH: 'IS-DEV/GOV/10066/MMS-Protected/inna-v1'
XROAD_MMS_FRIGG_PATH: 'IS-DEV/GOV/10066/MMS-Protected/frigg-api'
XROAD_MMS_FRIGG_PATH: 'IS-DEV/GOV/10066/MMS-Protected/frigg-form-service'
XROAD_NATIONAL_REGISTRY_REDIS_NODES: '["clustercfg.general-redis-cluster-group.5fzau3.euw1.cache.amazonaws.com:6379"]'
XROAD_NATIONAL_REGISTRY_SERVICE_PATH: 'IS-DEV/GOV/10001/SKRA-Protected/Einstaklingar-v1'
XROAD_OFFICIAL_JOURNAL_APPLICATION_PATH: 'IS-DEV/GOV/10014/DMR-Protected/official-journal-application'
Expand Down
4 changes: 2 additions & 2 deletions charts/islandis/values.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ api:
XROAD_INNA_PATH: 'IS/GOV/6601241280/MMS-Protected/inna-v1'
XROAD_INTELLECTUAL_PROPERTIES_PATH: 'IS/GOV/6501912189/WebAPI-Public/HUG-webAPI/'
XROAD_JUDICIAL_SYSTEM_SP_PATH: 'IS-GOV/GOV/5804170510/Rettarvorslugatt-Private/judicial-system-mailbox-api'
XROAD_MMS_FRIGG_PATH: 'IS/GOV/10066/MMS-Protected/frigg-api'
XROAD_MMS_FRIGG_PATH: 'IS/GOV/10066/MMS-Protected/frigg-form-service'
XROAD_MMS_GRADE_SERVICE_ID: 'IS/GOV/6601241280/MMS-Protected/grade-api-v1'
XROAD_MMS_LICENSE_SERVICE_ID: 'IS/GOV/6601241280/MMS-Protected/license-api-v1'
XROAD_NATIONAL_REGISTRY_REDIS_NODES: '["clustercfg.general-redis-cluster-group.whakos.euw1.cache.amazonaws.com:6379"]'
Expand Down Expand Up @@ -639,7 +639,7 @@ application-system-api:
XROAD_HOLAR_UNIVERSITY_PATH: 'IS/EDU/5001694359/Holar-Protected/brautskraning-v1'
XROAD_ICELAND_UNIVERSITY_OF_THE_ARTS_PATH: 'IS/EDU/4210984099/LHI-Protected/brautskraning-v1'
XROAD_INNA_PATH: 'IS/GOV/6601241280/MMS-Protected/inna-v1'
XROAD_MMS_FRIGG_PATH: 'IS/GOV/10066/MMS-Protected/frigg-api'
XROAD_MMS_FRIGG_PATH: 'IS/GOV/10066/MMS-Protected/frigg-form-service'
XROAD_NATIONAL_REGISTRY_REDIS_NODES: '["clustercfg.general-redis-cluster-group.whakos.euw1.cache.amazonaws.com:6379"]'
XROAD_NATIONAL_REGISTRY_SERVICE_PATH: 'IS/GOV/6503760649/SKRA-Protected/Einstaklingar-v1'
XROAD_OFFICIAL_JOURNAL_APPLICATION_PATH: 'IS/GOV/10014/DMR-Protected/official-journal-application'
Expand Down
4 changes: 2 additions & 2 deletions charts/islandis/values.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ api:
XROAD_INNA_PATH: 'IS-TEST/GOV/6601241280/MMS-Protected/inna-v1'
XROAD_INTELLECTUAL_PROPERTIES_PATH: 'IS-TEST/GOV/6501912189/WebAPI-Public/HUG-webAPI/'
XROAD_JUDICIAL_SYSTEM_SP_PATH: 'IS-TEST/GOV/10014/Rettarvorslugatt-Private/judicial-system-mailbox-api'
XROAD_MMS_FRIGG_PATH: 'IS-TEST/GOV/10066/MMS-Protected/frigg-api'
XROAD_MMS_FRIGG_PATH: 'IS-TEST/GOV/10066/MMS-Protected/frigg-form-service'
XROAD_MMS_GRADE_SERVICE_ID: 'IS-TEST/GOV/6601241280/MMS-Protected/grade-api-v1'
XROAD_MMS_LICENSE_SERVICE_ID: 'IS-TEST/GOV/6601241280/MMS-Protected/license-api-v1'
XROAD_NATIONAL_REGISTRY_REDIS_NODES: '["clustercfg.general-redis-cluster-group.ab9ckb.euw1.cache.amazonaws.com:6379"]'
Expand Down Expand Up @@ -647,7 +647,7 @@ application-system-api:
XROAD_HOLAR_UNIVERSITY_PATH: 'IS-TEST/EDU/10055/Holar-Protected/brautskraning-v1'
XROAD_ICELAND_UNIVERSITY_OF_THE_ARTS_PATH: 'IS-TEST/EDU/10049/LHI-Protected/brautskraning-v1'
XROAD_INNA_PATH: 'IS-TEST/GOV/6601241280/MMS-Protected/inna-v1'
XROAD_MMS_FRIGG_PATH: 'IS-TEST/GOV/10066/MMS-Protected/frigg-api'
XROAD_MMS_FRIGG_PATH: 'IS-TEST/GOV/10066/MMS-Protected/frigg-form-service'
XROAD_NATIONAL_REGISTRY_REDIS_NODES: '["clustercfg.general-redis-cluster-group.ab9ckb.euw1.cache.amazonaws.com:6379"]'
XROAD_NATIONAL_REGISTRY_SERVICE_PATH: 'IS-TEST/GOV/6503760649/SKRA-Protected/Einstaklingar-v1'
XROAD_OFFICIAL_JOURNAL_APPLICATION_PATH: 'IS-TEST/GOV/10014/DMR-Protected/official-journal-application'
Expand Down
6 changes: 3 additions & 3 deletions infra/src/dsl/xroad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -895,9 +895,9 @@ export const OfficialJournalOfIcelandApplication = new XroadConf({
export const Frigg = new XroadConf({
env: {
XROAD_MMS_FRIGG_PATH: {
dev: 'IS-DEV/GOV/10066/MMS-Protected/frigg-api',
staging: 'IS-TEST/GOV/10066/MMS-Protected/frigg-api',
prod: 'IS/GOV/10066/MMS-Protected/frigg-api',
dev: 'IS-DEV/GOV/10066/MMS-Protected/frigg-form-service',
staging: 'IS-TEST/GOV/10066/MMS-Protected/frigg-form-service',
prod: 'IS/GOV/10066/MMS-Protected/frigg-form-service',
},
},
})
Expand Down
23 changes: 16 additions & 7 deletions libs/api/domains/education/src/lib/graphql/frigg.resolver.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { Args, Query, Resolver } from '@nestjs/graphql'

import { UseGuards } from '@nestjs/common'

import type { User } from '@island.is/auth-nest-tools'
import {
CurrentUser,
IdsUserGuard,
Scopes,
ScopesGuard,
} from '@island.is/auth-nest-tools'

import type { User } from '@island.is/auth-nest-tools'
import { ApiScope } from '@island.is/auth/scopes'
import { FriggClientService, KeyOption } from '@island.is/clients/mms/frigg'
import {
FriggClientService,
KeyOption,
OrganizationModel,
} from '@island.is/clients/mms/frigg'
import { UseGuards } from '@nestjs/common'
import { Args, Query, Resolver } from '@nestjs/graphql'

import { KeyOptionModel } from './frigg/keyOption.model'
import { FriggOptionListInput } from './frigg/optionList.input'
import { FriggOrganizationModel } from './frigg/organization.model'

@UseGuards(IdsUserGuard, ScopesGuard)
@Scopes(ApiScope.internal)
Expand All @@ -30,4 +32,11 @@ export class FriggResolver {
): Promise<KeyOption[]> {
return this.friggClientService.getAllKeyOptions(user, input.type)
}

@Query(() => [FriggOrganizationModel], { nullable: true })
friggSchoolsByMunicipality(
@CurrentUser() user: User,
): Promise<OrganizationModel[]> {
return this.friggClientService.getAllSchoolsByMunicipality(user)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Field, ObjectType, registerEnumType } from '@nestjs/graphql'

export enum OrganizationModelTypeEnum {
Municipality = 'municipality',
National = 'national',
School = 'school',
}

registerEnumType(OrganizationModelTypeEnum, {
name: 'OrganizationModelTypeEnum',
})

@ObjectType('EducationFriggOrganizationModel')
export class FriggOrganizationModel {
@Field()
id!: string

@Field()
nationalId!: string

@Field()
name!: string

@Field(() => OrganizationModelTypeEnum)
type!: OrganizationModelTypeEnum

@Field(() => [String], { nullable: true })
gradeLevels?: string[]

@Field(() => [FriggOrganizationModel], { nullable: true })
children?: FriggOrganizationModel[]
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,101 @@
import { Inject, Injectable } from '@nestjs/common'
import { NationalRegistryXRoadService } from '@island.is/api/domains/national-registry-x-road'
import {
errorMessages,
getApplicationAnswers,
} from '@island.is/application/templates/new-primary-school'
import { ApplicationTypes } from '@island.is/application/types'
import { BaseTemplateApiService } from '../../base-template-api.service'
import { FriggClientService } from '@island.is/clients/mms/frigg'
import { LOGGER_PROVIDER } from '@island.is/logging'
import { TemplateApiError } from '@island.is/nest/problem'
import { Inject, Injectable } from '@nestjs/common'
import * as kennitala from 'kennitala'
import { TemplateApiModuleActionProps } from '../../../types'
import { BaseTemplateApiService } from '../../base-template-api.service'
import { transformApplicationToNewPrimarySchoolDTO } from './new-primary-school.utils'
import { isRunningOnEnvironment } from '@island.is/shared/utils'

@Injectable()
export class NewPrimarySchoolService extends BaseTemplateApiService {
constructor(
@Inject(LOGGER_PROVIDER) private logger: Logger,
private readonly friggClientService: FriggClientService,
private readonly nationalRegistryService: NationalRegistryXRoadService,
) {
super(ApplicationTypes.NEW_PRIMARY_SCHOOL)
}

async getTypes({ auth }: TemplateApiModuleActionProps) {
return await this.friggClientService.getTypes(auth)
async getChildInformation({
auth,
application,
}: TemplateApiModuleActionProps) {
const { childNationalId } = getApplicationAnswers(application.answers)

if (!childNationalId) {
return undefined
}

return await this.friggClientService.getUserById(auth, childNationalId)
}

async getAllKeyOptions({ auth }: TemplateApiModuleActionProps) {
return await this.friggClientService.getAllKeyOptions(auth, '')
async getChildren({ auth }: TemplateApiModuleActionProps) {
const children =
await this.nationalRegistryService.getChildrenCustodyInformation(auth)

const currentYear = new Date().getFullYear()
const maxYear = currentYear - 7 // 2nd grade
const minYear = currentYear - 16 // 10th grade

// Check if the child is at primary school age and lives with the applicant
const filteredChildren = children.filter((child) => {
// Allow children to pass through
const validChildren = [
'1111111119',
'2222222229',
'5555555559',
'6666666669',
]
if (
isRunningOnEnvironment('local') &&
validChildren.includes(child.nationalId)
) {
return true
}

if (!child.nationalId) {
return false
}

const yearOfBirth = kennitala
.info(child.nationalId)
.birthday.getFullYear()

return (
child.livesWithApplicant &&
yearOfBirth >= minYear &&
yearOfBirth <= maxYear
)
})

if (filteredChildren.length === 0) {
throw new TemplateApiError(
{
title: errorMessages.noChildrenFoundTitle,
summary: errorMessages.noChildrenFoundMessage,
},
400,
)
}

return filteredChildren
}

async getHealth({ auth }: TemplateApiModuleActionProps) {
return await this.friggClientService.getHealth(auth)
async sendApplication({ auth, application }: TemplateApiModuleActionProps) {
const newPrimarySchoolDTO =
transformApplicationToNewPrimarySchoolDTO(application)

return await this.friggClientService.sendApplication(
auth,
newPrimarySchoolDTO,
)
}
}
Loading

0 comments on commit f1b145f

Please sign in to comment.