From 941f132bae97033a16305956c3d031f1aee1ea36 Mon Sep 17 00:00:00 2001 From: Veronika Sif Date: Wed, 22 Jan 2025 14:43:56 +0000 Subject: [PATCH 1/4] Update new school page to use updateOnSelect --- .../newSchoolSubSection.ts | 29 ++++++++----------- .../new-primary-school/src/lib/dataSchema.ts | 8 ++--- .../src/lib/newPrimarySchoolUtils.ts | 15 ++-------- 3 files changed, 18 insertions(+), 34 deletions(-) diff --git a/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/primarySchoolSection/newSchoolSubSection.ts b/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/primarySchoolSection/newSchoolSubSection.ts index fc5449e50716..aeb7a3b51742 100644 --- a/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/primarySchoolSection/newSchoolSubSection.ts +++ b/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/primarySchoolSection/newSchoolSubSection.ts @@ -1,6 +1,5 @@ import { buildAsyncSelectField, - buildHiddenInputWithWatchedValue, buildMultiField, buildSubSection, coreErrorMessages, @@ -24,11 +23,11 @@ export const newSchoolSubSection = buildSubSection({ }, children: [ buildMultiField({ - id: 'school', + id: 'newSchool', title: newPrimarySchoolMessages.primarySchool.newSchoolSubSectionTitle, children: [ buildAsyncSelectField({ - id: 'schools.newSchool.municipality', + id: 'newSchool.municipality', title: newPrimarySchoolMessages.shared.municipality, placeholder: newPrimarySchoolMessages.shared.municipalityPlaceholder, loadingError: coreErrorMessages.failedDataProvider, @@ -48,12 +47,13 @@ export const newSchoolSubSection = buildSubSection({ }, }), buildAsyncSelectField({ - id: 'schools.newSchool.school', + id: 'newSchool.school', title: newPrimarySchoolMessages.shared.school, placeholder: newPrimarySchoolMessages.shared.schoolPlaceholder, loadingError: coreErrorMessages.failedDataProvider, dataTestId: 'new-school-school', - loadOptions: async ({ application, apolloClient }) => { + updateOnSelect: ['newSchool.municipality'], + loadOptions: async ({ application, apolloClient, selectedValue }) => { const { schoolMunicipality } = getApplicationAnswers( application.answers, ) @@ -68,7 +68,11 @@ export const newSchoolSubSection = buildSubSection({ return ( data?.friggSchoolsByMunicipality - ?.find(({ name }) => name === schoolMunicipality) + ?.find( + ({ name }) => + name === + (selectedValue ? selectedValue : schoolMunicipality), + ) ?.children?.filter((school) => school.gradeLevels?.includes(childGradeLevel), ) @@ -79,20 +83,11 @@ export const newSchoolSubSection = buildSubSection({ ) }, condition: (answers) => { - const { schoolMunicipality, newSchoolHiddenInput } = - getApplicationAnswers(answers) + const { schoolMunicipality } = getApplicationAnswers(answers) - return ( - !!schoolMunicipality && - schoolMunicipality === newSchoolHiddenInput - ) + return !!schoolMunicipality }, }), - buildHiddenInputWithWatchedValue({ - // Needed to trigger an update on loadOptions in the async select above - id: 'schools.newSchool.hiddenInput', - watchValue: 'schools.newSchool.municipality', - }), ], }), ], diff --git a/libs/application/templates/new-primary-school/src/lib/dataSchema.ts b/libs/application/templates/new-primary-school/src/lib/dataSchema.ts index b68780e26358..54ca78c013b7 100644 --- a/libs/application/templates/new-primary-school/src/lib/dataSchema.ts +++ b/libs/application/templates/new-primary-school/src/lib/dataSchema.ts @@ -115,11 +115,9 @@ export const dataSchema = z.object({ path: ['transferOfLegalDomicile', 'postalCode'], }, ), - schools: z.object({ - newSchool: z.object({ - municipality: z.string(), - school: z.string(), - }), + newSchool: z.object({ + municipality: z.string(), + school: z.string(), }), siblings: z .array( diff --git a/libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.ts b/libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.ts index e243c78bb199..112d2f7b97d5 100644 --- a/libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.ts +++ b/libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.ts @@ -9,11 +9,11 @@ import { Locale } from '@island.is/shared/types' import { Child, ChildInformation, + ContactsRow, FriggChildInformation, Membership, Parents, Person, - ContactsRow, SelectOption, SiblingsRow, } from '../types' @@ -145,18 +145,10 @@ export const getApplicationAnswers = (answers: Application['answers']) => { const schoolMunicipality = getValueViaPath( answers, - 'schools.newSchool.municipality', + 'newSchool.municipality', ) as string - const selectedSchool = getValueViaPath( - answers, - 'schools.newSchool.school', - ) as string - - const newSchoolHiddenInput = getValueViaPath( - answers, - 'schools.newSchool.hiddenInput', - ) as string + const selectedSchool = getValueViaPath(answers, 'newSchool.school') as string return { childNationalId, @@ -189,7 +181,6 @@ export const getApplicationAnswers = (answers: Application['answers']) => { startDate, schoolMunicipality, selectedSchool, - newSchoolHiddenInput, } } From 8e40eceeac53b33b0d854ddb04cbaaf57ea74142 Mon Sep 17 00:00:00 2001 From: andes-it Date: Wed, 22 Jan 2025 15:26:00 +0000 Subject: [PATCH 2/4] chore: nx run-many --target lint --fix --parallel 3 --projects=api,api-domains-air-discount-scheme,api-domains-application,api-domains-auth,api-domains-auth-admin,api-domains-document-provider,api-domains-endorsement-system update dirty files --- .../src/lib/client/clients.service.spec.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libs/api/domains/auth-admin/src/lib/client/clients.service.spec.ts b/libs/api/domains/auth-admin/src/lib/client/clients.service.spec.ts index 5eea8020c827..152a7e8337f4 100644 --- a/libs/api/domains/auth-admin/src/lib/client/clients.service.spec.ts +++ b/libs/api/domains/auth-admin/src/lib/client/clients.service.spec.ts @@ -158,7 +158,7 @@ describe('ClientsService', () => { await app.cleanUp() }) - it('should create application in all environments', async function () { + it('should create application in all environments', async () => { const createClientsInput: CreateClientInput = { clientId: 'test-application-id', clientType: CreateClientType.web, @@ -194,7 +194,7 @@ describe('ClientsService', () => { ]) }) - it('should only create application in development', async function () { + it('should only create application in development', async () => { const createClientsInput: CreateClientInput = { clientId: 'test-application-id', clientType: CreateClientType.web, @@ -232,7 +232,7 @@ describe('ClientsService', () => { ]) }) - it('should publish the client from Staging to Development', async function () { + it('should publish the client from Staging to Development', async () => { const publishClientInput: PublishClientInput = { clientId: 'test-client-id', tenantId: 'test-tenant-id', @@ -268,7 +268,7 @@ describe('ClientsService', () => { }) }) - it('should throw an error because no value was provided', async function () { + it('should throw an error because no value was provided', async () => { const patchClientsInput: PatchClientInput = { clientId: 'test-application-id', tenantId: 'test-tenant-id', @@ -288,7 +288,7 @@ describe('ClientsService', () => { await expect(actPromise).rejects.toThrow('Nothing provided to update') }) - it('should update the postLogoutRedirectUris for all environments', async function () { + it('should update the postLogoutRedirectUris for all environments', async () => { const patchClientsInput: PatchClientInput = { clientId: 'test-application-id', tenantId: 'test-tenant-id', @@ -348,7 +348,7 @@ describe('ClientsService', () => { ]) }) - it('should update the postLogoutRedirectUris for all Development only', async function () { + it('should update the postLogoutRedirectUris for all Development only', async () => { const patchClientsInput: PatchClientInput = { clientId: 'test-application-id', tenantId: 'test-tenant-id', @@ -384,7 +384,7 @@ describe('ClientsService', () => { ]) }) - it('should only rotate secret in a single target environment', async function () { + it('should only rotate secret in a single target environment', async () => { // Arrange const rotateSecretInput: RotateSecretInput = { clientId: 'test-application-id', @@ -414,7 +414,7 @@ describe('ClientsService', () => { }) }) - it('should revoke old secrets and create new secret in a single environment', async function () { + it('should revoke old secrets and create new secret in a single environment', async () => { // Arrange const rotateSecretInput: RotateSecretInput = { clientId: 'test-application-id', From 7ce4115276b85d203944c68de58d7d203ff11022 Mon Sep 17 00:00:00 2001 From: andes-it Date: Wed, 22 Jan 2025 16:00:18 +0000 Subject: [PATCH 3/4] chore: nx run-many --target lint --fix --parallel 3 --projects=api-domains-documents,api-domains-driving-license,api-domains-driving-license-book,api-domains-education,api-domains-email-signup,api-domains-endorsement-system,api-domains-energy-funds update dirty files --- .../driving-license/src/lib/graphql/qualityPhoto.resolver.ts | 2 +- .../src/lib/graphql/qualitySignature.resolver.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/api/domains/driving-license/src/lib/graphql/qualityPhoto.resolver.ts b/libs/api/domains/driving-license/src/lib/graphql/qualityPhoto.resolver.ts index 28cc3dbfcf8a..e98ef9e4a33a 100644 --- a/libs/api/domains/driving-license/src/lib/graphql/qualityPhoto.resolver.ts +++ b/libs/api/domains/driving-license/src/lib/graphql/qualityPhoto.resolver.ts @@ -22,7 +22,7 @@ export class QualityPhotoResolver { resolveDataUri( @Parent() { hasQualityPhoto }: QualityPhoto, @CurrentUser() user: User, - ): Promise { + ): Promise { return hasQualityPhoto ? this.drivingLicenseService.getQualityPhotoUri(user.authorization) : Promise.resolve(null) diff --git a/libs/api/domains/driving-license/src/lib/graphql/qualitySignature.resolver.ts b/libs/api/domains/driving-license/src/lib/graphql/qualitySignature.resolver.ts index e96a0cfc585d..928ffe03ab05 100644 --- a/libs/api/domains/driving-license/src/lib/graphql/qualitySignature.resolver.ts +++ b/libs/api/domains/driving-license/src/lib/graphql/qualitySignature.resolver.ts @@ -22,7 +22,7 @@ export class QualitySignatureResolver { resolveDataUri( @Parent() { hasQualitySignature }: QualitySignature, @CurrentUser() user: User, - ): Promise { + ): Promise { return hasQualitySignature ? this.drivingLicenseService.getQualitySignatureUri(user.authorization) : Promise.resolve(null) From b5e3dced584ce3e0548bd7a784fc93376adf8641 Mon Sep 17 00:00:00 2001 From: Veronika Sif Date: Thu, 23 Jan 2025 18:09:51 +0000 Subject: [PATCH 4/4] Update after review --- .../primarySchoolSection/newSchoolSubSection.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/primarySchoolSection/newSchoolSubSection.ts b/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/primarySchoolSection/newSchoolSubSection.ts index 2468ddf48bc5..3b602a7dc691 100644 --- a/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/primarySchoolSection/newSchoolSubSection.ts +++ b/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/primarySchoolSection/newSchoolSubSection.ts @@ -63,9 +63,7 @@ export const newSchoolSubSection = buildSubSection({ return ( data?.friggSchoolsByMunicipality ?.find( - ({ name }) => - name === - (selectedValue ? selectedValue : schoolMunicipality), + ({ name }) => name === (selectedValue || schoolMunicipality), ) ?.children?.filter((school) => school.gradeLevels?.includes(childGradeLevel),