-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(new-primary-school): Data implementation and remove not used pag…
…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
1 parent
fa8f276
commit f1b145f
Showing
53 changed files
with
1,620 additions
and
1,548 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
libs/api/domains/education/src/lib/graphql/frigg/organization.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[] | ||
} |
89 changes: 81 additions & 8 deletions
89
...te-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) | ||
} | ||
} |
Oops, something went wrong.