From 363f2aa60bb86d50bb0c71bba00260685c04a97c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9E=C3=B3r=C3=B0ur=20H?= Date: Wed, 15 May 2024 10:27:32 +0000 Subject: [PATCH 01/10] feat(service-portal): Mark all notifications as read (#14786) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../src/lib/notifications.model.ts | 6 ++ .../src/lib/notifications.resolver.ts | 22 +++++++ .../src/lib/notifications.service.ts | 15 +++++ .../information/src/lib/messages.ts | 8 +++ .../Notifications/Notifications.graphql | 6 ++ .../screens/Notifications/Notifications.tsx | 66 ++++++++++++++----- 6 files changed, 108 insertions(+), 15 deletions(-) diff --git a/libs/api/domains/notifications/src/lib/notifications.model.ts b/libs/api/domains/notifications/src/lib/notifications.model.ts index 8152bd4c2b19..64436d89583a 100644 --- a/libs/api/domains/notifications/src/lib/notifications.model.ts +++ b/libs/api/domains/notifications/src/lib/notifications.model.ts @@ -125,6 +125,12 @@ export class NotificationsMarkAllAsSeenResponse { success!: boolean } +@ObjectType() +export class NotificationsMarkAllAsReadResponse { + @Field() + success!: boolean +} + @ObjectType() export class NotificationsUnreadCount { @Field(() => Int) diff --git a/libs/api/domains/notifications/src/lib/notifications.resolver.ts b/libs/api/domains/notifications/src/lib/notifications.resolver.ts index b6d35cc9dcda..0f4ee313468d 100644 --- a/libs/api/domains/notifications/src/lib/notifications.resolver.ts +++ b/libs/api/domains/notifications/src/lib/notifications.resolver.ts @@ -9,6 +9,7 @@ import { NotificationsMarkAllAsSeenResponse, MarkNotificationReadResponse, NotificationResponse, + NotificationsMarkAllAsReadResponse, } from './notifications.model' import type { Locale } from '@island.is/shared/types' import { LOGGER_PROVIDER, type Logger } from '@island.is/logging' @@ -94,6 +95,27 @@ export class NotificationsResolver { return result } + @Mutation(() => NotificationsMarkAllAsReadResponse, { + name: 'markAllNotificationsRead', + nullable: true, + }) + @Audit() + async markAllNotificationsAsRead(@CurrentUser() user: User) { + let result + + try { + result = await this.service.markAllNotificationsAsRead(user) + } catch (e) { + this.logger.error('failed to mark all notifications as read', { + category: LOG_CATEGORY, + error: e, + }) + throw e + } + + return result + } + @Mutation(() => MarkNotificationReadResponse, { name: 'markNotificationAsRead', nullable: true, diff --git a/libs/api/domains/notifications/src/lib/notifications.service.ts b/libs/api/domains/notifications/src/lib/notifications.service.ts index c18ff677b447..fe1a7b156a6a 100644 --- a/libs/api/domains/notifications/src/lib/notifications.service.ts +++ b/libs/api/domains/notifications/src/lib/notifications.service.ts @@ -12,6 +12,7 @@ import { NotificationsResponse, NotificationsUnreadCount, NotificationsUnseenCount, + NotificationsMarkAllAsReadResponse, } from './notifications.model' import { notificationMapper } from '../utils/helpers' @@ -86,6 +87,20 @@ export class NotificationsService { } } + async markAllNotificationsAsRead( + user: User, + ): Promise { + this.logger.debug('marking all notifications as read') + + await this.userNotificationsWAuth( + user, + ).meNotificationsControllerMarkAllAsRead() + + return { + success: true, + } + } + async getUnreadCount(user: User): Promise { this.logger.debug('getting unread count') diff --git a/libs/service-portal/information/src/lib/messages.ts b/libs/service-portal/information/src/lib/messages.ts index 3665dfd7306c..7a57137c2294 100644 --- a/libs/service-portal/information/src/lib/messages.ts +++ b/libs/service-portal/information/src/lib/messages.ts @@ -149,6 +149,14 @@ export const mInformationNotifications = defineMessages({ id: 'sp.information-notifications:description', defaultMessage: 'Hér getur þú nálgast tilkynningar þínar.', }, + markAllRead: { + id: 'sp.information-notifications:mark-all-read', + defaultMessage: 'Merkja allt lesið', + }, + allMarkedAsRead: { + id: 'sp.information-notifications:all-marked-as-read', + defaultMessage: 'Allar tilkynningar merktar lesnar', + }, }) export const msg = defineMessages({ diff --git a/libs/service-portal/information/src/screens/Notifications/Notifications.graphql b/libs/service-portal/information/src/screens/Notifications/Notifications.graphql index 3b0d18555fc4..b370a1d97a3d 100644 --- a/libs/service-portal/information/src/screens/Notifications/Notifications.graphql +++ b/libs/service-portal/information/src/screens/Notifications/Notifications.graphql @@ -75,3 +75,9 @@ mutation MarkAllNotificationsAsSeen { success } } + +mutation MarkAllNotificationsAsRead { + markAllNotificationsRead { + success + } +} diff --git a/libs/service-portal/information/src/screens/Notifications/Notifications.tsx b/libs/service-portal/information/src/screens/Notifications/Notifications.tsx index cb11785a5a6f..294bec5bc6cf 100644 --- a/libs/service-portal/information/src/screens/Notifications/Notifications.tsx +++ b/libs/service-portal/information/src/screens/Notifications/Notifications.tsx @@ -1,5 +1,12 @@ import { useState } from 'react' -import { Box, Button, Stack } from '@island.is/island-ui/core' +import { + Box, + Button, + Column, + Columns, + Stack, + toast, +} from '@island.is/island-ui/core' import { useLocale, useNamespaces } from '@island.is/localization' import { FootNote, @@ -11,6 +18,7 @@ import { import { useGetUserNotificationsQuery, + useMarkAllNotificationsAsReadMutation, useMarkUserNotificationAsReadMutation, } from './Notifications.generated' @@ -28,17 +36,27 @@ const UserNotifications = () => { const [loadingMore, setLoadingMore] = useState(false) const [postMarkAsRead] = useMarkUserNotificationAsReadMutation() - - const { data, loading, error, fetchMore } = useGetUserNotificationsQuery({ - variables: { - input: { - limit: DEFAULT_PAGE_SIZE, - before: '', - after: '', - }, + const [postMarkAllAsRead] = useMarkAllNotificationsAsReadMutation({ + onCompleted: () => { + refetch() + toast.success(formatMessage(mInformationNotifications.allMarkedAsRead)) + }, + onError: () => { + toast.error(formatMessage(m.errorTitle)) }, }) + const { data, loading, error, refetch, fetchMore } = + useGetUserNotificationsQuery({ + variables: { + input: { + limit: DEFAULT_PAGE_SIZE, + before: '', + after: '', + }, + }, + }) + const loadMore = (cursor: string) => { if (loadingMore) return setLoadingMore(true) @@ -77,12 +95,30 @@ const UserNotifications = () => { /> - + + + + + + + + From db650c5be1ebe7ab59da9551fe7a545b3ebde1c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9E=C3=B3r=C3=B0ur=20H?= Date: Wed, 15 May 2024 11:14:41 +0000 Subject: [PATCH 02/10] chore(national-registry): Remove all soffia related code (#14733) * Remove all soffia related code * Remove unused * Remove unused * Update person.resolver.ts --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- apps/api/infra/api.ts | 10 - apps/api/project.json | 6 +- apps/api/src/app/app.module.ts | 2 - apps/api/src/app/environments/environment.ts | 12 - apps/application-system/api/project.json | 3 +- .../api/src/environments/environment.ts | 12 - .../infra/external-contracts-tests.ts | 8 +- apps/external-contracts-tests/main.spec.ts | 3 - .../test-suites/index.ts | 1 - .../test-suites/soffia.spec.ts | 25 - .../api/infra/endorsement-system-api.ts | 5 - apps/services/endorsements/api/project.json | 1 - .../api/src/environments/environment.ts | 12 - charts/islandis/values.dev.yaml | 12 - charts/islandis/values.prod.yaml | 8 - charts/islandis/values.staging.yaml | 8 - infra/src/dsl/settings.ts | 4 - .../dsl/value-files-generators/local-setup.ts | 9 - .../domains/air-discount-scheme/project.json | 1 - .../src/lib/nationalRegistry.module.ts | 23 +- .../src/lib/nationalRegistry.service.ts | 133 +----- .../src/lib/resolvers/child.resolver.ts | 5 +- .../lib/resolvers/childCustody.resolver.ts | 3 +- .../lib/resolvers/familyMember.resolver.ts | 62 --- .../src/lib/resolvers/index.ts | 1 - .../src/lib/resolvers/person.resolver.ts | 12 +- .../src/lib/resolvers/user.resolver.ts | 5 +- .../national-registry/src/lib/shared/types.ts | 23 +- .../src/lib/v1/dto/getFamilyDetailInput.ts | 9 - .../src/lib/v1/dto/getMyInfoInput.ts | 10 - .../src/lib/v1/soffia.service.ts | 434 ------------------ .../src/lib/v1/types/child.type.ts | 66 --- .../src/lib/v1/types/familyMember.type.ts | 7 - .../src/lib/v1/types/familyRelation.enum.ts | 5 - .../src/lib/v1/types/index.ts | 4 - .../src/lib/v3/broker.service.ts | 2 +- .../national-registry/src/lib/v3/mapper.ts | 2 +- .../src/lib/v3/types/child.type.ts | 28 ++ .../src/lib/v3/types/index.ts | 2 + .../src/lib/{v1 => v3}/types/user.type.ts | 0 .../src/domains/applications/resolvers.ts | 3 - .../mocks/src/domains/applications/store.ts | 15 +- .../templates/criminal-record/README.md | 4 - .../children-residence-change-v2/README.md | 3 - .../children-residence-change/README.md | 3 - .../financial-statements-inao/README.md | 1 - .../templates/general-petition/README.md | 12 - .../templates/general-petition/project.json | 1 - .../src/fields/SignPetitionView/index.tsx | 4 +- .../general-petition/src/graphql/index.ts | 4 +- .../templates/health-insurance/README.md | 5 - .../templates/mortgage-certificate/README.md | 4 - .../templates/no-debt-certificate/README.md | 2 - libs/clients/national-registry/README.md | 2 +- libs/clients/national-registry/v1/.babelrc | 3 - .../national-registry/v1/.eslintrc.json | 10 - libs/clients/national-registry/v1/README.md | 7 - .../national-registry/v1/jest.config.ts | 16 - .../clients/national-registry/v1/project.json | 25 - .../clients/national-registry/v1/src/index.ts | 6 - .../v1/src/lib/dto/getViewISLBorninMin.dto.ts | 120 ----- .../lib/dto/getViewISLEinstaklingur.dto.ts | 147 ------ .../src/lib/dto/getViewISLFjolskyldan.dto.ts | 102 ---- .../national-registry/v1/src/lib/dto/index.ts | 9 - .../v1/src/lib/nationalRegistryApi.ts | 187 -------- .../v1/src/lib/soapClient.ts | 35 -- .../v1/src/lib/soffiaClient.config.ts | 24 - .../national-registry/v1/tsconfig.json | 13 - .../national-registry/v1/tsconfig.lib.json | 11 - .../national-registry/v1/tsconfig.spec.json | 20 - libs/feature-flags/src/lib/features.ts | 3 - .../portals/admin/regulations-admin/README.md | 9 +- libs/service-portal/education/project.json | 1 - .../src/lib/queries/getNationalChildren.ts | 33 -- .../lib/queries/getNationalRegistryFamily.ts | 40 -- .../lib/queries/getNationalRegistryUser.ts | 31 -- .../src/screens/Child/Child.graphql | 3 +- .../information/src/screens/Child/Child.tsx | 1 - .../src/screens/Spouse/Spouse.graphql | 4 +- .../information/src/screens/Spouse/Spouse.tsx | 6 +- .../src/screens/UserInfo/UserInfo.graphql | 4 +- .../src/screens/UserInfo/UserInfo.tsx | 6 +- .../UserInfoOverview/UserInfoOverview.graphql | 4 +- .../UserInfoOverview/UserInfoOverview.tsx | 4 +- scripts/run-proxies.sh | 14 +- scripts/run-soffia-proxy.sh | 4 - scripts/stop-test-proxies.sh | 2 +- 87 files changed, 91 insertions(+), 1854 deletions(-) delete mode 100644 apps/external-contracts-tests/test-suites/index.ts delete mode 100644 apps/external-contracts-tests/test-suites/soffia.spec.ts delete mode 100644 infra/src/dsl/settings.ts delete mode 100644 libs/api/domains/national-registry/src/lib/resolvers/familyMember.resolver.ts delete mode 100644 libs/api/domains/national-registry/src/lib/v1/dto/getFamilyDetailInput.ts delete mode 100644 libs/api/domains/national-registry/src/lib/v1/dto/getMyInfoInput.ts delete mode 100644 libs/api/domains/national-registry/src/lib/v1/soffia.service.ts delete mode 100644 libs/api/domains/national-registry/src/lib/v1/types/child.type.ts delete mode 100644 libs/api/domains/national-registry/src/lib/v1/types/familyMember.type.ts delete mode 100644 libs/api/domains/national-registry/src/lib/v1/types/familyRelation.enum.ts delete mode 100644 libs/api/domains/national-registry/src/lib/v1/types/index.ts create mode 100644 libs/api/domains/national-registry/src/lib/v3/types/child.type.ts create mode 100644 libs/api/domains/national-registry/src/lib/v3/types/index.ts rename libs/api/domains/national-registry/src/lib/{v1 => v3}/types/user.type.ts (100%) delete mode 100644 libs/clients/national-registry/v1/.babelrc delete mode 100644 libs/clients/national-registry/v1/.eslintrc.json delete mode 100644 libs/clients/national-registry/v1/README.md delete mode 100644 libs/clients/national-registry/v1/jest.config.ts delete mode 100644 libs/clients/national-registry/v1/project.json delete mode 100644 libs/clients/national-registry/v1/src/index.ts delete mode 100644 libs/clients/national-registry/v1/src/lib/dto/getViewISLBorninMin.dto.ts delete mode 100644 libs/clients/national-registry/v1/src/lib/dto/getViewISLEinstaklingur.dto.ts delete mode 100644 libs/clients/national-registry/v1/src/lib/dto/getViewISLFjolskyldan.dto.ts delete mode 100644 libs/clients/national-registry/v1/src/lib/dto/index.ts delete mode 100644 libs/clients/national-registry/v1/src/lib/nationalRegistryApi.ts delete mode 100644 libs/clients/national-registry/v1/src/lib/soapClient.ts delete mode 100644 libs/clients/national-registry/v1/src/lib/soffiaClient.config.ts delete mode 100644 libs/clients/national-registry/v1/tsconfig.json delete mode 100644 libs/clients/national-registry/v1/tsconfig.lib.json delete mode 100644 libs/clients/national-registry/v1/tsconfig.spec.json delete mode 100644 libs/service-portal/information/src/lib/queries/getNationalChildren.ts delete mode 100644 libs/service-portal/information/src/lib/queries/getNationalRegistryFamily.ts delete mode 100644 libs/service-portal/information/src/lib/queries/getNationalRegistryUser.ts delete mode 100755 scripts/run-soffia-proxy.sh diff --git a/apps/api/infra/api.ts b/apps/api/infra/api.ts index 9f99f1d34c31..7dfa73db5403 100644 --- a/apps/api/infra/api.ts +++ b/apps/api/infra/api.ts @@ -1,5 +1,4 @@ import { json, ref, service, ServiceBuilder } from '../../../infra/src/dsl/dsl' -import { settings } from '../../../infra/src/dsl/settings' import { AdrAndMachine, Base, @@ -198,12 +197,6 @@ export const serviceSetup = (services: { prod: 'https://samradapi.island.is', }, FISKISTOFA_ZENTER_CLIENT_ID: '1114', - SOFFIA_SOAP_URL: { - dev: ref((h) => h.svc('https://soffiaprufa.skra.is')), - staging: ref((h) => h.svc('https://soffiaprufa.skra.is')), - prod: ref((h) => h.svc('https://soffia2.skra.is')), - local: ref((h) => h.svc('https://localhost:8443')), - }, HSN_WEB_FORM_ID: '1dimJFHLFYtnhoYEA3JxRK', SESSIONS_API_URL: ref((h) => `http://${h.svc(services.sessionsApi)}`), AUTH_ADMIN_API_PATHS: { @@ -288,12 +281,9 @@ export const serviceSetup = (services: { '/k8s/api/REGULATIONS_FILE_UPLOAD_KEY_PUBLISH', REGULATIONS_FILE_UPLOAD_KEY_PRESIGNED: '/k8s/api/REGULATIONS_FILE_UPLOAD_KEY_PRESIGNED', - SOFFIA_HOST_URL: '/k8s/api/SOFFIA_HOST_URL', CONTENTFUL_ACCESS_TOKEN: '/k8s/api/CONTENTFUL_ACCESS_TOKEN', ZENDESK_CONTACT_FORM_EMAIL: '/k8s/api/ZENDESK_CONTACT_FORM_EMAIL', ZENDESK_CONTACT_FORM_TOKEN: '/k8s/api/ZENDESK_CONTACT_FORM_TOKEN', - SOFFIA_USER: settings.SOFFIA_USER, - SOFFIA_PASS: settings.SOFFIA_PASS, POSTHOLF_CLIENTID: '/k8s/documents/POSTHOLF_CLIENTID', POSTHOLF_CLIENT_SECRET: '/k8s/documents/POSTHOLF_CLIENT_SECRET', POSTHOLF_TOKEN_URL: '/k8s/documents/POSTHOLF_TOKEN_URL', diff --git a/apps/api/project.json b/apps/api/project.json index c9e5fa855111..ae26567962c1 100644 --- a/apps/api/project.json +++ b/apps/api/project.json @@ -81,11 +81,7 @@ "dev": { "executor": "nx:run-commands", "options": { - "commands": [ - "./scripts/run-xroad-proxy.sh", - "./scripts/run-soffia-proxy.sh", - "yarn start api" - ], + "commands": ["./scripts/run-xroad-proxy.sh", "yarn start api"], "parallel": true } }, diff --git a/apps/api/src/app/app.module.ts b/apps/api/src/app/app.module.ts index 141d3f2ae31e..1069adffaa0b 100644 --- a/apps/api/src/app/app.module.ts +++ b/apps/api/src/app/app.module.ts @@ -121,7 +121,6 @@ import { MachineDigitalLicenseClientConfig, } from '@island.is/clients/license-client' import { MunicipalitiesFinancialAidConfig } from '@island.is/clients/municipalities-financial-aid' -import { NationalRegistrySoffiaClientConfig } from '@island.is/clients/national-registry-v1' import { NationalRegistryClientConfig } from '@island.is/clients/national-registry-v2' import { NationalRegistryV3ClientConfig } from '@island.is/clients/national-registry-v3' import { PassportsClientConfig } from '@island.is/clients/passports' @@ -331,7 +330,6 @@ const environment = getConfig PCardClientConfig, DistrictCommissionersLicensesClientConfig, AdrAndMachineLicenseClientConfig, - NationalRegistrySoffiaClientConfig, NationalRegistryV3ClientConfig, FirearmLicenseClientConfig, DisabilityLicenseClientConfig, diff --git a/apps/api/src/app/environments/environment.ts b/apps/api/src/app/environments/environment.ts index dedc028c4442..dcf935a98db5 100644 --- a/apps/api/src/app/environments/environment.ts +++ b/apps/api/src/app/environments/environment.ts @@ -34,12 +34,6 @@ const prodConfig = () => ({ fileStorage: { uploadBucket: process.env.FILE_STORAGE_UPLOAD_BUCKET, }, - nationalRegistry: { - baseSoapUrl: process.env.SOFFIA_SOAP_URL, - user: process.env.SOFFIA_USER, - password: process.env.SOFFIA_PASS, - host: process.env.SOFFIA_HOST_URL, - }, healthInsurance: { wsdlUrl: process.env.XROAD_HEALTH_INSURANCE_WSDLURL, baseUrl: process.env.XROAD_BASE_PATH, @@ -148,12 +142,6 @@ const devConfig = () => ({ fileStorage: { uploadBucket: process.env.FILE_STORAGE_UPLOAD_BUCKET, }, - nationalRegistry: { - baseSoapUrl: 'https://localhost:8443', - user: process.env.SOFFIA_USER ?? '', - password: process.env.SOFFIA_PASS ?? '', - host: 'soffiaprufa.skra.is', - }, healthInsurance: { wsdlUrl: process.env.XROAD_HEALTH_INSURANCE_WSDLURL ?? diff --git a/apps/application-system/api/project.json b/apps/application-system/api/project.json index c12f15277fbe..2f69c1f8bce3 100644 --- a/apps/application-system/api/project.json +++ b/apps/application-system/api/project.json @@ -179,8 +179,7 @@ "commands": [ "yarn nx run api:dev", "yarn nx run services-user-profile:dev", - "yarn start application-system-api", - "scripts/run-soffia-proxy.sh" + "yarn start application-system-api" ], "parallel": true } diff --git a/apps/application-system/api/src/environments/environment.ts b/apps/application-system/api/src/environments/environment.ts index 3e854ff09586..6de3ad51ee9a 100644 --- a/apps/application-system/api/src/environments/environment.ts +++ b/apps/application-system/api/src/environments/environment.ts @@ -72,12 +72,6 @@ const devConfig = { userProfile: { serviceBasePath: 'http://localhost:3366', }, - nationalRegistry: { - baseSoapUrl: 'https://localhost:8443', - user: process.env.SOFFIA_USER ?? '', - password: process.env.SOFFIA_PASS ?? '', - host: 'soffiaprufa.skra.is', - }, islykill: { cert: process.env.ISLYKILL_CERT, passphrase: process.env.ISLYKILL_SERVICE_PASSPHRASE, @@ -156,12 +150,6 @@ const prodConfig = { userProfile: { serviceBasePath: process.env.SERVICE_USER_PROFILE_URL, }, - nationalRegistry: { - baseSoapUrl: process.env.SOFFIA_SOAP_URL, - user: process.env.SOFFIA_USER, - password: process.env.SOFFIA_PASS, - host: process.env.SOFFIA_HOST_URL, - }, islykill: { cert: process.env.ISLYKILL_CERT, passphrase: process.env.ISLYKILL_SERVICE_PASSPHRASE, diff --git a/apps/external-contracts-tests/infra/external-contracts-tests.ts b/apps/external-contracts-tests/infra/external-contracts-tests.ts index 2d252b3e3b60..c737a9fe6ed9 100644 --- a/apps/external-contracts-tests/infra/external-contracts-tests.ts +++ b/apps/external-contracts-tests/infra/external-contracts-tests.ts @@ -1,6 +1,5 @@ import { service, ServiceBuilder } from '../../../infra/src/dsl/dsl' import { Base, NationalRegistry } from '../../../infra/src/dsl/xroad' -import { settings } from '../../../infra/src/dsl/settings' export const serviceSetup = (): ServiceBuilder<'external-contracts-tests'> => { return service('external-contracts-tests') @@ -11,12 +10,7 @@ export const serviceSetup = (): ServiceBuilder<'external-contracts-tests'> => { prod: { schedule: '0 11 * * *' }, }) .env({}) - .secrets({ - SOFFIA_SOAP_URL: '/k8s/api/SOFFIA_SOAP_URL', - SOFFIA_HOST_URL: '/k8s/api/SOFFIA_HOST_URL', - SOFFIA_USER: settings.SOFFIA_USER, - SOFFIA_PASS: settings.SOFFIA_PASS, - }) + .secrets({}) .resources({ limits: { cpu: '1', diff --git a/apps/external-contracts-tests/main.spec.ts b/apps/external-contracts-tests/main.spec.ts index 5afa4e997bf4..e69de29bb2d1 100644 --- a/apps/external-contracts-tests/main.spec.ts +++ b/apps/external-contracts-tests/main.spec.ts @@ -1,3 +0,0 @@ -import * as testSuites from './test-suites/' - -console.log('Forcing esbuild visit to testSuites:', testSuites) diff --git a/apps/external-contracts-tests/test-suites/index.ts b/apps/external-contracts-tests/test-suites/index.ts deleted file mode 100644 index 1dad1b5e4cc3..000000000000 --- a/apps/external-contracts-tests/test-suites/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './soffia.spec' diff --git a/apps/external-contracts-tests/test-suites/soffia.spec.ts b/apps/external-contracts-tests/test-suites/soffia.spec.ts deleted file mode 100644 index 18d27af719a0..000000000000 --- a/apps/external-contracts-tests/test-suites/soffia.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -// NOTE: To run this locally, you'll need to portforward soffia and set -// the environment variable "SOFFIA_SOAP_URL" to https://localhost:8443 -// kubectl port-forward svc/socat-soffia 8443:443 -n socat -import { NationalRegistryApi } from '@island.is/clients/national-registry-v1' - -describe('is.island.external.national', () => { - let client: NationalRegistryApi - beforeAll(async () => { - client = await NationalRegistryApi.instantiateClass({ - baseSoapUrl: process.env.SOFFIA_SOAP_URL!, - user: process.env.SOFFIA_USER!, - password: process.env.SOFFIA_PASS!, - host: process.env.SOFFIA_HOST_URL!, - }) - }) - it('should get user correctly', async () => { - const user = await client.getUser('0101302989') - expect(user.Fulltnafn).toEqual('Gervimaður Ameríka') - }) - it('throws error if user is not found', async () => { - await expect(client.getUser('0123456789')).rejects.toThrow( - 'user with nationalId 0123456789 not found in national Registry', - ) - }) -}) diff --git a/apps/services/endorsements/api/infra/endorsement-system-api.ts b/apps/services/endorsements/api/infra/endorsement-system-api.ts index dccc772987e0..33e2dc2ba6ce 100644 --- a/apps/services/endorsements/api/infra/endorsement-system-api.ts +++ b/apps/services/endorsements/api/infra/endorsement-system-api.ts @@ -1,5 +1,4 @@ import { service, ServiceBuilder } from '../../../../../infra/src/dsl/dsl' -import { settings } from '../../../../../infra/src/dsl/settings' import { Base, Client, @@ -39,10 +38,6 @@ export const serviceSetup = .secrets({ IDENTITY_SERVER_CLIENT_SECRET: '/k8s/endorsement-system-api/IDS-shared-secret', - SOFFIA_HOST_URL: '/k8s/endorsement-system-api/SOFFIA_HOST_URL', - SOFFIA_SOAP_URL: '/k8s/endorsement-system-api/SOFFIA_SOAP_URL', - SOFFIA_USER: settings.SOFFIA_USER, - SOFFIA_PASS: settings.SOFFIA_PASS, NATIONAL_REGISTRY_B2C_CLIENT_SECRET: '/k8s/api/NATIONAL_REGISTRY_B2C_CLIENT_SECRET', }) diff --git a/apps/services/endorsements/api/project.json b/apps/services/endorsements/api/project.json index 30ca99d35578..4923ce4401d9 100644 --- a/apps/services/endorsements/api/project.json +++ b/apps/services/endorsements/api/project.json @@ -90,7 +90,6 @@ "options": { "commands": [ "./scripts/run-xroad-proxy.sh", - "./scripts/run-soffia-proxy.sh", "yarn start services-endorsements-api $NX_OPTIONS" ], "parallel": true diff --git a/apps/services/endorsements/api/src/environments/environment.ts b/apps/services/endorsements/api/src/environments/environment.ts index bb80e29c1ac9..c29823a9e130 100644 --- a/apps/services/endorsements/api/src/environments/environment.ts +++ b/apps/services/endorsements/api/src/environments/environment.ts @@ -8,12 +8,6 @@ const isProductionEnvironment = process.env.NODE_ENV === 'production' const devConfig = { production: isProductionEnvironment, - nationalRegistry: { - baseSoapUrl: 'https://localhost:8443', - user: process.env.SOFFIA_USER ?? '', - password: process.env.SOFFIA_PASS ?? '', - host: 'soffiaprufa.skra.is', - }, auth: { issuer: 'https://identity-server.dev01.devland.is', audience: ['@island.is', '@admin.island.is'], @@ -37,12 +31,6 @@ const devConfig = { const prodConfig = { production: isProductionEnvironment, - nationalRegistry: { - baseSoapUrl: process.env.SOFFIA_SOAP_URL ?? '', - user: process.env.SOFFIA_USER ?? '', - password: process.env.SOFFIA_PASS ?? '', - host: process.env.SOFFIA_HOST_URL ?? '', - }, auth: { issuer: process.env.IDENTITY_SERVER_ISSUER_URL, audience: ['@island.is', '@admin.island.is'], diff --git a/charts/islandis/values.dev.yaml b/charts/islandis/values.dev.yaml index 6106a3a57e96..8397e012cd85 100644 --- a/charts/islandis/values.dev.yaml +++ b/charts/islandis/values.dev.yaml @@ -319,7 +319,6 @@ api: SERVERSIDE_FEATURES_ON: '' SERVICE_DOCUMENTS_BASEPATH: 'http://web-services-documents.services-documents.svc.cluster.local' SESSIONS_API_URL: 'http://web-services-sessions.services-sessions.svc.cluster.local' - SOFFIA_SOAP_URL: 'https://soffiaprufa.skra.is' SYSLUMENN_TIMEOUT: '40000' TELL_US_A_STORY_EMAIL: 's@kogk.is' UNIVERSITY_GATEWAY_API_URL: 'http://web-services-university-gateway.services-university-gateway.svc.cluster.local' @@ -531,9 +530,6 @@ api: REGULATIONS_FILE_UPLOAD_KEY_PUBLISH: '/k8s/api/REGULATIONS_FILE_UPLOAD_KEY_PUBLISH' RLS_PKPASS_API_KEY: '/k8s/api/RLS_PKPASS_API_KEY' SMART_SOLUTIONS_API_URL: '/k8s/api/SMART_SOLUTIONS_API_URL' - SOFFIA_HOST_URL: '/k8s/api/SOFFIA_HOST_URL' - SOFFIA_PASS: '/k8s/service-portal/SOFFIA_PASS' - SOFFIA_USER: '/k8s/service-portal/SOFFIA_USER' SYSLUMENN_HOST: '/k8s/api/SYSLUMENN_HOST' SYSLUMENN_PASSWORD: '/k8s/api/SYSLUMENN_PASSWORD' SYSLUMENN_USERNAME: '/k8s/api/SYSLUMENN_USERNAME' @@ -1359,10 +1355,6 @@ endorsement-system-api: DB_PASS: '/k8s/services-endorsements-api/DB_PASSWORD' IDENTITY_SERVER_CLIENT_SECRET: '/k8s/endorsement-system-api/IDS-shared-secret' NATIONAL_REGISTRY_B2C_CLIENT_SECRET: '/k8s/api/NATIONAL_REGISTRY_B2C_CLIENT_SECRET' - SOFFIA_HOST_URL: '/k8s/endorsement-system-api/SOFFIA_HOST_URL' - SOFFIA_PASS: '/k8s/service-portal/SOFFIA_PASS' - SOFFIA_SOAP_URL: '/k8s/endorsement-system-api/SOFFIA_SOAP_URL' - SOFFIA_USER: '/k8s/service-portal/SOFFIA_USER' securityContext: allowPrivilegeEscalation: false privileged: false @@ -1424,10 +1416,6 @@ external-contracts-tests: schedule: '0 11 * * *' secrets: CONFIGCAT_SDK_KEY: '/k8s/configcat/CONFIGCAT_SDK_KEY' - SOFFIA_HOST_URL: '/k8s/api/SOFFIA_HOST_URL' - SOFFIA_PASS: '/k8s/service-portal/SOFFIA_PASS' - SOFFIA_SOAP_URL: '/k8s/api/SOFFIA_SOAP_URL' - SOFFIA_USER: '/k8s/service-portal/SOFFIA_USER' securityContext: allowPrivilegeEscalation: false privileged: false diff --git a/charts/islandis/values.prod.yaml b/charts/islandis/values.prod.yaml index 8c5c366e169c..c2678d320a48 100644 --- a/charts/islandis/values.prod.yaml +++ b/charts/islandis/values.prod.yaml @@ -309,7 +309,6 @@ api: SERVERSIDE_FEATURES_ON: 'driving-license-use-v1-endpoint-for-v2-comms' SERVICE_DOCUMENTS_BASEPATH: 'http://web-services-documents.services-documents.svc.cluster.local' SESSIONS_API_URL: 'http://web-services-sessions.services-sessions.svc.cluster.local' - SOFFIA_SOAP_URL: 'https://soffia2.skra.is' SYSLUMENN_TIMEOUT: '40000' TELL_US_A_STORY_EMAIL: 'sogur@island.is' UNIVERSITY_GATEWAY_API_URL: 'http://web-services-university-gateway.services-university-gateway.svc.cluster.local' @@ -521,9 +520,6 @@ api: REGULATIONS_FILE_UPLOAD_KEY_PUBLISH: '/k8s/api/REGULATIONS_FILE_UPLOAD_KEY_PUBLISH' RLS_PKPASS_API_KEY: '/k8s/api/RLS_PKPASS_API_KEY' SMART_SOLUTIONS_API_URL: '/k8s/api/SMART_SOLUTIONS_API_URL' - SOFFIA_HOST_URL: '/k8s/api/SOFFIA_HOST_URL' - SOFFIA_PASS: '/k8s/service-portal/SOFFIA_PASS' - SOFFIA_USER: '/k8s/service-portal/SOFFIA_USER' SYSLUMENN_HOST: '/k8s/api/SYSLUMENN_HOST' SYSLUMENN_PASSWORD: '/k8s/api/SYSLUMENN_PASSWORD' SYSLUMENN_USERNAME: '/k8s/api/SYSLUMENN_USERNAME' @@ -1354,10 +1350,6 @@ endorsement-system-api: DB_PASS: '/k8s/services-endorsements-api/DB_PASSWORD' IDENTITY_SERVER_CLIENT_SECRET: '/k8s/endorsement-system-api/IDS-shared-secret' NATIONAL_REGISTRY_B2C_CLIENT_SECRET: '/k8s/api/NATIONAL_REGISTRY_B2C_CLIENT_SECRET' - SOFFIA_HOST_URL: '/k8s/endorsement-system-api/SOFFIA_HOST_URL' - SOFFIA_PASS: '/k8s/service-portal/SOFFIA_PASS' - SOFFIA_SOAP_URL: '/k8s/endorsement-system-api/SOFFIA_SOAP_URL' - SOFFIA_USER: '/k8s/service-portal/SOFFIA_USER' securityContext: allowPrivilegeEscalation: false privileged: false diff --git a/charts/islandis/values.staging.yaml b/charts/islandis/values.staging.yaml index fe29faffd69e..6f15ddb35d3b 100644 --- a/charts/islandis/values.staging.yaml +++ b/charts/islandis/values.staging.yaml @@ -319,7 +319,6 @@ api: SERVERSIDE_FEATURES_ON: '' SERVICE_DOCUMENTS_BASEPATH: 'http://web-services-documents.services-documents.svc.cluster.local' SESSIONS_API_URL: 'http://web-services-sessions.services-sessions.svc.cluster.local' - SOFFIA_SOAP_URL: 'https://soffiaprufa.skra.is' SYSLUMENN_TIMEOUT: '40000' TELL_US_A_STORY_EMAIL: 'sogur@island.is' UNIVERSITY_GATEWAY_API_URL: 'http://web-services-university-gateway.services-university-gateway.svc.cluster.local' @@ -529,9 +528,6 @@ api: REGULATIONS_FILE_UPLOAD_KEY_PUBLISH: '/k8s/api/REGULATIONS_FILE_UPLOAD_KEY_PUBLISH' RLS_PKPASS_API_KEY: '/k8s/api/RLS_PKPASS_API_KEY' SMART_SOLUTIONS_API_URL: '/k8s/api/SMART_SOLUTIONS_API_URL' - SOFFIA_HOST_URL: '/k8s/api/SOFFIA_HOST_URL' - SOFFIA_PASS: '/k8s/service-portal/SOFFIA_PASS' - SOFFIA_USER: '/k8s/service-portal/SOFFIA_USER' SYSLUMENN_HOST: '/k8s/api/SYSLUMENN_HOST' SYSLUMENN_PASSWORD: '/k8s/api/SYSLUMENN_PASSWORD' SYSLUMENN_USERNAME: '/k8s/api/SYSLUMENN_USERNAME' @@ -1230,10 +1226,6 @@ endorsement-system-api: DB_PASS: '/k8s/services-endorsements-api/DB_PASSWORD' IDENTITY_SERVER_CLIENT_SECRET: '/k8s/endorsement-system-api/IDS-shared-secret' NATIONAL_REGISTRY_B2C_CLIENT_SECRET: '/k8s/api/NATIONAL_REGISTRY_B2C_CLIENT_SECRET' - SOFFIA_HOST_URL: '/k8s/endorsement-system-api/SOFFIA_HOST_URL' - SOFFIA_PASS: '/k8s/service-portal/SOFFIA_PASS' - SOFFIA_SOAP_URL: '/k8s/endorsement-system-api/SOFFIA_SOAP_URL' - SOFFIA_USER: '/k8s/service-portal/SOFFIA_USER' securityContext: allowPrivilegeEscalation: false privileged: false diff --git a/infra/src/dsl/settings.ts b/infra/src/dsl/settings.ts deleted file mode 100644 index 486fca89899d..000000000000 --- a/infra/src/dsl/settings.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const settings = { - SOFFIA_USER: '/k8s/service-portal/SOFFIA_USER', - SOFFIA_PASS: '/k8s/service-portal/SOFFIA_PASS', -} diff --git a/infra/src/dsl/value-files-generators/local-setup.ts b/infra/src/dsl/value-files-generators/local-setup.ts index 46c556ff175c..2770615a561e 100644 --- a/infra/src/dsl/value-files-generators/local-setup.ts +++ b/infra/src/dsl/value-files-generators/local-setup.ts @@ -146,15 +146,6 @@ export const getLocalrunValueFile = async ( proxy: { to: target.replace('localhost', 'host.docker.internal'), mode: 'proxyAlways', - // soffia proxy service hack. need to get this proxy to forward host header - // but not really how to do it yet. - ...(target === 'https://localhost:8443' - ? { - injectHeaders: { - Host: 'soffiaprufa.skra.is', - }, - } - : {}), predicateGenerators: [ { matches: { diff --git a/libs/api/domains/air-discount-scheme/project.json b/libs/api/domains/air-discount-scheme/project.json index 1a1374c6f450..403659d11adc 100644 --- a/libs/api/domains/air-discount-scheme/project.json +++ b/libs/api/domains/air-discount-scheme/project.json @@ -39,7 +39,6 @@ "commands": [ "yarn start api", "yarn start air-discount-scheme-backend", - "scripts/run-soffia-proxy.sh", "scripts/run-xroad-proxy.sh" ], "parallel": true diff --git a/libs/api/domains/national-registry/src/lib/nationalRegistry.module.ts b/libs/api/domains/national-registry/src/lib/nationalRegistry.module.ts index 82d692006171..d3e49fbe0bfd 100644 --- a/libs/api/domains/national-registry/src/lib/nationalRegistry.module.ts +++ b/libs/api/domains/national-registry/src/lib/nationalRegistry.module.ts @@ -1,44 +1,23 @@ -import { FeatureFlagModule } from '@island.is/nest/feature-flags' import { Module } from '@nestjs/common' -import { - NationalRegistryApi, - NationalRegistrySoffiaClientConfig, -} from '@island.is/clients/national-registry-v1' import { NationalRegistryService } from './nationalRegistry.service' import { NationalRegistryV3ClientModule } from '@island.is/clients/national-registry-v3' -import { ConfigType } from '@nestjs/config' -import { SoffiaService } from './v1/soffia.service' import { BrokerService } from './v3/broker.service' import { UserResolver, - FamilyMemberResolver, ChildResolver, PersonResolver, ChildCustodyResolver, } from './resolvers' @Module({ - imports: [NationalRegistryV3ClientModule, FeatureFlagModule], + imports: [NationalRegistryV3ClientModule], providers: [ - { - provide: NationalRegistryApi, - useFactory( - config: ConfigType, - ) { - if (config) { - return NationalRegistryApi.instantiateClass(config) - } - }, - inject: [NationalRegistrySoffiaClientConfig.KEY], - }, - SoffiaService, BrokerService, NationalRegistryService, UserResolver, ChildCustodyResolver, PersonResolver, - FamilyMemberResolver, ChildResolver, ], }) diff --git a/libs/api/domains/national-registry/src/lib/nationalRegistry.service.ts b/libs/api/domains/national-registry/src/lib/nationalRegistry.service.ts index b03865be8cb9..011793f99400 100644 --- a/libs/api/domains/national-registry/src/lib/nationalRegistry.service.ts +++ b/libs/api/domains/national-registry/src/lib/nationalRegistry.service.ts @@ -1,166 +1,77 @@ -import { User } from '@island.is/auth-nest-tools' import type { Logger } from '@island.is/logging' import { LOGGER_PROVIDER } from '@island.is/logging' -import { FeatureFlagService, Features } from '@island.is/nest/feature-flags' -import { Inject, Injectable, NotImplementedException } from '@nestjs/common' +import { Inject, Injectable } from '@nestjs/common' import { Birthplace, Citizenship, Housing, Spouse } from './shared/models' import { Name } from './shared/models/name.model' import { SharedPerson } from './shared/types' -import { SoffiaService } from './v1/soffia.service' import { BrokerService } from './v3/broker.service' -type ApiVersion = 'v1' | 'v3' - @Injectable() export class NationalRegistryService { constructor( - private readonly v1: SoffiaService, private readonly v3: BrokerService, - private readonly featureFlagService: FeatureFlagService, @Inject(LOGGER_PROVIDER) private readonly logger: Logger, ) {} - async getApi(user: User, api: ApiVersion = 'v1') { - if (api === 'v3') { - return api - } - - const disableSoffia = await this.featureFlagService.getValue( - Features.disableSoffia, - false, - user, - ) - if (disableSoffia) { - return 'v3' - } else { - return api - } - } - - getPerson(nationalId: string, api: ApiVersion = 'v1', useFakeData?: boolean) { - return api === 'v3' - ? this.v3.getPerson(nationalId, undefined, useFakeData) - : this.v1.getPerson(nationalId) + getPerson(nationalId: string, useFakeData?: boolean) { + return this.v3.getPerson(nationalId, undefined, useFakeData) } getChildCustody(nationalId: string, data?: SharedPerson) { - if (data?.api === 'v3') { - return this.v3.getChildrenCustodyInformation( - nationalId, - data?.rawData, - data?.useFakeData, - ) - } - - return this.v1.getChildCustody(nationalId, data?.rawData) + return this.v3.getChildrenCustodyInformation( + nationalId, + data?.rawData, + data?.useFakeData, + ) } - async getChildDetails( - nationalId: string, - api: ApiVersion, - useFakeData?: boolean, - ) { - if (api === 'v3') { - return this.v3.getChildDetails(nationalId, useFakeData) - } - return this.v1.getPerson(nationalId) + async getChildDetails(nationalId: string, useFakeData?: boolean) { + return this.v3.getChildDetails(nationalId, useFakeData) } - getCustodians( - nationalId: string, - userNationalId: string, - data?: SharedPerson, - ) { - return data?.api === 'v3' - ? this.v3.getCustodians(nationalId, data?.rawData) - : this.v1.getCustodians(nationalId, userNationalId, data?.rawData) + getCustodians(nationalId: string, data?: SharedPerson) { + return this.v3.getCustodians(nationalId, data?.rawData) } - getParents(nationalId: string, data?: SharedPerson, userNationalId?: string) { - return data?.api === 'v3' - ? this.v3.getParents(nationalId, data?.rawData) - : this.v1.getParents(userNationalId, data?.rawData) + getParents(nationalId: string, data?: SharedPerson) { + return this.v3.getParents(nationalId, data?.rawData) } getBirthplace( nationalId: string, data?: SharedPerson, ): Promise { - return data?.api === 'v3' - ? this.v3.getBirthplace(nationalId, data?.rawData) - : this.v1.getBirthplace(nationalId, data?.rawData) + return this.v3.getBirthplace(nationalId, data?.rawData) } getCitizenship( nationalId: string, data?: SharedPerson, ): Promise { - return data?.api === 'v3' - ? this.v3.getCitizenship(nationalId, data?.rawData) - : this.v1.getCitizenship(nationalId, data?.rawData) + return this.v3.getCitizenship(nationalId, data?.rawData) } async getHousing( nationalId: string, data?: SharedPerson, ): Promise { - if (data?.api === 'v1') { - const family = await this.v1.getFamily(nationalId) - return { - domicileId: data?.rawData?.Fjolsknr ?? '', - address: { - code: data?.rawData?.LoghHusk, - lastUpdated: data?.rawData?.LoghHuskBreytt, - streetAddress: - data?.rawData?.Logheimili || data?.address?.streetAddress, - city: - data?.rawData?.LogheimiliSveitarfelag || data?.address?.city || '', - postalCode: data?.rawData?.Postnr || data?.address?.postalCode, - }, - domicileInhabitants: family, - } - } return this.v3.getHousing(nationalId, data?.rawData) } getName(nationalId: string, data?: SharedPerson): Promise { - return data?.api === 'v3' - ? this.v3.getName(nationalId, data?.rawData) - : this.v1.getName(nationalId, data?.rawData) + return this.v3.getName(nationalId, data?.rawData) } getSpouse(nationalId: string, data?: SharedPerson): Promise { - return data?.api === 'v3' - ? this.v3.getSpouse(nationalId, data?.rawData) - : this.v1.getSpouse(nationalId, data?.rawData) + return this.v3.getSpouse(nationalId, data?.rawData) } // Deprecated schemas - getUser(nationalId: string, api: ApiVersion = 'v1') { - return api === 'v3' - ? this.v3.getUser(nationalId) - : this.v1.getUser(nationalId) - } - - getChildren(nationalId: string, api: ApiVersion = 'v1') { - return api === 'v3' - ? this.v3.getChildren(nationalId) - : this.v1.getChildren(nationalId) + getUser(nationalId: string) { + return this.v3.getUser(nationalId) } - getFamily(nationalId: string, api: ApiVersion = 'v1') { - // Returning null in v3 as this schema should have no clients. - return api === 'v3' ? null : this.v1.getFamily(nationalId) - } - - getFamilyMemberDetails( - nationalId: string, - familyMemberNationalId: string, - api: ApiVersion = 'v1', - ) { - // Returning null in v3 as this schema should have no clients. - return api === 'v3' - ? null - : this.v1.getFamilyMemberDetails(nationalId, familyMemberNationalId) + getChildren(nationalId: string) { + return this.v3.getChildren(nationalId) } } diff --git a/libs/api/domains/national-registry/src/lib/resolvers/child.resolver.ts b/libs/api/domains/national-registry/src/lib/resolvers/child.resolver.ts index 4d43745bafe6..e0764181853d 100644 --- a/libs/api/domains/national-registry/src/lib/resolvers/child.resolver.ts +++ b/libs/api/domains/national-registry/src/lib/resolvers/child.resolver.ts @@ -12,7 +12,7 @@ import { import { Audit } from '@island.is/nest/audit' import { NationalRegistryService } from '../nationalRegistry.service' -import { FamilyChild } from '../v1/types' +import { FamilyChild } from '../v3/types' import { Child } from '../shared/models' @UseGuards(IdsUserGuard, ScopesGuard) @@ -32,8 +32,7 @@ export class ChildResolver { async getMyChildren( @CurrentUser() user: AuthUser, ): Promise { - const api = await this.service.getApi(user) - return this.service.getChildren(user.nationalId, api) + return this.service.getChildren(user.nationalId) } @ResolveField('legalResidence', () => String, { nullable: true }) diff --git a/libs/api/domains/national-registry/src/lib/resolvers/childCustody.resolver.ts b/libs/api/domains/national-registry/src/lib/resolvers/childCustody.resolver.ts index aef205d109e3..f652d811284f 100644 --- a/libs/api/domains/national-registry/src/lib/resolvers/childCustody.resolver.ts +++ b/libs/api/domains/national-registry/src/lib/resolvers/childCustody.resolver.ts @@ -46,8 +46,7 @@ export class ChildCustodyResolver { return this.service.getChildDetails( childCustody.nationalId ?? '0', - childCustody.api, - childCustody.api === 'v3' ? childCustody.useFakeData : false, + childCustody.useFakeData, ) } } diff --git a/libs/api/domains/national-registry/src/lib/resolvers/familyMember.resolver.ts b/libs/api/domains/national-registry/src/lib/resolvers/familyMember.resolver.ts deleted file mode 100644 index 74dc86ccc30d..000000000000 --- a/libs/api/domains/national-registry/src/lib/resolvers/familyMember.resolver.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { ApiScope } from '@island.is/auth/scopes' -import { UseGuards } from '@nestjs/common' -import { Resolver, Query, Args, ResolveField, Parent } from '@nestjs/graphql' - -import type { User as AuthUser } from '@island.is/auth-nest-tools' -import { - IdsUserGuard, - ScopesGuard, - CurrentUser, - Scopes, -} from '@island.is/auth-nest-tools' -import { Audit } from '@island.is/nest/audit' -import { FamilyMember, Child } from '../shared/models' -import { GetFamilyInfoInput } from '../v1/dto/getFamilyDetailInput' -import { FamilyChild } from '../v1/types' -import { NationalRegistryService } from '../nationalRegistry.service' - -@UseGuards(IdsUserGuard, ScopesGuard) -@Scopes(ApiScope.meDetails) -@Resolver(() => FamilyMember) -@Audit({ namespace: '@island.is/api/national-registry' }) -export class FamilyMemberResolver { - constructor(private readonly service: NationalRegistryService) {} - - @Query(() => [FamilyMember], { - name: 'nationalRegistryFamily', - nullable: true, - deprecationReason: - 'Up for removal. Query for custodians/parents/children/custodyinfo for the authenticated user instead of this.', - }) - @Audit() - async getMyFamily( - @CurrentUser() user: AuthUser, - ): Promise { - const api = await this.service.getApi(user) - return this.service.getFamily(user.nationalId, api) - } - - @Query(() => Child, { - name: 'nationalRegistryFamilyDetail', - nullable: true, - }) - @Audit() - async getMyFamilyDetail( - @CurrentUser() user: AuthUser, - @Args('input') input: GetFamilyInfoInput, - ): Promise { - const api = await this.service.getApi(user) - return this.service.getFamilyMemberDetails( - user.nationalId, - input.familyMemberNationalId, - api, - ) - } - - @ResolveField('legalResidence', () => String, { nullable: true }) - resolveLegalResidence( - @Parent() { homeAddress, postal }: FamilyChild, - ): string { - return `${homeAddress}, ${postal}` - } -} diff --git a/libs/api/domains/national-registry/src/lib/resolvers/index.ts b/libs/api/domains/national-registry/src/lib/resolvers/index.ts index 63a089f60bca..e66464fe3faa 100644 --- a/libs/api/domains/national-registry/src/lib/resolvers/index.ts +++ b/libs/api/domains/national-registry/src/lib/resolvers/index.ts @@ -1,5 +1,4 @@ export { ChildResolver } from './child.resolver' -export { FamilyMemberResolver } from './familyMember.resolver' export { PersonResolver } from './person.resolver' export { UserResolver } from './user.resolver' export { ChildCustodyResolver } from './childCustody.resolver' diff --git a/libs/api/domains/national-registry/src/lib/resolvers/person.resolver.ts b/libs/api/domains/national-registry/src/lib/resolvers/person.resolver.ts index 8b125ed1bc45..c23510dfc7d0 100644 --- a/libs/api/domains/national-registry/src/lib/resolvers/person.resolver.ts +++ b/libs/api/domains/national-registry/src/lib/resolvers/person.resolver.ts @@ -54,11 +54,9 @@ export class PersonResolver { @Audit() async nationalRegistryPerson( @CurrentUser() user: AuthUser, - @Args('api', { nullable: true }) requestedApi?: 'v1' | 'v3', @Args('useFakeData', { nullable: true }) useFakeData?: boolean, ): Promise { - const api = await this.service.getApi(user, requestedApi) - return this.service.getPerson(user.nationalId, api, useFakeData) + return this.service.getPerson(user.nationalId, useFakeData) } @ResolveField('custodians', () => [Custodian], { @@ -77,11 +75,7 @@ export class PersonResolver { if ( person.nationalIdType === NationalIdType.NATIONAL_REGISTRY_NATIONAL_ID ) { - return this.service.getCustodians( - person.nationalId, - user.nationalId, - person, - ) + return this.service.getCustodians(person.nationalId, person) } return null } @@ -102,7 +96,7 @@ export class PersonResolver { if ( person.nationalIdType === NationalIdType.NATIONAL_REGISTRY_NATIONAL_ID ) { - return this.service.getParents(person.nationalId, person, user.nationalId) + return this.service.getParents(person.nationalId, person) } return null } diff --git a/libs/api/domains/national-registry/src/lib/resolvers/user.resolver.ts b/libs/api/domains/national-registry/src/lib/resolvers/user.resolver.ts index e399a7aa4394..121cb200d205 100644 --- a/libs/api/domains/national-registry/src/lib/resolvers/user.resolver.ts +++ b/libs/api/domains/national-registry/src/lib/resolvers/user.resolver.ts @@ -12,7 +12,7 @@ import { } from '@island.is/auth-nest-tools' import { Audit } from '@island.is/nest/audit' -import { User } from '../v1/types' +import { User } from '../v3/types' import { NationalRegistryUser } from '../shared/models/user.model' import { Citizenship } from '../shared/models/citizenship.model' import { NationalRegistryService } from '../nationalRegistry.service' @@ -31,8 +31,7 @@ export class UserResolver { }) @Audit() async user(@CurrentUser() user: AuthUser): Promise { - const api = await this.service.getApi(user) - return this.service.getUser(user.nationalId, api) + return this.service.getUser(user.nationalId) } @ResolveField('citizenship', () => Citizenship, { nullable: true }) diff --git a/libs/api/domains/national-registry/src/lib/shared/types.ts b/libs/api/domains/national-registry/src/lib/shared/types.ts index b4a2b54e7b01..80e58185417c 100644 --- a/libs/api/domains/national-registry/src/lib/shared/types.ts +++ b/libs/api/domains/national-registry/src/lib/shared/types.ts @@ -1,10 +1,6 @@ import { EinstaklingurDTOAllt } from '@island.is/clients/national-registry-v3' import { registerEnumType } from '@nestjs/graphql' import { Person } from './models' -import { - ISLBorninMin, - ISLEinstaklingur, -} from '@island.is/clients/national-registry-v1' import { ChildCustody } from './models/childCustody.model' export enum Gender { @@ -48,26 +44,11 @@ export type PersonV3 = Person & { rawData?: EinstaklingurDTOAllt | null } -export type V1RawData = ISLEinstaklingur & { - children: Array | null -} - -export type PersonV1 = Person & { - api: 'v1' - useFakeData?: boolean - rawData?: V1RawData -} - -export type SharedPerson = PersonV1 | PersonV3 - -export type ChildCustodyV1 = ChildCustody & { - api: 'v1' - useFakeData?: boolean -} +export type SharedPerson = PersonV3 export type ChildCustodyV3 = ChildCustody & { api: 'v3' useFakeData?: boolean } -export type SharedChildCustody = ChildCustodyV1 | ChildCustodyV3 +export type SharedChildCustody = ChildCustodyV3 diff --git a/libs/api/domains/national-registry/src/lib/v1/dto/getFamilyDetailInput.ts b/libs/api/domains/national-registry/src/lib/v1/dto/getFamilyDetailInput.ts deleted file mode 100644 index 22d9439b45b7..000000000000 --- a/libs/api/domains/national-registry/src/lib/v1/dto/getFamilyDetailInput.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Field, InputType } from '@nestjs/graphql' -import { IsString } from 'class-validator' - -@InputType() -export class GetFamilyInfoInput { - @Field() - @IsString() - familyMemberNationalId!: string -} diff --git a/libs/api/domains/national-registry/src/lib/v1/dto/getMyInfoInput.ts b/libs/api/domains/national-registry/src/lib/v1/dto/getMyInfoInput.ts deleted file mode 100644 index 0de0bfbaa06c..000000000000 --- a/libs/api/domains/national-registry/src/lib/v1/dto/getMyInfoInput.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Field, InputType } from '@nestjs/graphql' - -import { IsString } from 'class-validator' -//TODO REMOVE for proper authentication -@InputType() -export class GetMyInfoInput { - @Field() - @IsString() - nationalId!: string -} diff --git a/libs/api/domains/national-registry/src/lib/v1/soffia.service.ts b/libs/api/domains/national-registry/src/lib/v1/soffia.service.ts deleted file mode 100644 index 907b975cac56..000000000000 --- a/libs/api/domains/national-registry/src/lib/v1/soffia.service.ts +++ /dev/null @@ -1,434 +0,0 @@ -import * as kennitala from 'kennitala' -import some from 'lodash/some' -import { Injectable, ForbiddenException, Inject } from '@nestjs/common' - -import { FamilyMember, FamilyChild, User } from './types' -import { - ISLEinstaklingur, - NationalRegistryApi, -} from '@island.is/clients/national-registry-v1' -import { ChildCustodyV1, PersonV1, V1RawData } from '../shared/types' -import { mapGender, mapMaritalStatus } from '../shared/mapper' -import { - Birthplace, - Citizenship, - Housing, - PersonBase, - Spouse, -} from '../shared/models' -import { LOGGER_PROVIDER } from '@island.is/logging' - -import type { Logger } from '@island.is/logging' -import { formatFamilyChild } from './types/child.type' -import { Name } from '../shared/models/name.model' -import { isDefined } from '@island.is/shared/utils' -import { ExcludesFalse } from '../utils' - -@Injectable() -export class SoffiaService { - constructor( - private nationalRegistryApi: NationalRegistryApi, - @Inject(LOGGER_PROVIDER) private readonly logger: Logger, - ) {} - - async getUser(nationalId: User['nationalId']): Promise { - const user = await this.nationalRegistryApi.getUser(nationalId) - return { - nationalId: user.Kennitala, - name: user.Birtnafn, - firstName: user.Eiginnafn, - middleName: user.Millinafn, - lastName: user.Kenninafn, - fullName: user.Fulltnafn, - gender: mapGender(user.Kyn), - maritalStatus: mapMaritalStatus(user.hju), - religion: user.Trufelag, // TODO: format from user.Tru - familyNr: user.Fjolsknr, - banMarking: { - banMarked: - user.Bannmerking === '1' || user.Bannmerking?.toLowerCase() === 'já', - startDate: user.BannmerkingBreytt, - }, - citizenship: { - code: user.Rikisfang ?? '', - name: user.RikisfangLand ?? '', - }, - address: { - code: user.LoghHusk, - lastUpdated: user.LoghHuskBreytt, - streetAddress: user.Logheimili, - city: user.LogheimiliSveitarfelag, - postalCode: user.Postnr, - }, - birthPlace: { - code: user.FaedSveit, - city: user.Faedingarstadur, - date: user.Faedingardagur, - }, - ...(user.nafnmaka && - user.MakiKt && { - spouse: { - name: user.nafnmaka, - nationalId: user.MakiKt, - cohabitant: user.Sambudarmaki, - }, - }), - } - } - async getPerson(nationalId: string): Promise { - const user = await this.nationalRegistryApi.getUser(nationalId) - - let children = null - try { - children = await this.nationalRegistryApi.getMyChildren(nationalId) - } catch { - //nothing - } - - return { - api: 'v1', - rawData: { ...user, children }, - nationalId: user.Kennitala, - fullName: user.Fulltnafn, - nationalIdType: null, - gender: mapGender(user.Kyn), - religion: user.Trufelag, - exceptionFromDirectMarketing: - user.Bannmerking === '1' || user.Bannmerking?.toLowerCase() === 'já', - maritalStatus: mapMaritalStatus(user.hju), - - //Deprecate below - familyNr: user.Fjolsknr, - firstName: user.Eiginnafn, - middleName: user.Millinafn, - lastName: user.Kenninafn, - banMarking: { - banMarked: - user.Bannmerking === '1' || user.Bannmerking?.toLowerCase() === 'já', - startDate: user.BannmerkingBreytt, - }, - birthPlace: user.Faedingarstadur, - age: kennitala.info(user.Kennitala).age, - birthday: kennitala.info(user.Kennitala).birthday, - legalResidence: `${user.Logheimili}, ${user.Postnr} ${user.LogheimiliSveitarfelag}`, - address: { - code: user.LoghHusk, - lastUpdated: user.LoghHuskBreytt, - streetAddress: user.Logheimili, - city: user.LogheimiliSveitarfelag, - postalCode: user.Postnr, - }, - } - } - - async getFamily(nationalId: User['nationalId']): Promise { - const family = await this.nationalRegistryApi.getMyFamily(nationalId) - - const members = family - .filter((familyMember) => { - return familyMember.Kennitala !== nationalId - }) - .map( - (familyMember) => - ({ - fullName: familyMember.Nafn, - nationalId: familyMember.Kennitala, - gender: mapGender(familyMember.Kyn), - } as FamilyMember), - ) - .sort((a, b) => { - return ( - kennitala.info(b.nationalId).age - kennitala.info(a.nationalId).age - ) - }) - - return members - } - - async getFamilyMemberDetails( - nationalId: User['nationalId'], - familyMemberNationalId: User['nationalId'], - ): Promise { - const family = await this.nationalRegistryApi.getMyFamily(nationalId) - const isAllowed = some(family, ['Kennitala', familyMemberNationalId]) - /** - * Only show data if SSN is part of family. - */ - if (isAllowed) { - const familyMember = await this.nationalRegistryApi.getUser( - familyMemberNationalId, - ) - return { - fullName: familyMember.Fulltnafn, - firstName: familyMember.Eiginnafn, - nationalId: familyMemberNationalId, - gender: familyMember.Kyn, - displayName: familyMember.Birtnafn, - middleName: familyMember.Millinafn, - surname: familyMember.Kenninafn, - lastName: familyMember.Kenninafn, - genderDisplay: familyMember.Kynheiti, - birthday: familyMember.Faedingardagur, - parent1: familyMember.Foreldri1, - nameParent1: familyMember.nafn1, - parent2: familyMember.Foreldri2, - nameParent2: familyMember.Nafn2, - custody1: undefined, - nameCustody1: undefined, - custodyText1: undefined, - custody2: undefined, - nameCustody2: undefined, - custodyText2: undefined, - birthplace: familyMember.Faedingarstadur, - religion: familyMember.Trufelag, - nationality: familyMember.RikisfangLand, - homeAddress: familyMember.Logheimili, - municipality: familyMember.LogheimiliSveitarfelag, - postal: `${familyMember.Postnr} ${familyMember.LogheimiliSveitarfelag}`, // Same structure as familyChild.Postaritun - } - } else { - throw new ForbiddenException('Family member not found') - } - } - - async getChildren( - nationalId: User['nationalId'], - data?: V1RawData, - ): Promise { - const myChildren = - data?.children ?? - (await this.nationalRegistryApi.getMyChildren(nationalId)) - const members = myChildren - .filter((familyChild) => { - const isNotUser = familyChild.Barn !== nationalId - const isUnderEighteen = kennitala.info(familyChild.Barn).age < 18 - - return isNotUser && isUnderEighteen - }) - .map((familyChild) => formatFamilyChild(familyChild)) - .filter(isDefined) - .sort((a, b) => { - return ( - kennitala.info(b.nationalId).age - kennitala.info(a.nationalId).age - ) - }) - - return members - } - - async getChildCustody( - nationalId?: string, - data?: V1RawData, - ): Promise | null> { - if (nationalId || data) { - //just some nationalId fallback which won't ever get used - const children = await this.getChildren(nationalId ?? '0', data) - - const childrenData = children.map((c) => { - return { - api: 'v1' as ChildCustodyV1['api'], - nationalId: c.nationalId, - fullName: c.fullName, - } - }) - - return childrenData - } - - return null - } - - async getChildDetails( - nationalId?: string, - data?: V1RawData, - ): Promise | null> { - if (nationalId || data) { - //just some nationalId fallback which won't ever get used - const children = await this.getChildren(nationalId ?? '0', data) - - const childrenData = children.map((c) => { - return { - api: 'v1' as PersonV1['api'], - nationalId: c.nationalId, - fullName: c.fullName, - nationalIdType: null, - gender: c.gender ? mapGender(c.gender) : undefined, - religion: c.religion, - exceptionFromDirectMarketing: undefined, - maritalStatus: undefined, - - //Deprecate below - familyNr: undefined, - firstName: c.firstName, - middleName: c.middleName, - lastName: c.lastName, - banMarking: undefined, - birthPlace: c.birthplace, - age: kennitala.info(c.nationalId).age, - birthday: kennitala.info(c.nationalId).birthday, - legalResidence: `${c.homeAddress}, ${c.postal}`, - address: { - code: undefined, - lastUpdated: undefined, - streetAddress: c.homeAddress, - city: c.municipality ?? '', - postalCode: c.postal, - }, - } - }) - - return childrenData - } - - return null - } - - async getParents( - nationalId?: string, - data?: V1RawData, - ): Promise | null> { - if (nationalId || data) { - //just some nationalId fallback which won't ever get used - const children = await this.getChildren(nationalId ?? '0', data) - const child = children.find((c) => c?.nationalId === nationalId) ?? null - - if (!child) { - return null - } - - return [ - child.parent1 && - child.nameParent1 && { - nationalId: child.parent1, - fullName: child.nameParent1, - }, - child.parent2 && - child.nameParent2 && { - nationalId: child.parent2, - fullName: child.nameParent2, - }, - //temporary, until we remove v1 - ].filter(Boolean as unknown as ExcludesFalse) - } - return null - } - - async getCustodians( - nationalId: string, - parentNationalId: string, - data?: V1RawData, - ): Promise | null> { - const children = await this.getChildren(parentNationalId ?? '0', data) - const child = children.find((c) => c?.nationalId === nationalId) ?? null - - if (!child) { - return null - } - - return [ - child.custody1 && - child.nameCustody1 && { - nationalId: child.custody1, - fullName: child.nameCustody1, - text: child.custodyText1, - }, - child.custody2 && - child.nameCustody2 && { - nationalId: child.custody2, - fullName: child.nameCustody2, - text: child.custodyText2, - }, - ].filter(Boolean as unknown as ExcludesFalse) - } - - async getBirthplace( - nationalId: string, - data?: V1RawData, - ): Promise { - const birthplace = data - ? (data as ISLEinstaklingur) - : (await this.getPerson(nationalId)).rawData - - return birthplace - ? { - location: birthplace.Faedingarstadur, - municipalityText: birthplace.FaedSveit, - dateOfBirth: new Date(birthplace.Faedingardagur), - } - : null - } - - async getCitizenship( - nationalId: string, - data?: V1RawData, - ): Promise { - const citizenship = data - ? (data as ISLEinstaklingur) - : (await this.getPerson(nationalId)).rawData - - return citizenship && citizenship.Rikisfang && citizenship.RikisfangLand - ? { - code: citizenship.Rikisfang ?? null, - name: citizenship.RikisfangLand ?? null, - } - : null - } - - async getName(nationalId: string, data?: V1RawData): Promise { - const name = data - ? (data as ISLEinstaklingur) - : (await this.getPerson(nationalId)).rawData - - return name - ? { - firstName: name.Eiginnafn, - middleName: name.Millinafn, - lastName: name.Kenninafn, - fullName: name.Fulltnafn, - } - : null - } - - async getSpouse( - nationalId: string, - data?: V1RawData, - ): Promise { - const spouse = data - ? (data as ISLEinstaklingur) - : (await this.getPerson(nationalId)).rawData - - return spouse && spouse.MakiKt && spouse.nafnmaka - ? { - fullName: spouse.nafnmaka, - name: spouse.nafnmaka, - nationalId: spouse.MakiKt, - maritalStatus: mapMaritalStatus(spouse.hju), - cohabitant: spouse.Sambudarmaki, - } - : null - } - - async getHousing( - nationalId: string, - data?: V1RawData, - ): Promise { - const family = await this.getFamily(nationalId) - const person = data - ? (data as ISLEinstaklingur) - : (await this.getPerson(nationalId)).rawData - - return person && family && person.Fjolsknr - ? { - domicileId: person.Fjolsknr, - address: { - code: person.LoghHusk, - lastUpdated: person.LoghHuskBreytt, - streetAddress: person.Logheimili, - city: person.LogheimiliSveitarfelag, - postalCode: person.Postnr, - }, - domicileInhabitants: family, - } - : null - } -} diff --git a/libs/api/domains/national-registry/src/lib/v1/types/child.type.ts b/libs/api/domains/national-registry/src/lib/v1/types/child.type.ts deleted file mode 100644 index 3c1a3348ab72..000000000000 --- a/libs/api/domains/national-registry/src/lib/v1/types/child.type.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { ISLBorninMin } from '@island.is/clients/national-registry-v1' - -export interface FamilyChild { - nationalId: string // Barn - fullName: string // FulltNafn - displayName?: string // BirtNafn - firstName?: string // Eiginnafn - middleName?: string // Millinafn - surname?: string // Kenninafn - lastName?: string // Kenninafn - gender?: string // Kyn - genderDisplay?: string // Kynheiti - birthday?: string // Faedingardagur - parent1?: string // Foreldri1 - nameParent1?: string // NafnForeldri1 - parent2?: string // Foreldri2 - nameParent2?: string // NafnForeldri2 - custody1?: string // Forsja1 - nameCustody1?: string // NafnForsja1 - custodyText1?: string // Forsjatxt1 - custody2?: string // Forsja2 - nameCustody2?: string // NafnForsja2 - custodyText2?: string // Forsjatxt2 - birthplace?: string // Faedingarstadur - religion?: string // Trufelag - nationality?: string // Rikisfang - homeAddress?: string // Logheimili - municipality?: string // Sveitarfelag - postal?: string // Postaritun -} -export function formatFamilyChild( - familyChild: ISLBorninMin | null | undefined, -): FamilyChild | null { - if (!familyChild) { - return null - } - - return { - fullName: familyChild.FulltNafn, - nationalId: familyChild.Barn, - gender: familyChild.Kyn, - displayName: familyChild.BirtNafn, - firstName: familyChild.Eiginnafn, - lastName: familyChild.Kenninafn, - middleName: familyChild.Millinafn, - surname: familyChild.Kenninafn, - genderDisplay: familyChild.Kynheiti, - birthday: familyChild.Faedingardagur, - parent1: familyChild.Foreldri1, - nameParent1: familyChild.NafnForeldri1, - parent2: familyChild.Foreldri2, - nameParent2: familyChild.NafnForeldri2, - custody1: familyChild.Forsja1, - nameCustody1: familyChild.NafnForsja1, - custodyText1: familyChild.Forsjatxt1, - custody2: familyChild.Forsja2, - nameCustody2: familyChild.NafnForsja2, - custodyText2: familyChild.Forsjatxt2, - birthplace: familyChild.Faedingarstadur, - religion: familyChild.Trufelag, - nationality: familyChild.Rikisfang, - homeAddress: familyChild.Logheimili, - municipality: familyChild.Sveitarfelag, - postal: familyChild.Postaritun, - } -} diff --git a/libs/api/domains/national-registry/src/lib/v1/types/familyMember.type.ts b/libs/api/domains/national-registry/src/lib/v1/types/familyMember.type.ts deleted file mode 100644 index 5651a20ce96e..000000000000 --- a/libs/api/domains/national-registry/src/lib/v1/types/familyMember.type.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Gender } from '../../shared/types' - -export interface FamilyMember { - nationalId: string - fullName: string - gender: Gender -} diff --git a/libs/api/domains/national-registry/src/lib/v1/types/familyRelation.enum.ts b/libs/api/domains/national-registry/src/lib/v1/types/familyRelation.enum.ts deleted file mode 100644 index 9318d4cdc518..000000000000 --- a/libs/api/domains/national-registry/src/lib/v1/types/familyRelation.enum.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum FamilyRelation { - CHILD = 'child', - SPOUSE = 'spouse', - PARENT = 'parent', -} diff --git a/libs/api/domains/national-registry/src/lib/v1/types/index.ts b/libs/api/domains/national-registry/src/lib/v1/types/index.ts deleted file mode 100644 index 880216ba5f70..000000000000 --- a/libs/api/domains/national-registry/src/lib/v1/types/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export { FamilyMember } from './familyMember.type' -export { FamilyRelation } from './familyRelation.enum' -export { User } from './user.type' -export { FamilyChild } from './child.type' diff --git a/libs/api/domains/national-registry/src/lib/v3/broker.service.ts b/libs/api/domains/national-registry/src/lib/v3/broker.service.ts index 6fd47db2c066..21fff5df8087 100644 --- a/libs/api/domains/national-registry/src/lib/v3/broker.service.ts +++ b/libs/api/domains/national-registry/src/lib/v3/broker.service.ts @@ -7,7 +7,7 @@ import { EinstaklingurDTOLoghTengsl, NationalRegistryV3ClientService, } from '@island.is/clients/national-registry-v3' -import { FamilyChild, User } from '../v1/types' +import { FamilyChild, User } from './types' import { formatPersonDiscriminated, formatAddress, diff --git a/libs/api/domains/national-registry/src/lib/v3/mapper.ts b/libs/api/domains/national-registry/src/lib/v3/mapper.ts index f588e01c6cd1..e64e4893368a 100644 --- a/libs/api/domains/national-registry/src/lib/v3/mapper.ts +++ b/libs/api/domains/national-registry/src/lib/v3/mapper.ts @@ -29,7 +29,7 @@ import { Housing } from '../shared/models/housing.model' import { Name } from '../shared/models/name.model' import * as kennitala from 'kennitala' import { maskString, isDefined } from '@island.is/shared/utils' -import { FamilyChild, User } from '../v1/types' +import { FamilyChild, User } from './types' export function formatPersonDiscriminated( individual?: EinstaklingurDTOAllt | null, diff --git a/libs/api/domains/national-registry/src/lib/v3/types/child.type.ts b/libs/api/domains/national-registry/src/lib/v3/types/child.type.ts new file mode 100644 index 000000000000..4c01ab06a432 --- /dev/null +++ b/libs/api/domains/national-registry/src/lib/v3/types/child.type.ts @@ -0,0 +1,28 @@ +export interface FamilyChild { + nationalId: string // Barn + fullName: string // FulltNafn + displayName?: string // BirtNafn + firstName?: string // Eiginnafn + middleName?: string // Millinafn + surname?: string // Kenninafn + lastName?: string // Kenninafn + gender?: string // Kyn + genderDisplay?: string // Kynheiti + birthday?: string // Faedingardagur + parent1?: string // Foreldri1 + nameParent1?: string // NafnForeldri1 + parent2?: string // Foreldri2 + nameParent2?: string // NafnForeldri2 + custody1?: string // Forsja1 + nameCustody1?: string // NafnForsja1 + custodyText1?: string // Forsjatxt1 + custody2?: string // Forsja2 + nameCustody2?: string // NafnForsja2 + custodyText2?: string // Forsjatxt2 + birthplace?: string // Faedingarstadur + religion?: string // Trufelag + nationality?: string // Rikisfang + homeAddress?: string // Logheimili + municipality?: string // Sveitarfelag + postal?: string // Postaritun +} diff --git a/libs/api/domains/national-registry/src/lib/v3/types/index.ts b/libs/api/domains/national-registry/src/lib/v3/types/index.ts new file mode 100644 index 000000000000..3977fafb41c8 --- /dev/null +++ b/libs/api/domains/national-registry/src/lib/v3/types/index.ts @@ -0,0 +1,2 @@ +export { User } from './user.type' +export { FamilyChild } from './child.type' diff --git a/libs/api/domains/national-registry/src/lib/v1/types/user.type.ts b/libs/api/domains/national-registry/src/lib/v3/types/user.type.ts similarity index 100% rename from libs/api/domains/national-registry/src/lib/v1/types/user.type.ts rename to libs/api/domains/national-registry/src/lib/v3/types/user.type.ts diff --git a/libs/api/mocks/src/domains/applications/resolvers.ts b/libs/api/mocks/src/domains/applications/resolvers.ts index 3119a266e421..ae857259b2d4 100644 --- a/libs/api/mocks/src/domains/applications/resolvers.ts +++ b/libs/api/mocks/src/domains/applications/resolvers.ts @@ -20,9 +20,6 @@ export const resolvers: Resolvers = { applicationApplication: (parent, args) => { return store.applications.find((a) => a.id === args.input.id) || null }, - nationalRegistryFamily: () => { - return store.familyMembers - }, }, Mutation: { createApplication: (parent, args) => { diff --git a/libs/api/mocks/src/domains/applications/store.ts b/libs/api/mocks/src/domains/applications/store.ts index a507a91db21d..ed382b5f7d09 100644 --- a/libs/api/mocks/src/domains/applications/store.ts +++ b/libs/api/mocks/src/domains/applications/store.ts @@ -1,5 +1,4 @@ import { application } from './factories' -import { NationalRegistryFamilyMember } from '../../types' import { createStore, faker } from '@island.is/shared/mocking' export const store = createStore(() => { @@ -9,18 +8,6 @@ export const store = createStore(() => { .list(10) .concat([application({ applicant: '0000000000' })]) .concat([application({ applicant: '0000000000', typeId: 'ParentalLeave' })]) - const familyMembers: NationalRegistryFamilyMember[] = [ - { - nationalId: '1234567890', - fullName: 'Jóna Jónsdóttir', - gender: 'FEMALE', - }, - { - nationalId: '0987654321', - fullName: 'Bjarni sonur þinn', - gender: 'MALE', - }, - ] - return { applications, familyMembers } + return { applications } }) diff --git a/libs/application/templates/criminal-record/README.md b/libs/application/templates/criminal-record/README.md index acc0dcb9748f..2ede828be807 100644 --- a/libs/application/templates/criminal-record/README.md +++ b/libs/application/templates/criminal-record/README.md @@ -26,10 +26,6 @@ First you need to run this (maybe only once?): `aws eks update-kubeconfig --name dev-cluster01 --profile --region eu-west-1` -Then: - -`kubectl port-forward svc/socat-soffia 8443:443 -n socat` - Fetch all necessary secrets ### Running locally diff --git a/libs/application/templates/family-matters/children-residence-change-v2/README.md b/libs/application/templates/family-matters/children-residence-change-v2/README.md index 2e7ed29ad556..d8e8181e2c07 100644 --- a/libs/application/templates/family-matters/children-residence-change-v2/README.md +++ b/libs/application/templates/family-matters/children-residence-change-v2/README.md @@ -26,9 +26,6 @@ Prerequisites - Export aws variables `aws eks update-kubeconfig --name dev-cluster01` -3. Socat Þjóðskrá - -- Run `kubectl port-forward svc/socat-soffia 8443:443 -n socat` - Keep this process running while running the project ### Test user diff --git a/libs/application/templates/family-matters/children-residence-change/README.md b/libs/application/templates/family-matters/children-residence-change/README.md index 2e7ed29ad556..d8e8181e2c07 100644 --- a/libs/application/templates/family-matters/children-residence-change/README.md +++ b/libs/application/templates/family-matters/children-residence-change/README.md @@ -26,9 +26,6 @@ Prerequisites - Export aws variables `aws eks update-kubeconfig --name dev-cluster01` -3. Socat Þjóðskrá - -- Run `kubectl port-forward svc/socat-soffia 8443:443 -n socat` - Keep this process running while running the project ### Test user diff --git a/libs/application/templates/financial-statements-inao/README.md b/libs/application/templates/financial-statements-inao/README.md index ef9fe20e1cfd..901ac254516f 100644 --- a/libs/application/templates/financial-statements-inao/README.md +++ b/libs/application/templates/financial-statements-inao/README.md @@ -24,7 +24,6 @@ yarn nx run application-system-api:migrate and both proxies ```bash -kubectl port-forward svc/socat-soffia 8443:443 -n socat kubectl -n socat port-forward svc/socat-xroad 8081:80 ``` diff --git a/libs/application/templates/general-petition/README.md b/libs/application/templates/general-petition/README.md index 9620da6c408d..c6fee5049ea3 100644 --- a/libs/application/templates/general-petition/README.md +++ b/libs/application/templates/general-petition/README.md @@ -30,24 +30,12 @@ Prerequisites - `brew install kubectl` - You have [AWS Secrets](../../../../handbook/repository/aws-secrets.md) configured -1. Make sure the following environment variables are set: - -```bash -SOFFIA_PASS -SOFFIA_USER -``` - - A good way to get environment variables is to run `yarn get-secrets service-portal` 2. Get kubeconfig - Export aws variables `aws eks update-kubeconfig --name dev-cluster01` -3. Socat Þjóðskrá - -- Run `kubectl port-forward svc/socat-soffia 8443:443 -n socat` -- Keep this process running while running the project - ### Current user companies provider Make sure the following environment variable is set diff --git a/libs/application/templates/general-petition/project.json b/libs/application/templates/general-petition/project.json index ec2bb9f146b8..364872cf6d16 100644 --- a/libs/application/templates/general-petition/project.json +++ b/libs/application/templates/general-petition/project.json @@ -46,7 +46,6 @@ "executor": "nx:run-commands", "options": { "commands": [ - "kubectl port-forward svc/socat-soffia 8443:443 -n socat &", "yarn start application-system-api $NX_OPTIONS &", "yarn start application-system-form $NX_OPTIONS &", "yarn start services-endorsements-api $NX_OPTIONS &", diff --git a/libs/application/templates/general-petition/src/fields/SignPetitionView/index.tsx b/libs/application/templates/general-petition/src/fields/SignPetitionView/index.tsx index e83e3e03d0c8..e7eae8b418b9 100644 --- a/libs/application/templates/general-petition/src/fields/SignPetitionView/index.tsx +++ b/libs/application/templates/general-petition/src/fields/SignPetitionView/index.tsx @@ -38,9 +38,7 @@ const SignPetitionView: FC> = ({ const petitionList = petitionData as EndorsementList const listClosed = new Date() >= new Date(petitionList.closedDate) const [createEndorsement, { loading }] = useMutation(EndorseList) - const { data: userData } = useQuery(GetFullName, { - variables: { api: 'v3' }, - }) + const { data: userData } = useQuery(GetFullName) useEffect(() => setHasSigned(checkForSigned), [checkForSigned]) diff --git a/libs/application/templates/general-petition/src/graphql/index.ts b/libs/application/templates/general-petition/src/graphql/index.ts index a196cd7330ae..915979888e63 100644 --- a/libs/application/templates/general-petition/src/graphql/index.ts +++ b/libs/application/templates/general-petition/src/graphql/index.ts @@ -26,8 +26,8 @@ export const GetSingleEndorsementList = gql` ` export const GetFullName = gql` - query nationalRegistryPersonQuery($api: String, $useFakeData: Boolean) { - nationalRegistryPerson(api: $api, useFakeData: $useFakeData) { + query nationalRegistryPersonQuery($useFakeData: Boolean) { + nationalRegistryPerson(useFakeData: $useFakeData) { fullName } } diff --git a/libs/application/templates/health-insurance/README.md b/libs/application/templates/health-insurance/README.md index 16f2aea791e2..f58b98abc5c8 100644 --- a/libs/application/templates/health-insurance/README.md +++ b/libs/application/templates/health-insurance/README.md @@ -41,11 +41,6 @@ There are additional steps required to run this template locally - Run `yarn get-secrets service-portal` -2. Socat Þjóðskrá - -- Run `kubectl port-forward svc/socat-soffia 8443:443 -n socat` -- Keep this process running while running the project - ### User Profile Provider (optional) - Follow the instructions to start the user profule service in the handbook [here](https://docs.devland.is/apps/services/user-profile). diff --git a/libs/application/templates/mortgage-certificate/README.md b/libs/application/templates/mortgage-certificate/README.md index 442cdb118ebb..233a2bf48987 100644 --- a/libs/application/templates/mortgage-certificate/README.md +++ b/libs/application/templates/mortgage-certificate/README.md @@ -26,10 +26,6 @@ First you need to run this (maybe only once?): `aws eks update-kubeconfig --name dev-cluster01 --profile --region eu-west-1` -Then: - -`kubectl port-forward svc/socat-soffia 8443:443 -n socat` - Fetch all necessary secrets ### Running locally diff --git a/libs/application/templates/no-debt-certificate/README.md b/libs/application/templates/no-debt-certificate/README.md index d2baafc00d58..2e7261dc1b6d 100644 --- a/libs/application/templates/no-debt-certificate/README.md +++ b/libs/application/templates/no-debt-certificate/README.md @@ -28,8 +28,6 @@ First you need to run this (maybe only once?): Then: -`kubectl port-forward svc/socat-soffia 8443:443 -n socat` - Fetch all necessary secrets ### Running locally diff --git a/libs/clients/national-registry/README.md b/libs/clients/national-registry/README.md index 67f5d2e8c0c3..fe9dacf2d32b 100644 --- a/libs/clients/national-registry/README.md +++ b/libs/clients/national-registry/README.md @@ -1,5 +1,5 @@ # National Registry Clients -V1 is soap service from national registry +V1 has been removed. V2 is x road connected service from national registry V3 is b2c azure service from national registry diff --git a/libs/clients/national-registry/v1/.babelrc b/libs/clients/national-registry/v1/.babelrc deleted file mode 100644 index 78b516e9714c..000000000000 --- a/libs/clients/national-registry/v1/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "presets": ["@nrwl/js/babel"] -} diff --git a/libs/clients/national-registry/v1/.eslintrc.json b/libs/clients/national-registry/v1/.eslintrc.json deleted file mode 100644 index 5bc995111210..000000000000 --- a/libs/clients/national-registry/v1/.eslintrc.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": ["../../../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "rules": {}, - "overrides": [ - { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], "rules": {} }, - { "files": ["*.ts", "*.tsx"], "rules": {} }, - { "files": ["*.js", "*.jsx"], "rules": {} } - ] -} diff --git a/libs/clients/national-registry/v1/README.md b/libs/clients/national-registry/v1/README.md deleted file mode 100644 index c442229fbb0f..000000000000 --- a/libs/clients/national-registry/v1/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# National Registry V1 Client - -This library was generated with [Nx](https://nx.dev). - -## Running unit tests - -Run `nx test clients-national-registry-v1` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/clients/national-registry/v1/jest.config.ts b/libs/clients/national-registry/v1/jest.config.ts deleted file mode 100644 index 11dce0800c99..000000000000 --- a/libs/clients/national-registry/v1/jest.config.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* eslint-disable */ -export default { - displayName: 'clients-national-registry', - preset: './jest.preset.js', - rootDir: '../../../..', - roots: [__dirname], - globals: {}, - transform: { - '^.+\\.[tj]sx?$': [ - 'ts-jest', - { tsconfig: `${__dirname}/tsconfig.spec.json` }, - ], - }, - moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - coverageDirectory: '/coverage/libs/clients/national-registry/v1', -} diff --git a/libs/clients/national-registry/v1/project.json b/libs/clients/national-registry/v1/project.json deleted file mode 100644 index 49cf90807c1b..000000000000 --- a/libs/clients/national-registry/v1/project.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "clients-national-registry-v1", - "$schema": "../../../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "libs/clients/national-registry/v1/src", - "projectType": "library", - "targets": { - "lint": { - "executor": "@nx/linter:eslint", - "options": { - "lintFilePatterns": [ - "libs/clients/national-registry/v1/**/*.{ts,tsx,js,jsx}" - ] - } - }, - "test": { - "executor": "@nx/jest:jest", - "outputs": ["{workspaceRoot}/coverage/libs/clients/national-registry/v1"], - "options": { - "jestConfig": "libs/clients/national-registry/v1/jest.config.ts", - "passWithNoTests": true - } - } - }, - "tags": ["lib:client", "scope:client"] -} diff --git a/libs/clients/national-registry/v1/src/index.ts b/libs/clients/national-registry/v1/src/index.ts deleted file mode 100644 index 71cfb2ac716d..000000000000 --- a/libs/clients/national-registry/v1/src/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export { ISLFjolskyldan, ISLEinstaklingur, ISLBorninMin } from './lib/dto' -export { - NationalRegistryApi, - NationalRegistryConfig, -} from './lib/nationalRegistryApi' -export { NationalRegistrySoffiaClientConfig } from './lib/soffiaClient.config' diff --git a/libs/clients/national-registry/v1/src/lib/dto/getViewISLBorninMin.dto.ts b/libs/clients/national-registry/v1/src/lib/dto/getViewISLBorninMin.dto.ts deleted file mode 100644 index b0e441649a03..000000000000 --- a/libs/clients/national-registry/v1/src/lib/dto/getViewISLBorninMin.dto.ts +++ /dev/null @@ -1,120 +0,0 @@ -export interface GetViewISLBorninMinDto { - message: string - table: Table - success: boolean -} - -interface Table { - schema: Schema - diffgram: Diffgram -} - -interface Diffgram { - DocumentElement: DocumentElement -} - -interface DocumentElement { - ISLBorninMin: ISLBorninMin[] -} - -export interface ISLBorninMin { - attributes: ISLBorninMinAttributes - Barn: string - FulltNafn: string - BirtNafn?: string - Millinafn?: string - Kenninafn?: string - Kyn?: string - Kynheiti?: string - Faedingardagur?: string - Foreldri1?: string - NafnForeldri1?: string - Foreldri2?: string - NafnForeldri2?: string - Forsja1?: string - NafnForsja1?: string - Forsjatxt1?: string - Forsja2?: string - NafnForsja2?: string - Forsjatxt2?: string - Faedingarstadur?: string - Trufelag?: string - Rikisfang?: string - Logheimili?: string - Sveitarfelag?: string - Postaritun?: string - Eiginnafn?: string -} - -interface ISLBorninMinAttributes { - 'diffgr:id': string - 'msdata:rowOrder': string - 'diffgr:hasChanges': string -} - -interface Schema { - attributes: SchemaAttributes - element: SchemaElement -} - -interface SchemaAttributes { - id: string -} - -interface SchemaElement { - attributes: PurpleAttributes - complexType: PurpleComplexType -} - -interface PurpleAttributes { - name: string - 'msdata:IsDataSet': string - 'msdata:MainDataTable': string - 'msdata:UseCurrentLocale': string -} - -interface PurpleComplexType { - choice: Choice -} - -interface Choice { - attributes: ChoiceAttributes - element: ChoiceElement -} - -interface ChoiceAttributes { - minOccurs: string - maxOccurs: string -} - -interface ChoiceElement { - attributes: FluffyAttributes - complexType: FluffyComplexType -} - -interface FluffyAttributes { - name: string -} - -interface FluffyComplexType { - sequence: Sequence -} - -interface Sequence { - element: ElementElement[] -} - -interface ElementElement { - attributes: TentacledAttributes -} - -interface TentacledAttributes { - name: string - 'msprop:ColumnId': string - type: Type - minOccurs: string -} - -enum Type { - XsString = 'xs:string', -} diff --git a/libs/clients/national-registry/v1/src/lib/dto/getViewISLEinstaklingur.dto.ts b/libs/clients/national-registry/v1/src/lib/dto/getViewISLEinstaklingur.dto.ts deleted file mode 100644 index dd04d85b27c2..000000000000 --- a/libs/clients/national-registry/v1/src/lib/dto/getViewISLEinstaklingur.dto.ts +++ /dev/null @@ -1,147 +0,0 @@ -export interface GetViewISLEinstaklingurDto { - message: string - table: Table - success: boolean -} - -interface Table { - schema: Schema - diffgram: Diffgram -} - -interface Diffgram { - DocumentElement: DocumentElement -} - -interface DocumentElement { - ISLEinstaklingur: ISLEinstaklingur -} - -export interface ISLEinstaklingur { - attributes: ISLEinstaklingurAttributes - Kennitala: string - Birtnafn: string - Eiginnafn: string - Millinafn: string - Kenninafn: string - Fulltnafn: string - hju: string - hjuskapur: string - hjuundir: string - HjuBreytt: string - Samb: string - Sambud: string - Sambudbreytt: string - HjuSamdags: string - HjuSamBreytt: string - MakiKt: string - nafnmaka: string - Sambudarmaki: string - Sambudmaki: string - Tru: string - Trufelag: string - TruBreytt: string - Kyn: string - Kynheiti: string - KarlKona: string - FaedSveit: string - Faedingarstadur: string - Faedingardagur: string - Rikisfang: string - RikisfangLand: string - LoghHusk: string - LoghHuskBreytt: string - Logheimili: string - LogheimiliSveitarfelag: string - Postnr: string - LogheimiliPostaritun: string - Bannmerking: string - BannmerkingBreytt: string - AdsHusk: string - AdsHuskBreytt: string - Adsetur: string - AdseturSveitarfelag: string - AdseturPostaritun: string - FjFjolsk: string - Fjolsknr: string - FjolsknrBreytt: string - Foreldri1: string - nafn1: string - Afdrif1: string - Foreldri2: string - Nafn2: string - Afdrif2: string -} - -interface ISLEinstaklingurAttributes { - 'diffgr:id': string - 'msdata:rowOrder': string - 'diffgr:hasChanges': string -} - -interface Schema { - attributes: SchemaAttributes - element: SchemaElement -} - -interface SchemaAttributes { - id: string -} - -interface SchemaElement { - attributes: PurpleAttributes - complexType: PurpleComplexType -} - -interface PurpleAttributes { - name: string - 'msdata:IsDataSet': string - 'msdata:MainDataTable': string - 'msdata:UseCurrentLocale': string -} - -interface PurpleComplexType { - choice: Choice -} - -interface Choice { - attributes: ChoiceAttributes - element: ChoiceElement -} - -interface ChoiceAttributes { - minOccurs: string - maxOccurs: string -} - -interface ChoiceElement { - attributes: FluffyAttributes - complexType: FluffyComplexType -} - -interface FluffyAttributes { - name: string -} - -interface FluffyComplexType { - sequence: Sequence -} - -interface Sequence { - element: ElementElement[] -} - -interface ElementElement { - attributes: TentacledAttributes -} - -interface TentacledAttributes { - name: string - 'msprop:ColumnId': string - type: Type - minOccurs: string -} - -enum Type { - XsString = 'xs:string', -} diff --git a/libs/clients/national-registry/v1/src/lib/dto/getViewISLFjolskyldan.dto.ts b/libs/clients/national-registry/v1/src/lib/dto/getViewISLFjolskyldan.dto.ts deleted file mode 100644 index f94e275d7645..000000000000 --- a/libs/clients/national-registry/v1/src/lib/dto/getViewISLFjolskyldan.dto.ts +++ /dev/null @@ -1,102 +0,0 @@ -export interface GetViewISLFjolskyldanDto { - message: string - table: Table - success: boolean -} - -interface Table { - schema: Schema - diffgram: Diffgram -} - -interface Diffgram { - DocumentElement: DocumentElement -} - -interface DocumentElement { - ISLFjolskyldan: ISLFjolskyldan[] -} - -export interface ISLFjolskyldan { - attributes: ISLFjolskyldanAttributes - Kennitala: string - Nafn: string - Fjolsknr: string - Kyn: string - Kynheiti: string - Faedingardagur: string - MakiBarn: string -} - -interface ISLFjolskyldanAttributes { - 'diffgr:id': string - 'msdata:rowOrder': string - 'diffgr:hasChanges': string -} - -interface Schema { - attributes: SchemaAttributes - element: SchemaElement -} - -interface SchemaAttributes { - id: string -} - -interface SchemaElement { - attributes: PurpleAttributes - complexType: PurpleComplexType -} - -interface PurpleAttributes { - name: string - 'msdata:IsDataSet': string - 'msdata:MainDataTable': string - 'msdata:UseCurrentLocale': string -} - -interface PurpleComplexType { - choice: Choice -} - -interface Choice { - attributes: ChoiceAttributes - element: ChoiceElement -} - -interface ChoiceAttributes { - minOccurs: string - maxOccurs: string -} - -interface ChoiceElement { - attributes: FluffyAttributes - complexType: FluffyComplexType -} - -interface FluffyAttributes { - name: string -} - -interface FluffyComplexType { - sequence: Sequence -} - -interface Sequence { - element: ElementElement[] -} - -interface ElementElement { - attributes: TentacledAttributes -} - -interface TentacledAttributes { - name: string - 'msprop:ColumnId': string - type: Type - minOccurs: string -} - -enum Type { - XsString = 'xs:string', -} diff --git a/libs/clients/national-registry/v1/src/lib/dto/index.ts b/libs/clients/national-registry/v1/src/lib/dto/index.ts deleted file mode 100644 index 96090d875484..000000000000 --- a/libs/clients/national-registry/v1/src/lib/dto/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -export { - GetViewISLEinstaklingurDto, - ISLEinstaklingur, -} from './getViewISLEinstaklingur.dto' -export { - GetViewISLFjolskyldanDto, - ISLFjolskyldan, -} from './getViewISLFjolskyldan.dto' -export { GetViewISLBorninMinDto, ISLBorninMin } from './getViewISLBorninMin.dto' diff --git a/libs/clients/national-registry/v1/src/lib/nationalRegistryApi.ts b/libs/clients/national-registry/v1/src/lib/nationalRegistryApi.ts deleted file mode 100644 index 62275b2d9e0e..000000000000 --- a/libs/clients/national-registry/v1/src/lib/nationalRegistryApi.ts +++ /dev/null @@ -1,187 +0,0 @@ -import { InternalServerErrorException, NotFoundException } from '@nestjs/common' -import Soap from 'soap' - -import isEmpty from 'lodash/isEmpty' -import isObject from 'lodash/isObject' -import type { User } from '@island.is/auth-nest-tools' -import { logger } from '@island.is/logging' -import { - GetViewISLFjolskyldanDto, - GetViewISLEinstaklingurDto, - GetViewISLBorninMinDto, - ISLFjolskyldan, - ISLBorninMin, - ISLEinstaklingur, -} from './dto' -import { SoapClient } from './soapClient' - -export interface NationalRegistryConfig { - baseSoapUrl: string - host: string - user: string - password: string -} - -export class NationalRegistryApi { - private readonly client: Soap.Client | null - private readonly clientUser: string - private readonly clientPassword: string - - /** - * This caused a GQL api server crash when the WSDL request was hanging due to - * Þjóðskrá loosing electricity and their services went down. - * To prevent this causing a restart loop in our kubernetes environment we have - * added a http request timeout of 10 sec. - */ - static async instantiateClass(config: NationalRegistryConfig) { - return new NationalRegistryApi( - await SoapClient.generateClient(config.baseSoapUrl, config.host), - config.password, - config.user, - ) - } - - constructor( - private soapClient: Soap.Client | null, - clientPassword: string, - clientUser: string, - ) { - if (!soapClient) { - logger.error('NationalRegistry Soap client not initialized') - } - if (!clientUser) { - logger.error('NationalRegistry user not provided') - } - if (!clientPassword) { - logger.error('NationalRegistry password not provided') - } - - this.client = this.soapClient - this.clientUser = clientUser - this.clientPassword = clientPassword - } - - public async getUser( - nationalId: User['nationalId'], - ): Promise { - const response: GetViewISLEinstaklingurDto = await this.signal( - 'GetViewISLEinstaklingur', - { - Kennitala: nationalId, - }, - ) - - if (!response) { - throw new NotFoundException( - `user with nationalId ${nationalId} not found in national Registry`, - ) - } - return response.table.diffgram.DocumentElement.ISLEinstaklingur - } - - public async getMyFamily(nationalId: string): Promise { - const response: GetViewISLFjolskyldanDto = await this.signal( - 'GetViewISLFjolskyldan', - { - Kennitala: nationalId, - }, - ) - - if (!response) { - throw new NotFoundException( - `family for nationalId ${nationalId} not found`, - ) - } - return Array.isArray(response.table.diffgram.DocumentElement.ISLFjolskyldan) - ? response.table.diffgram.DocumentElement.ISLFjolskyldan - : [response.table.diffgram.DocumentElement.ISLFjolskyldan] - } - - public async getMyChildren(nationalId: string): Promise { - const borninMinResponse: GetViewISLBorninMinDto = await this.signal( - 'GetViewISLBorninMin', - { - Kennitala: nationalId, - }, - ) - - if (isObject(borninMinResponse) && isEmpty(borninMinResponse)) { - /** - * User with no children will recieve an empty object - * Returning an empty array instead. - */ - return [] - } - - if (!borninMinResponse) { - throw new NotFoundException( - `children for nationalId ${nationalId} not found`, - ) - } - - const documentData = - borninMinResponse?.table?.diffgram?.DocumentElement?.ISLBorninMin - return Array.isArray(documentData) ? documentData : [documentData] - } - - private async signal( - functionName: string, - args: Record, - post?: boolean, - ): Promise { - return new Promise((resolve, reject) => { - if (!this.client) { - throw new InternalServerErrorException('Client not initialized') - } - - const formatData = Object.keys(args).reduce( - (acc: Record, key: string) => ({ - ...acc, - [`:${key}`]: args[key], - }), - {}, - ) - - const formattedData = post - ? { - ':S5Username': this.clientUser, - ':S5Password': this.clientPassword, - ':values': formatData, - } - : { - ':SortColumn': 1, - ':SortAscending': true, - ':S5Username': this.clientUser, - ':S5Password': this.clientPassword, - ...formatData, - } - - this.client[functionName]( - formattedData, - ( - // eslint-disable-next-line - error: any, - response: any, - ) => { - const result = response[`${functionName}Result`] - if (result != null) { - if (!result.success) { - logger.error(result.message) - reject(result) - } - if (error) { - logger.error(error) - reject(error) - } - if (post) { - resolve(result ? result : null) - } else { - resolve(result.table.diffgram ? result : null) - } - } - resolve(null) - }, - ) - }) - } -} diff --git a/libs/clients/national-registry/v1/src/lib/soapClient.ts b/libs/clients/national-registry/v1/src/lib/soapClient.ts deleted file mode 100644 index 4b631a8cde62..000000000000 --- a/libs/clients/national-registry/v1/src/lib/soapClient.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { logger } from '@island.is/logging' -import * as Soap from 'soap' - -const WSDL_REQUEST_TIMEOUT = 10 * 1000 - -export class SoapClient { - static async generateClient( - baseUrl: string, - host: string, - ): Promise { - const promise = new Promise((resolve) => { - Soap.createClient( - `${baseUrl}/islws/service.asmx?WSDL`, - { - // eslint-disable-next-line - wsdl_headers: { Host: host }, - wsdl_options: { - timeout: WSDL_REQUEST_TIMEOUT, - }, - }, - (error, client) => { - if (client) { - client.setEndpoint(`${baseUrl}/islws/service.asmx`) - client.addHttpHeader('Host', host) - resolve(client) - } else { - logger.error('NationalRegistry connection failed : ', error) - resolve(client) - } - }, - ) - }) - return promise - } -} diff --git a/libs/clients/national-registry/v1/src/lib/soffiaClient.config.ts b/libs/clients/national-registry/v1/src/lib/soffiaClient.config.ts deleted file mode 100644 index d47e0572dae2..000000000000 --- a/libs/clients/national-registry/v1/src/lib/soffiaClient.config.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { defineConfig } from '@island.is/nest/config' -import { z } from 'zod' - -const schema = z.object({ - baseSoapUrl: z.string(), - user: z.string(), - password: z.string(), - host: z.string(), -}) - -export const NationalRegistrySoffiaClientConfig = defineConfig< - z.infer ->({ - name: 'NationalRegistrySoffiaClientConfig', - schema, - load(env) { - return { - baseSoapUrl: env.required('SOFFIA_SOAP_URL', 'https://localhost:8443'), - user: env.required('SOFFIA_USER', ''), - password: env.required('SOFFIA_PASS', ''), - host: env.required('SOFFIA_HOST_URL', 'soffiaprufa.skra.is'), - } - }, -}) diff --git a/libs/clients/national-registry/v1/tsconfig.json b/libs/clients/national-registry/v1/tsconfig.json deleted file mode 100644 index 26b7b4afd192..000000000000 --- a/libs/clients/national-registry/v1/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "../../../../tsconfig.base.json", - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.lib.json" - }, - { - "path": "./tsconfig.spec.json" - } - ] -} diff --git a/libs/clients/national-registry/v1/tsconfig.lib.json b/libs/clients/national-registry/v1/tsconfig.lib.json deleted file mode 100644 index ff64bb51cff8..000000000000 --- a/libs/clients/national-registry/v1/tsconfig.lib.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "module": "commonjs", - "outDir": "../../../dist/out-tsc", - "declaration": true, - "types": ["node"] - }, - "exclude": ["**/*.spec.ts", "**/*.test.ts", "jest.config.ts"], - "include": ["**/*.ts"] -} diff --git a/libs/clients/national-registry/v1/tsconfig.spec.json b/libs/clients/national-registry/v1/tsconfig.spec.json deleted file mode 100644 index e1535ba9d07c..000000000000 --- a/libs/clients/national-registry/v1/tsconfig.spec.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../../dist/out-tsc", - "module": "commonjs", - "types": ["jest", "node"] - }, - "include": [ - "**/*.spec.ts", - "**/*.test.ts", - "**/*.spec.tsx", - "**/*.test.tsx", - "**/*.spec.js", - "**/*.test.js", - "**/*.spec.jsx", - "**/*.test.jsx", - "**/*.d.ts", - "jest.config.ts" - ] -} diff --git a/libs/feature-flags/src/lib/features.ts b/libs/feature-flags/src/lib/features.ts index 303123234fd0..4eb238297074 100644 --- a/libs/feature-flags/src/lib/features.ts +++ b/libs/feature-flags/src/lib/features.ts @@ -92,9 +92,6 @@ export enum Features { isDelegationNotificationEnabled = 'isDelegationNotificationEnabled', shouldSendEmailNotificationsToDelegations = 'shouldSendEmailNotificationsToDelegations', - - // National registry integration - disableSoffia = 'disableSoffia', } export enum ServerSideFeature { diff --git a/libs/portals/admin/regulations-admin/README.md b/libs/portals/admin/regulations-admin/README.md index b913c99c9ab9..5914c3426269 100644 --- a/libs/portals/admin/regulations-admin/README.md +++ b/libs/portals/admin/regulations-admin/README.md @@ -7,12 +7,11 @@ This library was generated with [Nx](https://nx.dev). Get fresh AWS credentials, and then open six (6) terminal windows. 1. `sh scripts/run-es-proxy.sh` -2. `kubectl port-forward svc/socat-soffia 8443:443 -n socat` -3. `docker-compose -f apps/services/regulations-admin-backend/docker-compose.yml up` +2. `docker-compose -f apps/services/regulations-admin-backend/docker-compose.yml up` (for setup see [the README.md](../../../services/../../apps/services/regulations-admin-backend/Readme.md)) -4. `yarn start regulations-admin-backend` -5. `yarn start api` -6. `yarn start portals-admin` +3. `yarn start regulations-admin-backend` +4. `yarn start api` +5. `yarn start portals-admin` Once everything is running, open and enjoy. diff --git a/libs/service-portal/education/project.json b/libs/service-portal/education/project.json index d718e6843a03..f80f16d19a4b 100644 --- a/libs/service-portal/education/project.json +++ b/libs/service-portal/education/project.json @@ -44,7 +44,6 @@ "options": { "commands": [ "kubectl port-forward svc/socat-xroad 8081:80 -n socat &", - "kubectl port-forward svc/socat-soffia 8443:443 -n socat &", "yarn start api &", "yarn start services-user-profile &", "yarn start service-portal &" diff --git a/libs/service-portal/information/src/lib/queries/getNationalChildren.ts b/libs/service-portal/information/src/lib/queries/getNationalChildren.ts deleted file mode 100644 index 88fd7681d79a..000000000000 --- a/libs/service-portal/information/src/lib/queries/getNationalChildren.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { gql } from '@apollo/client' - -export const NATIONAL_REGISTRY_CHILDREN = gql` - query NationalRegistryChildrenQuery { - nationalRegistryChildren { - nationalId - fullName - firstName - middleName - lastName - displayName - genderDisplay - birthplace - custody1 - custodyText1 - nameCustody1 - custody2 - custodyText2 - nameCustody2 - parent1 - nameParent1 - parent2 - nameParent2 - homeAddress - religion - nationality - religion - homeAddress - nationality - legalResidence - } - } -` diff --git a/libs/service-portal/information/src/lib/queries/getNationalRegistryFamily.ts b/libs/service-portal/information/src/lib/queries/getNationalRegistryFamily.ts deleted file mode 100644 index e0351540345f..000000000000 --- a/libs/service-portal/information/src/lib/queries/getNationalRegistryFamily.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { gql } from '@apollo/client' - -export const NATIONAL_REGISTRY_FAMILY = gql` - query NationalRegistryFamilyQuery { - nationalRegistryFamily { - fullName - gender - nationalId - } - } -` - -export const NATIONAL_REGISTRY_FAMILY_DETAIL = gql` - query NationalRegistryFamilyDetailQuery($input: GetFamilyInfoInput!) { - nationalRegistryFamilyDetail(input: $input) { - nationalId - fullName - displayName - genderDisplay - birthplace - custody1 - custodyText1 - nameCustody1 - custody2 - custodyText2 - nameCustody2 - parent1 - nameParent1 - parent2 - nameParent2 - homeAddress - religion - nationality - religion - homeAddress - nationality - legalResidence - } - } -` diff --git a/libs/service-portal/information/src/lib/queries/getNationalRegistryUser.ts b/libs/service-portal/information/src/lib/queries/getNationalRegistryUser.ts deleted file mode 100644 index 47fe9b215212..000000000000 --- a/libs/service-portal/information/src/lib/queries/getNationalRegistryUser.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { gql } from '@apollo/client' - -export const NATIONAL_REGISTRY_USER = gql` - query NationalRegistryUserQuery { - nationalRegistryUser { - nationalId - maritalStatus - religion - legalResidence - birthPlace - familyNr - fullName - firstName - middleName - lastName - banMarking { - banMarked - } - gender - spouse { - name - nationalId - cohabitant - } - citizenship { - code - name - } - } - } -` diff --git a/libs/service-portal/information/src/screens/Child/Child.graphql b/libs/service-portal/information/src/screens/Child/Child.graphql index 544624f36e1a..e438377ebfe5 100644 --- a/libs/service-portal/information/src/screens/Child/Child.graphql +++ b/libs/service-portal/information/src/screens/Child/Child.graphql @@ -1,9 +1,8 @@ query NationalRegistryChildCustody( - $api: String $childNationalId: String $useFakeData: Boolean ) { - nationalRegistryPerson(api: $api, useFakeData: $useFakeData) { + nationalRegistryPerson(useFakeData: $useFakeData) { nationalId fullName childCustody(childNationalId: $childNationalId) { diff --git a/libs/service-portal/information/src/screens/Child/Child.tsx b/libs/service-portal/information/src/screens/Child/Child.tsx index 0824089656fb..c1a64fa78d50 100644 --- a/libs/service-portal/information/src/screens/Child/Child.tsx +++ b/libs/service-portal/information/src/screens/Child/Child.tsx @@ -39,7 +39,6 @@ const Child = () => { const { data, loading, error } = useNationalRegistryChildCustodyQuery({ variables: { - api: 'v3', childNationalId: unmaskString(baseId, userInfo.profile.nationalId), }, }) diff --git a/libs/service-portal/information/src/screens/Spouse/Spouse.graphql b/libs/service-portal/information/src/screens/Spouse/Spouse.graphql index e369781e630b..7d20097349a8 100644 --- a/libs/service-portal/information/src/screens/Spouse/Spouse.graphql +++ b/libs/service-portal/information/src/screens/Spouse/Spouse.graphql @@ -1,5 +1,5 @@ -query NationalRegistrySpouse($api: String) { - nationalRegistryPerson(api: $api) { +query NationalRegistrySpouse { + nationalRegistryPerson { nationalId maritalStatus spouse { diff --git a/libs/service-portal/information/src/screens/Spouse/Spouse.tsx b/libs/service-portal/information/src/screens/Spouse/Spouse.tsx index b1c6b7c1031c..b38bdb05746e 100644 --- a/libs/service-portal/information/src/screens/Spouse/Spouse.tsx +++ b/libs/service-portal/information/src/screens/Spouse/Spouse.tsx @@ -21,11 +21,7 @@ const FamilyMember = () => { const [spouseValue, setSpouseValue] = useState('') - const { data, loading, error } = useNationalRegistrySpouseQuery({ - variables: { - api: 'v3', - }, - }) + const { data, loading, error } = useNationalRegistrySpouseQuery() useEffect(() => { if (data?.nationalRegistryPerson) { diff --git a/libs/service-portal/information/src/screens/UserInfo/UserInfo.graphql b/libs/service-portal/information/src/screens/UserInfo/UserInfo.graphql index 40bf67744730..7df730d19577 100644 --- a/libs/service-portal/information/src/screens/UserInfo/UserInfo.graphql +++ b/libs/service-portal/information/src/screens/UserInfo/UserInfo.graphql @@ -1,5 +1,5 @@ -query NationalRegistryPerson($api: String, $useFakeData: Boolean) { - nationalRegistryPerson(api: $api, useFakeData: $useFakeData) { +query NationalRegistryPerson($useFakeData: Boolean) { + nationalRegistryPerson(useFakeData: $useFakeData) { nationalId fullName gender diff --git a/libs/service-portal/information/src/screens/UserInfo/UserInfo.tsx b/libs/service-portal/information/src/screens/UserInfo/UserInfo.tsx index 2eb1ac1eeb15..61dfb1b0d76f 100644 --- a/libs/service-portal/information/src/screens/UserInfo/UserInfo.tsx +++ b/libs/service-portal/information/src/screens/UserInfo/UserInfo.tsx @@ -29,11 +29,7 @@ const SubjectInfo = () => { const userInfo = useUserInfo() const { formatMessage } = useLocale() - const { data, loading, error } = useNationalRegistryPersonQuery({ - variables: { - api: 'v3', - }, - }) + const { data, loading, error } = useNationalRegistryPersonQuery() const { nationalRegistryPerson } = data || {} const isDelegation = userInfo && checkDelegation(userInfo) diff --git a/libs/service-portal/information/src/screens/UserInfoOverview/UserInfoOverview.graphql b/libs/service-portal/information/src/screens/UserInfoOverview/UserInfoOverview.graphql index b3d0050a8aae..9726f4c0c9b7 100644 --- a/libs/service-portal/information/src/screens/UserInfoOverview/UserInfoOverview.graphql +++ b/libs/service-portal/information/src/screens/UserInfoOverview/UserInfoOverview.graphql @@ -1,5 +1,5 @@ -query UserInfoOverview($api: String, $useFakeData: Boolean) { - nationalRegistryPerson(api: $api, useFakeData: $useFakeData) { +query UserInfoOverview($useFakeData: Boolean) { + nationalRegistryPerson(useFakeData: $useFakeData) { nationalId fullName spouse { diff --git a/libs/service-portal/information/src/screens/UserInfoOverview/UserInfoOverview.tsx b/libs/service-portal/information/src/screens/UserInfoOverview/UserInfoOverview.tsx index 3a39ce1db40f..6ad0000c5d4e 100644 --- a/libs/service-portal/information/src/screens/UserInfoOverview/UserInfoOverview.tsx +++ b/libs/service-portal/information/src/screens/UserInfoOverview/UserInfoOverview.tsx @@ -20,9 +20,7 @@ const UserInfoOverview = () => { const { formatMessage } = useLocale() const userInfo = useUserInfo() - const { data, error, loading } = useUserInfoOverviewQuery({ - variables: { api: 'v3' }, - }) + const { data, error, loading } = useUserInfoOverviewQuery() const { spouse, childCustody } = data?.nationalRegistryPerson || {} diff --git a/scripts/run-proxies.sh b/scripts/run-proxies.sh index 72c03ed06102..483f95d2497b 100755 --- a/scripts/run-proxies.sh +++ b/scripts/run-proxies.sh @@ -79,12 +79,11 @@ Options: -i, --interval N Wait N seconds before restarting a proxy (default: 1) -p, --port N - Local port to bind to (default: 5432 for db, 6379 for redis, 9200 for es, 8443 for soffia, 8081 for xroad) + Local port to bind to (default: 5432 for db, 6379 for redis, 9200 for es, 8081 for xroad) Only works for single-proxy mode Proxies: es - soffia xroad redis db @@ -177,7 +176,7 @@ parse_cli() { # Return early if no proxies if [ "${#PROXIES[@]}" -eq 0 ]; then - PROXIES=("es" "soffia" "xroad" "redis" "db") + PROXIES=("es" "xroad" "redis" "db") return fi @@ -191,7 +190,7 @@ parse_cli() { local unknown_proxies unknown_proxies=() for proxy in "${PROXIES[@]}"; do - if ! [[ "$proxy" =~ ^(es|soffia|xroad|redis|db)$ ]]; then + if ! [[ "$proxy" =~ ^(es|xroad|redis|db)$ ]]; then unknown_proxies+=("$proxy") fi done @@ -218,10 +217,6 @@ run-proxy() { service="es-proxy" namespace="es-proxy" ;; - "soffia") - service="socat-soffia" - namespace="socat" - ;; "xroad") service="socat-xroad" namespace="socat" @@ -256,9 +251,6 @@ run-redis-proxy() { run-es-proxy() { run-proxy 9200 "${LOCAL_PORT:=9200}" es "$@" } -run-soffia-proxy() { - run-proxy 443 "${LOCAL_PORT:=8443}" soffia -} run-xroad-proxy() { run-proxy 80 "${LOCAL_PORT:=8081}" xroad } diff --git a/scripts/run-soffia-proxy.sh b/scripts/run-soffia-proxy.sh deleted file mode 100755 index a5a699b533bc..000000000000 --- a/scripts/run-soffia-proxy.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -set -euo pipefail -# This scripts sets up a local proxy for X-Road running in our Dev env -./scripts/run-proxies.sh soffia "$@" diff --git a/scripts/stop-test-proxies.sh b/scripts/stop-test-proxies.sh index ce0074c95a1a..51b852eab4ff 100755 --- a/scripts/stop-test-proxies.sh +++ b/scripts/stop-test-proxies.sh @@ -12,7 +12,7 @@ function stop_proxy() { builder=${1:-docker} -array=( socat-soffia socat-xroad es-proxy ) +array=( socat-xroad es-proxy ) for proxy in "${array[@]}" do From 1f799846757493259943e7e3cdf5f106ee8fca2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9E=C3=B3r=C3=B0ur=20H?= Date: Wed, 15 May 2024 11:44:07 +0000 Subject: [PATCH 03/10] fix(service-portal): ActionCard img height (#14801) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../core/src/components/ActionCard/ActionCard.css.ts | 11 +++++++++-- .../core/src/components/ActionCard/ActionCard.tsx | 7 ++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/libs/service-portal/core/src/components/ActionCard/ActionCard.css.ts b/libs/service-portal/core/src/components/ActionCard/ActionCard.css.ts index bf1b6c4d533d..c370bbbb5ef4 100644 --- a/libs/service-portal/core/src/components/ActionCard/ActionCard.css.ts +++ b/libs/service-portal/core/src/components/ActionCard/ActionCard.css.ts @@ -11,13 +11,20 @@ export const tag = style({ }), }) -export const avatar = style({ +export const image = style({ display: 'none', ...themeUtils.responsiveStyle({ sm: { display: 'flex', width: 66, - //height: 66, + }, + }), +}) + +export const avatar = style({ + ...themeUtils.responsiveStyle({ + sm: { + height: 66, }, }), }) diff --git a/libs/service-portal/core/src/components/ActionCard/ActionCard.tsx b/libs/service-portal/core/src/components/ActionCard/ActionCard.tsx index b2d2ab78b128..6efbc9cca915 100644 --- a/libs/service-portal/core/src/components/ActionCard/ActionCard.tsx +++ b/libs/service-portal/core/src/components/ActionCard/ActionCard.tsx @@ -15,6 +15,7 @@ import * as React from 'react' import { CardLoader, isExternalLink } from '../..' import * as styles from './ActionCard.css' import LinkResolver from '../LinkResolver/LinkResolver' +import cn from 'classnames' type ActionCardProps = { capitalizeHeading?: boolean @@ -117,7 +118,7 @@ export const ActionCard: React.FC> = ({ marginRight={[2, 3]} borderRadius="circle" background="blue100" - className={styles.avatar} + className={cn(styles.avatar, styles.image)} > > = ({ marginRight={[2, 3]} borderRadius="circle" > - action-card + action-card ) } @@ -155,7 +156,7 @@ export const ActionCard: React.FC> = ({ marginRight={[2, 3]} borderRadius="circle" background={image.active ? 'white' : 'blue100'} - className={styles.avatar} + className={cn(styles.avatar, styles.image)} > action-card From eec6b05b35fd6eca1872cd505130d46f26123f82 Mon Sep 17 00:00:00 2001 From: Halli1414 <42970319+Halli1414@users.noreply.github.com> Date: Wed, 15 May 2024 12:16:27 +0000 Subject: [PATCH 04/10] fix(Application-ctao): Minor typo fix in pdf (#14750) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../attachments/providers/applicationAttachmentProvider.ts | 2 +- .../pdfGenerators/templates/complaint.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/complaints-to-althingi-ombudsman/attachments/providers/applicationAttachmentProvider.ts b/libs/application/template-api-modules/src/lib/modules/templates/complaints-to-althingi-ombudsman/attachments/providers/applicationAttachmentProvider.ts index e968e247b0e9..9e2c4f1d2a29 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/complaints-to-althingi-ombudsman/attachments/providers/applicationAttachmentProvider.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/complaints-to-althingi-ombudsman/attachments/providers/applicationAttachmentProvider.ts @@ -27,7 +27,7 @@ export class ApplicationAttachmentProvider { application, attachmentAnswers, ) - return files.map((file, index) => { + return files.map((file) => { const type = this.mapAnswerToType(file.answerKey) const fileName = file.fileName return { diff --git a/libs/application/template-api-modules/src/lib/modules/templates/complaints-to-althingi-ombudsman/pdfGenerators/templates/complaint.ts b/libs/application/template-api-modules/src/lib/modules/templates/complaints-to-althingi-ombudsman/pdfGenerators/templates/complaint.ts index 187f9680a6f8..c306ee10a1b3 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/complaints-to-althingi-ombudsman/pdfGenerators/templates/complaint.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/complaints-to-althingi-ombudsman/pdfGenerators/templates/complaint.ts @@ -22,7 +22,7 @@ export async function generateComplaintPdf(application: Application) { buffers.push(buffer) }) - addHeader('Kvörtun til Umboðsmans Alþingis', doc) + addHeader('Kvörtun til umboðsmanns Alþingis', doc) addValue( `${answers.applicant.name}, ${formatNationalId( From 356b36c12cfa02f6179e0fd64899e9e6cbe41e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Wed, 15 May 2024 12:44:22 +0000 Subject: [PATCH 05/10] feat(j-s): Add defender to sendModifiedNotifications (#14792) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../app/modules/notification/notification.service.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/judicial-system/backend/src/app/modules/notification/notification.service.ts b/apps/judicial-system/backend/src/app/modules/notification/notification.service.ts index 3b843d1375d6..df71bae7172a 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/notification.service.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/notification.service.ts @@ -1281,6 +1281,17 @@ export class NotificationService { ) } + if (theCase.defenderEmail) { + promises.push( + this.sendEmail( + subject, + html, + theCase.defenderName, + theCase.defenderEmail, + ), + ) + } + const recipients = await Promise.all(promises) return this.recordNotification( From a78bd80d638584b0a875e1e17654af26477db5f7 Mon Sep 17 00:00:00 2001 From: MargretFinnboga <62568905+MargretFinnboga@users.noreply.github.com> Date: Wed, 15 May 2024 13:04:53 +0000 Subject: [PATCH 06/10] feat(fa): Showing children information in Veita (#14795) * adding sortable feature * Revert "adding sortable feature" This reverts commit d9691c54de2c2fb244cf89e49c0bfe6cd7857603. * adding more detail for api * removing white space break just adding html element to the db * adding children to Veita * updating the order of what is appeared * fix from codebot --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../components/Profile/ApplicationProfile.tsx | 44 ++++++++++++------- .../web-veita/src/utils/applicationHelper.ts | 29 ++++++++++++ 2 files changed, 57 insertions(+), 16 deletions(-) diff --git a/apps/financial-aid/web-veita/src/components/Profile/ApplicationProfile.tsx b/apps/financial-aid/web-veita/src/components/Profile/ApplicationProfile.tsx index afc00463db1b..9bf758d9a8eb 100644 --- a/apps/financial-aid/web-veita/src/components/Profile/ApplicationProfile.tsx +++ b/apps/financial-aid/web-veita/src/components/Profile/ApplicationProfile.tsx @@ -34,6 +34,7 @@ import { getApplicant, getApplicantMoreInfo, getApplicantSpouse, + getChildrenInfo, getDirectTaxPayments, getNationalRegistryInfo, } from '@island.is/financial-aid-web/veita/src/utils/applicationHelper' @@ -141,6 +142,8 @@ const ApplicationProfile = ({ const nationalRegistryInfo = getNationalRegistryInfo(application) + const childrenInfo = getChildrenInfo(application) + const modalInfo = getAidAmountModalInfo( calculationsModal.type, aidAmount, @@ -206,17 +209,11 @@ const ApplicationProfile = ({ /> - {getDirectTaxPaymentsContent( - applicantDirectPayments, - application.hasFetchedDirectTaxPayment, - application.created, - )} - + /> {showSpouseData[application.familyStatus] && ( <> @@ -242,16 +239,31 @@ const ApplicationProfile = ({ )} + {childrenInfo?.length > 0 && ( + + )} + + > + {getDirectTaxPaymentsContent( + applicantDirectPayments, + application.hasFetchedDirectTaxPayment, + application.created, + )} + diff --git a/apps/financial-aid/web-veita/src/utils/applicationHelper.ts b/apps/financial-aid/web-veita/src/utils/applicationHelper.ts index 4f2ee1ffc156..4c946b400845 100644 --- a/apps/financial-aid/web-veita/src/utils/applicationHelper.ts +++ b/apps/financial-aid/web-veita/src/utils/applicationHelper.ts @@ -117,6 +117,35 @@ export const getNationalRegistryInfo = (application: Application) => { ] } +export const getChildrenInfo = (application: Application) => { + if (!application.children) { + return [] + } + + const allChildren = application.children.map((child) => { + return [ + { + title: 'Nafn', + content: child.name, + }, + { + title: 'Kennitala', + content: formatNationalId(child.nationalId), + }, + { + title: 'Skólastofnun', + content: child.school, + }, + { + title: '', + content: '', + }, + ] + }) + + return allChildren.flat() +} + export const getApplicantSpouse = (application: Application) => { return [ { From 3e510158997eaae128532232604a2919777c611d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Wed, 15 May 2024 13:38:03 +0000 Subject: [PATCH 07/10] feat(j-s): Completed indictment overview (#14780) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Implement frontend * Checkpoint * Checkpoint * Checkpoint * Cleanup * Update apps/judicial-system/backend/src/app/modules/case/models/case.model.ts * Make CourtArrangements more generic * Checkpoint * Add CaseFiles to summary screen * Checkpoint * Remove ruling decision from caseList * Refactor * Fixes auto dates in db * Error handling * Rewrites case transitions * Add ruling case file to summary page * Add modal to summary page and transition case * Destroy everything regarding postponment when completing cases * Use Table component for appealed cases * Merge * Added a Completed screen * Routing * Add CaseFileCategory CRIMINAL_RECORD_UPDATE * Remove upload to court functionality * Checkpoint * Add CRIMINAL_RECORD_UPDATE file upload * Fix validation * Add title * Cleanup * Revert change * Revert change * Revert change * Revert change * Revert change * Revert change * Cleanup * Cleanup * Cleanup * fix: force generate file --------- Co-authored-by: Guðjón Guðjónsson Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: lommi --- .../migrations/20240513130819-update-case.js | 64 +++++ .../web/messages/Core/titles.ts | 6 + .../web/pages/domur/akaera/lokid/[id].ts | 3 + .../IndictmentCaseFilesList.tsx | 3 + .../Completed/Completed.strings.ts | 59 ++++ .../Court/Indictments/Completed/Completed.tsx | 259 ++++++++++++++++++ .../Indictments/Overview/Overview.strings.ts | 18 -- .../Court/Indictments/Overview/Overview.tsx | 107 +------- .../Court/Indictments/Summary/Summary.tsx | 6 +- libs/judicial-system/consts/src/lib/consts.ts | 1 + libs/judicial-system/types/src/lib/file.ts | 1 + scripts/_hash-generated-files.sh | 1 + 12 files changed, 406 insertions(+), 122 deletions(-) create mode 100644 apps/judicial-system/backend/migrations/20240513130819-update-case.js create mode 100644 apps/judicial-system/web/pages/domur/akaera/lokid/[id].ts create mode 100644 apps/judicial-system/web/src/routes/Court/Indictments/Completed/Completed.strings.ts create mode 100644 apps/judicial-system/web/src/routes/Court/Indictments/Completed/Completed.tsx diff --git a/apps/judicial-system/backend/migrations/20240513130819-update-case.js b/apps/judicial-system/backend/migrations/20240513130819-update-case.js new file mode 100644 index 000000000000..c58c260a9905 --- /dev/null +++ b/apps/judicial-system/backend/migrations/20240513130819-update-case.js @@ -0,0 +1,64 @@ +'use strict' + +const replaceEnum = require('sequelize-replace-enum-postgres').default + +module.exports = { + async up(queryInterface) { + return replaceEnum({ + queryInterface, + tableName: 'case_file', + columnName: 'category', + newValues: [ + 'COURT_RECORD', + 'RULING', + 'COVER_LETTER', + 'INDICTMENT', + 'CRIMINAL_RECORD', + 'COST_BREAKDOWN', + 'CASE_FILE', + 'PROSECUTOR_APPEAL_BRIEF', + 'DEFENDANT_APPEAL_BRIEF', + 'PROSECUTOR_APPEAL_BRIEF_CASE_FILE', + 'DEFENDANT_APPEAL_BRIEF_CASE_FILE', + 'PROSECUTOR_APPEAL_STATEMENT', + 'DEFENDANT_APPEAL_STATEMENT', + 'PROSECUTOR_APPEAL_STATEMENT_CASE_FILE', + 'DEFENDANT_APPEAL_STATEMENT_CASE_FILE', + 'PROSECUTOR_APPEAL_CASE_FILE', + 'DEFENDANT_APPEAL_CASE_FILE', + 'APPEAL_COURT_RECORD', + 'APPEAL_RULING', + 'CRIMINAL_RECORD_UPDATE', // new value + ], + }) + }, + + async down(queryInterface) { + return replaceEnum({ + queryInterface, + tableName: 'case_file', + columnName: 'category', + newValues: [ + 'COURT_RECORD', + 'RULING', + 'COVER_LETTER', + 'INDICTMENT', + 'CRIMINAL_RECORD', + 'COST_BREAKDOWN', + 'CASE_FILE', + 'PROSECUTOR_APPEAL_BRIEF', + 'DEFENDANT_APPEAL_BRIEF', + 'PROSECUTOR_APPEAL_BRIEF_CASE_FILE', + 'DEFENDANT_APPEAL_BRIEF_CASE_FILE', + 'PROSECUTOR_APPEAL_STATEMENT', + 'DEFENDANT_APPEAL_STATEMENT', + 'PROSECUTOR_APPEAL_STATEMENT_CASE_FILE', + 'DEFENDANT_APPEAL_STATEMENT_CASE_FILE', + 'PROSECUTOR_APPEAL_CASE_FILE', + 'DEFENDANT_APPEAL_CASE_FILE', + 'APPEAL_COURT_RECORD', + 'APPEAL_RULING', + ], + }) + }, +} diff --git a/apps/judicial-system/web/messages/Core/titles.ts b/apps/judicial-system/web/messages/Core/titles.ts index 8faec0f8724c..f44b175d28cc 100644 --- a/apps/judicial-system/web/messages/Core/titles.ts +++ b/apps/judicial-system/web/messages/Core/titles.ts @@ -209,6 +209,12 @@ export const titles = { description: 'Notaður sem titill fyrir Niðurstaða úrskurðar skjá hjá dómstólum í ákærum', }, + completed: { + id: 'judicial.system.core:titles.court.indictments.completed', + defaultMessage: 'Máli lokið - Réttarvörslugátt', + description: + 'Notaður sem titill fyrir Máli lokið skjá hjá dómstólum í ákærum', + }, }), }, defender: { diff --git a/apps/judicial-system/web/pages/domur/akaera/lokid/[id].ts b/apps/judicial-system/web/pages/domur/akaera/lokid/[id].ts new file mode 100644 index 000000000000..8e78e8dc106c --- /dev/null +++ b/apps/judicial-system/web/pages/domur/akaera/lokid/[id].ts @@ -0,0 +1,3 @@ +import Completed from '@island.is/judicial-system-web/src/routes/Court/Indictments/Completed/Completed' + +export default Completed diff --git a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx index 9bb2e273d65d..ec0833e1f0ef 100644 --- a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx +++ b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx @@ -79,6 +79,9 @@ const IndictmentCaseFilesList: React.FC> = ( const criminalRecords = cf?.filter( (file) => file.category === CaseFileCategory.CRIMINAL_RECORD, ) + const criminalRecordUpdates = cf?.filter( + (file) => file.category === CaseFileCategory.CRIMINAL_RECORD_UPDATE, + ) const costBreakdowns = cf?.filter( (file) => file.category === CaseFileCategory.COST_BREAKDOWN, ) diff --git a/apps/judicial-system/web/src/routes/Court/Indictments/Completed/Completed.strings.ts b/apps/judicial-system/web/src/routes/Court/Indictments/Completed/Completed.strings.ts new file mode 100644 index 000000000000..0e45b9146ec3 --- /dev/null +++ b/apps/judicial-system/web/src/routes/Court/Indictments/Completed/Completed.strings.ts @@ -0,0 +1,59 @@ +import { defineMessages } from 'react-intl' + +const strings = defineMessages({ + heading: { + id: 'judicial.system.court.indictments.completed.heading', + defaultMessage: 'Máli lokið', + description: 'Titill á Máli lokið síðu', + }, + sendToPublicProsecutor: { + id: 'judicial.system.core:indictments.completed.send_to_public_prosecutor', + defaultMessage: 'Senda til ákæruvalds', + description: + 'Notaður sem texti á takka til að senda mál til ríkissaksóknara.', + }, + criminalRecordUpdateTitle: { + id: 'judicial.system.core:indictments.completed.criminal_record_update_title', + defaultMessage: 'Tilkynning til sakaskrár', + description: + 'Notaður sem titill á Tilkynning til sakaskrár hluta á máli lokið skjá.', + }, + serviceRequirementTitle: { + id: 'judicial.system.core:indictments.completed.service_requirement_title', + defaultMessage: 'Ákvörðun um birtingu dóms', + description: + 'Notaður sem titill á Ákvörðun um birtingu dóms hluta á máli lokið skjá.', + }, + serviceRequirementRequired: { + id: 'judicial.system.core:indictments.completed.service_requirement_required', + defaultMessage: 'Birta skal dómfellda dóminn', + description: + 'Notaður sem texti í valmöguleika fyrir það þegar birta skal dómdfellda dóminn.', + }, + serviceRequirementNotRequired: { + id: 'judicial.system.core:indictments.completed.service_requirement_not_required', + defaultMessage: 'Birting dóms ekki þörf', + description: + 'Notaður sem texti í valmöguleika fyrir það þegar ekki skal birta dómdfellda dóminn.', + }, + serviceRequirementNotApplicable: { + id: 'judicial.system.core:indictments.completed.service_requirement_not_applicable', + defaultMessage: 'Dómfelldi var viðstaddur dómsuppkvaðningu', + description: + 'Notaður sem texti í valmöguleika fyrir það þegar birting dóms á ekki við.', + }, + sentToPublicProsecutorModalTitle: { + id: 'judicial.system.core:indictments.completed.sent_to_public_prosecutor_modal_title', + defaultMessage: 'Mál sent til Ríkissaksóknara', + description: + 'Notaður sem titill á staðfestingarmeldingu um að mál hafi verið sent til ákæruvalds.', + }, + sentToPublicProsecutorModalMessage: { + id: 'judicial.system.core:indictments.completed.sent_to_public_prosecutor_modal_message', + defaultMessage: 'Gögn hafa verið send til Ríkissaksóknara til yfirlesturs.', + description: + 'Notaður sem skilaboð í staðfestingarmeldingu um að mál hafi verið sent til ákæruvalds.', + }, +}) + +export default strings diff --git a/apps/judicial-system/web/src/routes/Court/Indictments/Completed/Completed.tsx b/apps/judicial-system/web/src/routes/Court/Indictments/Completed/Completed.tsx new file mode 100644 index 000000000000..b74b6ad4cb23 --- /dev/null +++ b/apps/judicial-system/web/src/routes/Court/Indictments/Completed/Completed.tsx @@ -0,0 +1,259 @@ +import React, { FC, useCallback, useContext, useState } from 'react' +import { useIntl } from 'react-intl' +import router from 'next/router' + +import { + Box, + InputFileUpload, + RadioButton, + Text, + UploadFile, +} from '@island.is/island-ui/core' +import * as constants from '@island.is/judicial-system/consts' +import { core, titles } from '@island.is/judicial-system-web/messages' +import { + BlueBox, + FormContentContainer, + FormContext, + FormFooter, + IndictmentCaseFilesList, + InfoCardClosedIndictment, + Modal, + PageHeader, + PageLayout, + SectionHeading, +} from '@island.is/judicial-system-web/src/components' +import { + CaseFileCategory, + CaseIndictmentRulingDecision, + ServiceRequirement, +} from '@island.is/judicial-system-web/src/graphql/schema' +import { + useDefendants, + useS3Upload, + useUploadFiles, +} from '@island.is/judicial-system-web/src/utils/hooks' + +import strings from './Completed.strings' + +const Completed: FC = () => { + const { formatMessage } = useIntl() + const { updateDefendantState } = useDefendants() + const { workingCase, setWorkingCase, isLoadingWorkingCase, caseNotFound } = + useContext(FormContext) + const { uploadFiles, addUploadFiles, removeUploadFile, updateUploadFile } = + useUploadFiles(workingCase.caseFiles) + const { handleUpload, handleRemove } = useS3Upload(workingCase.id) + const [modalVisible, setModalVisible] = + useState<'SENT_TO_PUBLIC_PROSECUTOR'>() + + const handleNextButtonClick = useCallback(async () => { + const allSucceeded = await handleUpload( + uploadFiles.filter((file) => !file.key), + updateUploadFile, + ) + + if (!allSucceeded) { + return + } + + setModalVisible('SENT_TO_PUBLIC_PROSECUTOR') + }, [handleUpload, uploadFiles, updateUploadFile]) + + const handleRemoveFile = useCallback( + (file: UploadFile) => { + if (file.key) { + handleRemove(file, removeUploadFile) + } else { + removeUploadFile(file) + } + }, + [handleRemove, removeUploadFile], + ) + + const handleCriminalRecordUpdateUpload = useCallback( + (files: File[], type: CaseFileCategory) => { + addUploadFiles(files, type, 'done') + }, + [addUploadFiles], + ) + + const handleNavigationTo = useCallback( + (destination: string) => router.push(`${destination}/${workingCase.id}`), + [workingCase.id], + ) + + const stepIsValid = () => + workingCase.indictmentRulingDecision === CaseIndictmentRulingDecision.RULING + ? workingCase.defendants?.every( + (defendant) => + defendant.serviceRequirement !== undefined && + defendant.serviceRequirement !== null, + ) + : true + + return ( + + + + + + {formatMessage(strings.heading)} + + + + + + + + + + + + file.category === CaseFileCategory.CRIMINAL_RECORD_UPDATE, + )} + accept="application/pdf" + header={formatMessage(core.uploadBoxTitle)} + buttonLabel={formatMessage(core.uploadBoxButtonLabel)} + description={formatMessage(core.uploadBoxDescription, { + fileEndings: '.pdf', + })} + onChange={(files) => + handleCriminalRecordUpdateUpload( + files, + CaseFileCategory.CRIMINAL_RECORD_UPDATE, + ) + } + onRemove={(file) => handleRemoveFile(file)} + /> + + {workingCase.indictmentRulingDecision === + CaseIndictmentRulingDecision.RULING && ( + + + {workingCase.defendants?.map((defendant, index) => ( + + + + + { + updateDefendantState( + { + defendantId: defendant.id, + caseId: workingCase.id, + serviceRequirement: + ServiceRequirement.NOT_APPLICABLE, + }, + setWorkingCase, + ) + }} + large + backgroundColor="white" + label={formatMessage( + strings.serviceRequirementNotApplicable, + )} + /> + + + { + updateDefendantState( + { + defendantId: defendant.id, + caseId: workingCase.id, + serviceRequirement: ServiceRequirement.REQUIRED, + }, + setWorkingCase, + ) + }} + large + backgroundColor="white" + label={formatMessage(strings.serviceRequirementRequired)} + /> + + { + updateDefendantState( + { + defendantId: defendant.id, + caseId: workingCase.id, + serviceRequirement: ServiceRequirement.NOT_REQUIRED, + }, + setWorkingCase, + ) + }} + large + backgroundColor="white" + label={formatMessage(strings.serviceRequirementNotRequired)} + /> + + + ))} + + )} + + + + + {modalVisible === 'SENT_TO_PUBLIC_PROSECUTOR' && ( + router.push(constants.CASES_ROUTE)} + /> + )} + + ) +} + +export default Completed diff --git a/apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.strings.ts b/apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.strings.ts index 1b5c014110ce..86819bf38a17 100644 --- a/apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.strings.ts +++ b/apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.strings.ts @@ -17,24 +17,6 @@ export const strings = defineMessages({ defaultMessage: 'Endursenda', description: 'Notaður sem texti á takka til að endursenda ákæru.', }, - serviceRequirementRequired: { - id: 'judicial.system.core:indictment_overview.service_requirement_required', - defaultMessage: 'Birta skal dómfellda dóminn', - description: - 'Notaður sem texti í valmöguleika fyrir það þegar birta skal dómdfellda dóminn.', - }, - serviceRequirementNotRequired: { - id: 'judicial.system.core:indictment_overview.service_requirement_not_required', - defaultMessage: 'Birting dóms ekki þörf', - description: - 'Notaður sem texti í valmöguleika fyrir það þegar ekki skal birta dómdfellda dóminn.', - }, - serviceRequirementNotApplicable: { - id: 'judicial.system.core:indictment_overview.service_requirement_not_applicable', - defaultMessage: 'Dómfelldi var viðstaddur dómsuppkvaðningu', - description: - 'Notaður sem texti í valmöguleika fyrir það þegar birting dóms á ekki við.', - }, sendToPublicProsecutorModalTitle: { id: 'judicial.system.core:indictment_overview.send_to_public_prosecutor_modal_title', defaultMessage: 'Mál hefur verið sent til Ríkissaksóknara', diff --git a/apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx b/apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx index d5eb07ad7888..d47a9bace956 100644 --- a/apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx +++ b/apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx @@ -2,12 +2,10 @@ import React, { useCallback, useContext, useState } from 'react' import { useIntl } from 'react-intl' import { useRouter } from 'next/router' -import { Box, RadioButton, toast } from '@island.is/island-ui/core' +import { Box, toast } from '@island.is/island-ui/core' import * as constants from '@island.is/judicial-system/consts' -import { isCompletedCase } from '@island.is/judicial-system/types' import { core, errors, titles } from '@island.is/judicial-system-web/messages' import { - BlueBox, CourtCaseInfo, FormContentContainer, FormContext, @@ -21,13 +19,9 @@ import { PageHeader, PageLayout, PageTitle, - SectionHeading, useIndictmentsLawsBroken, } from '@island.is/judicial-system-web/src/components' -import { - CaseState, - ServiceRequirement, -} from '@island.is/judicial-system-web/src/graphql/schema' +import { CaseState } from '@island.is/judicial-system-web/src/graphql/schema' import { useDefendants } from '@island.is/judicial-system-web/src/utils/hooks' import ReturnIndictmentModal from '../ReturnIndictmentCaseModal/ReturnIndictmentCaseModal' @@ -39,14 +33,14 @@ const IndictmentOverview = () => { useContext(FormContext) const { formatMessage } = useIntl() const lawsBroken = useIndictmentsLawsBroken(workingCase) - const { updateDefendant, updateDefendantState } = useDefendants() + const { updateDefendant } = useDefendants() const [modalVisible, setModalVisible] = useState< 'RETURN_INDICTMENT' | 'SEND_TO_PUBLIC_PROSECUTOR' >() const caseHasBeenReceivedByCourt = workingCase.state === CaseState.RECEIVED const latestDate = workingCase.courtDate ?? workingCase.arraignmentDate - const caseIsClosed = isCompletedCase(workingCase.state) + const caseIsClosed = workingCase.state === CaseState.COMPLETED const handleNavigationTo = useCallback( (destination: string) => router.push(`${destination}/${workingCase.id}`), @@ -106,99 +100,6 @@ const IndictmentOverview = () => { )} - {caseIsClosed && - workingCase.defendants?.map((defendant, index) => { - return ( - - - - - { - updateDefendantState( - { - defendantId: defendant.id, - caseId: workingCase.id, - serviceRequirement: - ServiceRequirement.NOT_APPLICABLE, - }, - setWorkingCase, - ) - }} - large - backgroundColor="white" - label={formatMessage( - strings.serviceRequirementNotApplicable, - )} - /> - - - { - updateDefendantState( - { - defendantId: defendant.id, - caseId: workingCase.id, - serviceRequirement: ServiceRequirement.REQUIRED, - }, - setWorkingCase, - ) - }} - large - backgroundColor="white" - label={formatMessage(strings.serviceRequirementRequired)} - /> - - { - updateDefendantState( - { - defendantId: defendant.id, - caseId: workingCase.id, - serviceRequirement: ServiceRequirement.NOT_REQUIRED, - }, - setWorkingCase, - ) - }} - large - backgroundColor="white" - label={formatMessage(strings.serviceRequirementNotRequired)} - /> - - - ) - })} {caseIsClosed && ( diff --git a/apps/judicial-system/web/src/routes/Court/Indictments/Summary/Summary.tsx b/apps/judicial-system/web/src/routes/Court/Indictments/Summary/Summary.tsx index cb8fffe1620c..3e4630c1ad1d 100644 --- a/apps/judicial-system/web/src/routes/Court/Indictments/Summary/Summary.tsx +++ b/apps/judicial-system/web/src/routes/Court/Indictments/Summary/Summary.tsx @@ -139,7 +139,11 @@ const Summary: React.FC = () => { title={formatMessage(strings.completedCaseModalTitle)} text={formatMessage(strings.completedCaseModalBody)} primaryButtonText={formatMessage(core.closeModal)} - onPrimaryButtonClick={() => setModalVisible(undefined)} + onPrimaryButtonClick={() => + router.push( + `${constants.INDICTMENTS_COMPLETED_ROUTE}/${workingCase.id}`, + ) + } /> )} diff --git a/libs/judicial-system/consts/src/lib/consts.ts b/libs/judicial-system/consts/src/lib/consts.ts index 1ed461c2b275..ba40d85db437 100644 --- a/libs/judicial-system/consts/src/lib/consts.ts +++ b/libs/judicial-system/consts/src/lib/consts.ts @@ -173,6 +173,7 @@ export const INDICTMENTS_SUBPOENA_ROUTE = '/domur/akaera/fyrirkall' export const INDICTMENTS_DEFENDER_ROUTE = '/domur/akaera/malflytjendur' export const INDICTMENTS_CONCLUSION_ROUTE = '/domur/akaera/nidurstada' export const INDICTMENTS_SUMMARY_ROUTE = '/domur/akaera/samantekt' +export const INDICTMENTS_COMPLETED_ROUTE = '/domur/akaera/lokid' /* DISTRICT COURT ROUTES END */ /* COURT OF APPEALS ROUTES START */ diff --git a/libs/judicial-system/types/src/lib/file.ts b/libs/judicial-system/types/src/lib/file.ts index bfc5968bd353..9b0b8b2b5e81 100644 --- a/libs/judicial-system/types/src/lib/file.ts +++ b/libs/judicial-system/types/src/lib/file.ts @@ -10,6 +10,7 @@ export enum CaseFileCategory { COVER_LETTER = 'COVER_LETTER', INDICTMENT = 'INDICTMENT', CRIMINAL_RECORD = 'CRIMINAL_RECORD', + CRIMINAL_RECORD_UPDATE = 'CRIMINAL_RECORD_UPDATE', COST_BREAKDOWN = 'COST_BREAKDOWN', CASE_FILE = 'CASE_FILE', PROSECUTOR_APPEAL_BRIEF = 'PROSECUTOR_APPEAL_BRIEF', diff --git a/scripts/_hash-generated-files.sh b/scripts/_hash-generated-files.sh index 7c123512d887..87acbd3cd1aa 100755 --- a/scripts/_hash-generated-files.sh +++ b/scripts/_hash-generated-files.sh @@ -38,6 +38,7 @@ patterns=( 'libs/**/*.graphql' 'libs/**/clientConfig.yaml' 'libs/**/clientConfig.json' + 'libs/judicial-system/**' ) HASH="$(for pattern in "${patterns[@]}"; do git ls-files "$pattern"; done | xargs cat | git hash-object --stdin)" echo -n "$HASH" From d4bb00fadee9561f1ff9793c8273d16023ff495c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3n=20Ingi?= <42949613+joningi98@users.noreply.github.com> Date: Wed, 15 May 2024 14:07:13 +0000 Subject: [PATCH 08/10] feat(annoucement-of-death): Firearms (#14559) * Adding firearms step in application * remove console log * update email and text * Send sms and email notification * check case number * remove unused function and imports * Update messages --- .../announcement-of-death-utils.ts | 16 ++ .../announcement-of-death.service.ts | 46 +++++- .../emailGenerators/assets/logo.jpg | Bin 0 -> 2885 bytes .../firearmApplicantNotification.ts | 65 ++++++++ .../smsGenerators/requestReviewSms.ts | 20 +++ .../src/fields/FirearmApplicant/index.tsx | 149 ++++++++++++++++++ .../announcement-of-death/src/fields/index.ts | 1 + .../announcement-of-death/src/forms/done.ts | 2 + .../src/forms/draft/draft.ts | 2 + .../src/forms/draft/sectionOverview.ts | 2 + .../src/forms/draft/subSectionFirearms.ts | 45 ++++++ .../src/forms/overviewSections.ts | 39 +++++ .../announcement-of-death/src/index.ts | 3 + .../src/lib/dataSchema.ts | 12 ++ .../announcement-of-death/src/lib/messages.ts | 54 +++++++ .../announcement-of-death/src/types.ts | 9 ++ 16 files changed, 464 insertions(+), 1 deletion(-) create mode 100644 libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/emailGenerators/assets/logo.jpg create mode 100644 libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/emailGenerators/firearmApplicantNotification.ts create mode 100644 libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/smsGenerators/requestReviewSms.ts create mode 100644 libs/application/templates/announcement-of-death/src/fields/FirearmApplicant/index.tsx create mode 100644 libs/application/templates/announcement-of-death/src/forms/draft/subSectionFirearms.ts diff --git a/libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/announcement-of-death-utils.ts b/libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/announcement-of-death-utils.ts index cbad616738b4..57d7171d825e 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/announcement-of-death-utils.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/announcement-of-death-utils.ts @@ -2,6 +2,8 @@ import { Asset, EstateMember, } from '@island.is/application/templates/announcement-of-death/types' +import { isRunningOnEnvironment } from '@island.is/shared/utils' +import { join } from 'path' export function baseMapper(entity: T): T { return { @@ -10,6 +12,20 @@ export function baseMapper(entity: T): T { } } +export const pathToAsset = (file: string) => { + if (isRunningOnEnvironment('local')) { + return join( + __dirname, + `../../../../libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/emailGenerators/assets/${file}`, + ) + } + + return join( + __dirname, + `./announcement-of-death/emailGenerators/assets/${file}`, + ) +} + export const dummyAsset: Asset = { dummy: true, initial: false, diff --git a/libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/announcement-of-death.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/announcement-of-death.service.ts index 81418ae0a850..9589c03b6571 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/announcement-of-death.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/announcement-of-death.service.ts @@ -23,15 +23,19 @@ import { import { isPerson } from 'kennitala' import { BaseTemplateApiService } from '../../base-template-api.service' -import { ApplicationTypes } from '@island.is/application/types' +import { Application, ApplicationTypes } from '@island.is/application/types' import { coreErrorMessages } from '@island.is/application/core' import { TemplateApiError } from '@island.is/nest/problem' +import { generateFirearmApplicantEmail } from './emailGenerators/firearmApplicantNotification' +import { SharedTemplateApiService } from '../../shared' +import { generateRequestReviewSms } from './smsGenerators/requestReviewSms' @Injectable() export class AnnouncementOfDeathService extends BaseTemplateApiService { constructor( @Inject(LOGGER_PROVIDER) private logger: Logger, private readonly syslumennService: SyslumennService, + private readonly sharedTemplateAPIService: SharedTemplateApiService, ) { super(ApplicationTypes.ANNOUNCEMENT_OF_DEATH) } @@ -126,6 +130,41 @@ export class AnnouncementOfDeathService extends BaseTemplateApiService { } } + private async notifyApplicant(answers: aodAnswers, application: Application) { + const applicant = answers.firearmApplicant + + if (!applicant) return + + if (applicant.phone) { + await this.sendSmsNotification(applicant.phone, application) + } + if (applicant.email) { + await this.sendEmailNotification(applicant.email, application) + } + } + + private async sendSmsNotification(phone: string, application: Application) { + try { + await this.sharedTemplateAPIService.sendSms( + (_) => generateRequestReviewSms(application), + application, + ) + } catch (error) { + this.logger.error(`Error sending SMS to ${phone}`, error) + } + } + + private async sendEmailNotification(email: string, application: Application) { + try { + await this.sharedTemplateAPIService.sendEmail( + (props) => generateFirearmApplicantEmail(props), + application, + ) + } catch (error) { + this.logger.error(`Error sending email to ${email}`, error) + } + } + async submitApplication({ application }: TemplateApiModuleActionProps) { if ( (application.answers?.pickRole as PickRole).roleConfirmation === @@ -199,6 +238,8 @@ export class AnnouncementOfDeathService extends BaseTemplateApiService { vehicles: JSON.stringify( answers.vehicles.vehicles.filter((vehicle) => !vehicle?.dummy), ), + hadFirearms: answers.hadFirearms, + firearm: JSON.stringify(answers.firearmApplicant), bankcodeSecuritiesOrShares: otherProperties.includes( OtherPropertiesEnum.ACCOUNTS, ) @@ -257,6 +298,9 @@ export class AnnouncementOfDeathService extends BaseTemplateApiService { 'Application submission failed on syslumadur upload data', ) } + if (answers.firearmApplicant) { + this.notifyApplicant(answers, application) + } return { success: result.success, id: result.caseNumber } } } diff --git a/libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/emailGenerators/assets/logo.jpg b/libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/emailGenerators/assets/logo.jpg new file mode 100644 index 0000000000000000000000000000000000000000..49ad45175f7b3f037ddbe614ef48c1cb5242c041 GIT binary patch literal 2885 zcmbVOc{J4P8~=W1##ov#j9p_JhOuR$xY@Ua2xCn$n365ojV{?$$Ye<+Ym_Tv8CjBT z>>*^CNK&$I>DJ|k%WqolJ?HoD@AJOryyraUeBSdspYxp0^BlZ6m;ty=jZYf`AP4{; z^8g3?fSAD*U;hA7U?9mu+$~((%b#>fF@WU$D|ql0hy!5%0uE<^!`WDwU_-Ef2Z9&D ziC|t{B#N7h8-+v*@bL+tC69<4k;F+$<5cmghKA1IzkJyL_rU=jK(YbiKsywa1RzKd ziUbcj01*IyK*8^|`~y}t0L~5tSq>%vwx97Gtaj@q+SHS=aF_GKy%>sounfWL#r3j5 zCvZ|xfE!tSQQg+bNccXQRkVG&Jz@J;-sE{MhIm~p}&j<7IWZT?QiV}qHJ5D5HlMgSDX0)YcR5`u6u^IRkS zISL6jIgZzK&Po~1n{;sWwfsT+!ThHX<_kht-~jXo5&E4-9T{!IsD#%Kf4G*m3mn4AhU5ddc~HFkDguHMQpeTpgG0oBX#(;97qK2CgI6@O z@2ocs3rL2;6)8LYZU(Mq(NfFRf}Y^h7{aU5FW6e0dzRsd4xhYd@Tq|ts7yyg=U&Ug z@WU?eZZzEw9=>?z_e)jwhrcvg2%IZ+#?D^#mMkpb(u$kS`qr>k+K2MZHYvFWlgYar zwQ6DFA~r2w9(Xg>B#73;yLl~vy52E8pgof=r%kJuPYkbWDRZ2>!&=)MBj>^pIviW+ z?ujhS@u%`EDV4e3uGrYT+mra|I zH{X$+5>20VYvUF9jAE_HXlygb(S{b*ftwVWnvQq+#+uHILW)~+2Yu*M2%v>2Voh=6 zf1#}IR<)So{gEMt;ygdRW+S0zZYTuTOD$5+@vNbbh-03PLxwzu&Y4g9zq-PhjM9|y zOl-#Ec8=v+&U$?!@I3$tKGMDoqRHW0ypldHgGmDAd1 z$H&GYyPMrnN76suYKUpHbz5EH*!H~Ay_fKnk95o8*t?$Oc>Si=V3pd}^M9$HJuEkz z%h!1|Mpjk*CCY5LReN?_d!bW2p+@m?nZD%~4_=7FIt{kR`#9sudhg&?=l0xs*|WiZ z{b}zi50jgkZm0MM4rOE}6@al#-g-y%gndZ35iLjBVq^cDVFEfy=CNA3JY9LL&T=_> zGipxS|0MC-@^qaS-Qm$Zn&emZ!9GDESBF5f6%Wl>B-t|ZK7`+Eygy&cs+{P8>ITK_ zx(xJPZyQ*-#LeZv)Iz<9ahM43xW~~F&G$;hDSh_dZPiiI27RP20=HCO_Bo~U1o!CX zQZmCBr)4BcCguXF`@&|X1?cIbd{&y0g@0=rN3P}^0M{<0x_I@G65RN=Ty91h8cPmA zCJF+wssshOLsLA_Y*J@Zi^tZ!_Ac)QHF+8G-I7Pphz?m37rX?kDArnxh7yh2Eq> zPALJ%kHUwrjCzfNLo_~uj>ZCeP*7C9&~3$PflD*5j7+vH7PITSw8+>C6_&EYNfr(o z_bV43FVL%3UYwZ9Ey_zu;3!C@!hvG>-E#pNbx2qz>g`n1fWV<6UlM&xKGLEX zR+l?Ig!h*@N|hc~ZO-LBx=UJ(A9(tC?@69$A8{+B#?QBU-eIp^GI*LiZsWf6hF{!q zn}!tR2t;@*89CK-z=OhXT4xOnHl+)CH{4yziLIDyjC6lgUTSGq_n#2m6-opBg@In# z%Er`CyrbDuk(}8_&+&XiqO-;l8m{wR?YVh*9DUTa_jkytWEm7L5?`Oq`rN*jIvePB zT{FOIrY&nrT_ZWQWhg@7d7PYMJ>}*)=X~@5@Y9_jOnU-YKvou}e=z|huL zl91FRvhYb+#m0?@AH~PK{^d@*Isk6Z_{gpzgY%gmJI4KuvvR3vLk|&ME1LIcZ}^eXy4A8!^%` zCG((b9=~H-3(nf4dq43S6479g`|gm}7-A{-@hFui-xap$ zUA=6%VEngEY6%5fi`Sr+)wh|pVHJXH&z`)91qfSL=?i}ov;?NQuo=ydwjacegiRIv zj(ZDimUewPNyagz<@X34jzJ&p6&?V}eu2fVo?^cAjp$6gMDks`QXJ%w@ZV0^f7~lc zS~N6~qU4;tG3%Y_s)I;Jg?Ea@nN6e-h7-HYzxl+d_YYu_oLTnh_I)*W-TTW9$T>-o zyU{j^pCQ%=fTcZbe{OjUai_ggsvk2%&OFJONHfZ77mmo!N_Wr|;chn`Ek&@2-<;SE zLp(&S#5&bUJ0K#Ud`q~+sz7wnZ&_>La&4ppm|pnMe`U5{rC&|0-4L~IV-6$N^=~C# z7wzB@&Jn(6+D|d_w1rA6KJ@`t~c!`6blO6^mM3?q{g zS+}&8par#Ht2;ri!g1w@Inq?wt~NLeRZR98PU@*_sf*}v->E4on|r&5NI`dU4g~Jq zl2gcEq~zq|#$v-AbTzue>J9+-%Tml|1JNNriRQapg(}Ooi1u;i^gO1PSR?>KnSeom zI>7g}lPM+(l1D;?ThfXbuV;69rTv7a;PQ>l>vB=N`+#b870b z@)oP%dZBk-tTFc^^kmi19HZ}L>p4w{uWYWX_ZqeOnD!9HCtC0^Z1e77DyyOKmucrO zQCr&1ge3^c%k%2gQBk { + const { + application, + options: { email = { sender: 'Ísland.is', address: 'no-reply@island.is' } }, + } = props + + const firearmApplicant = application.answers + .firearmApplicant as AnnouncementOfDeathAnswers['firearmApplicant'] + + if (!firearmApplicant) throw new Error('Firearm applicant was undefined') + if (!application.answers.caseNumber) + throw new Error('Case number was undefined') + + const subject = 'Tilkynning um vörslu skotvopna' + + return { + from: { + name: email.sender, + address: email.address, + }, + to: [ + { + name: firearmApplicant.name, + address: firearmApplicant.email, + }, + ], + subject, + template: { + title: subject, + body: [ + { + component: 'Image', + context: { + src: pathToAsset('logo.jpg'), + alt: 'Ísland.is logo', + }, + }, + { + component: 'Heading', + context: { copy: subject }, + }, + { + component: 'Copy', + context: { + copy: + `Góðan dag,

` + + `þú hefur verið tilnefndur til að taka við vörslu skotvopna sem tilheyra dánarbúi ${application.answers.caseNumber} - ${firearmApplicant.name}
` + + `Með undirritun lýsir þú því yfir að þú hafir leyfi til að varsla skotvopnin og samþykkir jafnframt að taka við vörslu þeirra.
`, + }, + }, + ], + }, + } +} diff --git a/libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/smsGenerators/requestReviewSms.ts b/libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/smsGenerators/requestReviewSms.ts new file mode 100644 index 000000000000..51defc8d4941 --- /dev/null +++ b/libs/application/template-api-modules/src/lib/modules/templates/announcement-of-death/smsGenerators/requestReviewSms.ts @@ -0,0 +1,20 @@ +import { Application } from '@island.is/application/types' +import { SmsMessage } from '../../../../types' +import { AnnouncementOfDeathAnswers } from '@island.is/application/templates/announcement-of-death' + +export type RequestReviewSms = (application: Application) => SmsMessage + +export const generateRequestReviewSms: RequestReviewSms = (application) => { + const firearmApplicant = application.answers + .firearmApplicant as AnnouncementOfDeathAnswers['firearmApplicant'] + + if (!firearmApplicant?.phone) throw new Error('Recipient phone was undefined') + + return { + phoneNumber: firearmApplicant.phone || '', + message: + `Góðan dag,` + + `þú hefur verið tilnefndur til að taka við vörslu skotvopna sem tilheyra dánarbúi ${application.answers.caseNumber} - ${firearmApplicant.name}` + + `Með undirritun lýsir þú því yfir að þú hafir leyfi til að varsla skotvopnin og samþykkir jafnframt að taka við vörslu þeirra.`, + } +} diff --git a/libs/application/templates/announcement-of-death/src/fields/FirearmApplicant/index.tsx b/libs/application/templates/announcement-of-death/src/fields/FirearmApplicant/index.tsx new file mode 100644 index 000000000000..8f2d5ae6f2d9 --- /dev/null +++ b/libs/application/templates/announcement-of-death/src/fields/FirearmApplicant/index.tsx @@ -0,0 +1,149 @@ +import { useLazyQuery } from '@apollo/client' +import { IdentityInput, Query } from '@island.is/api/schema' +import * as kennitala from 'kennitala' +import { FieldBaseProps } from '@island.is/application/types' +import React, { FC, useEffect } from 'react' +import { FieldErrors, FieldValues, useFormContext } from 'react-hook-form' +import { IDENTITY_QUERY } from '../../graphql' +import { m } from '../../lib/messages' +import { Box, GridColumn, GridRow, Text } from '@island.is/island-ui/core' +import { formatText, getErrorViaPath } from '@island.is/application/core' +import { useLocale } from '@island.is/localization' +import { InputController } from '@island.is/shared/form-fields' + +interface FirearmApplicantBaseProps extends FieldBaseProps { + errors: FieldErrors +} + +const fieldNames = { + firearmApplicantNationalId: 'firearmApplicant.nationalId', + firearmApplicantName: 'firearmApplicant.name', + firearmApplicantPhone: 'firearmApplicant.phone', + firearmApplicantEmail: 'firearmApplicant.email', + lookupError: 'firearmApplicant.lookupError', +} + +export const FirearmApplicant: FC< + React.PropsWithChildren +> = ({ application }) => { + const { formatMessage } = useLocale() + const { + setValue, + watch, + setError, + clearErrors, + formState: { errors }, + } = useFormContext() + + const [getIdentity, { loading: queryLoading }] = useLazyQuery< + Query, + { input: IdentityInput } + >(IDENTITY_QUERY, { + onError: (error: unknown) => { + setError(fieldNames.lookupError, { + type: 'serverError', + message: m.errorNationalIdNoName.defaultMessage, + }) + console.log('getIdentity error:', error) + }, + onCompleted: (data) => { + if (data.identity?.name) { + clearErrors(fieldNames.lookupError) + clearErrors(fieldNames.firearmApplicantName) + setValue(fieldNames.firearmApplicantName, data.identity?.name ?? '') + } else { + setError(fieldNames.lookupError, { + type: 'serverError', + message: m.errorNationalIdNoName.defaultMessage, + }) + } + }, + }) + + // Clear inital errors on mount + useEffect(() => { + clearErrors() + }, []) + + const nationalId = watch(fieldNames.firearmApplicantNationalId) + + const name = watch(fieldNames.firearmApplicantName) + + useEffect(() => { + if (nationalId?.length === 10) { + if (kennitala.isPerson(nationalId)) { + getIdentity({ + variables: { + input: { + nationalId, + }, + }, + }) + } else if (name !== '') { + setValue(fieldNames.firearmApplicantNationalId, '') + } + } else if (name !== '') { + setValue(fieldNames.firearmApplicantName, '') + } + }, [nationalId, name, getIdentity, setValue]) + + return ( + + + {formatText(m.delegateRoleDisclaimer, application, formatMessage)} + + + + + + + + + + + + + + + + + + + ) +} diff --git a/libs/application/templates/announcement-of-death/src/fields/index.ts b/libs/application/templates/announcement-of-death/src/fields/index.ts index 16c7d4766612..67969902531e 100644 --- a/libs/application/templates/announcement-of-death/src/fields/index.ts +++ b/libs/application/templates/announcement-of-death/src/fields/index.ts @@ -8,3 +8,4 @@ export { FilesRecipientCard } from './FilesRecipientCard' export { InfoCard } from './InfoCard' export { AnswerPopulator } from './AnswerPopulator' export { LinkExistingApplication } from './ExistingApplication/LinkExistingApplication' +export { FirearmApplicant } from './FirearmApplicant' diff --git a/libs/application/templates/announcement-of-death/src/forms/done.ts b/libs/application/templates/announcement-of-death/src/forms/done.ts index b4b7057ae351..37fd57524efb 100644 --- a/libs/application/templates/announcement-of-death/src/forms/done.ts +++ b/libs/application/templates/announcement-of-death/src/forms/done.ts @@ -12,6 +12,7 @@ import { m } from '../lib/messages' import { extraInfo, files, + firearmApplicant, inheritance, properties, testament, @@ -58,6 +59,7 @@ export const done: Form = buildForm({ ...theDeceased, ...theAnnouncer, ...testament, + ...firearmApplicant, ...inheritance, ...properties, ...files, diff --git a/libs/application/templates/announcement-of-death/src/forms/draft/draft.ts b/libs/application/templates/announcement-of-death/src/forms/draft/draft.ts index 5bef1b67139d..c1dd65829de4 100644 --- a/libs/application/templates/announcement-of-death/src/forms/draft/draft.ts +++ b/libs/application/templates/announcement-of-death/src/forms/draft/draft.ts @@ -8,6 +8,7 @@ import { m } from '../../lib/messages' import CoatOfArms from '../../assets/CoatOfArms' import { subSectionFiles } from './subSectionFiles' import { sectionOverview } from './sectionOverview' +import { subSectionFirearms } from './subSectionFirearms' export const draft: Form = buildForm({ id: 'AnnouncementOfDeathApplicationDraftForm', @@ -33,6 +34,7 @@ export const draft: Form = buildForm({ children: [ subSectionInfo, subSectionWillAndTrade, + subSectionFirearms, subSectionInheritance, subSectionProperties, subSectionFiles, diff --git a/libs/application/templates/announcement-of-death/src/forms/draft/sectionOverview.ts b/libs/application/templates/announcement-of-death/src/forms/draft/sectionOverview.ts index 37e71acda3a6..5d40dffb698a 100644 --- a/libs/application/templates/announcement-of-death/src/forms/draft/sectionOverview.ts +++ b/libs/application/templates/announcement-of-death/src/forms/draft/sectionOverview.ts @@ -9,6 +9,7 @@ import { additionalInfo, extraInfo, files, + firearmApplicant, inheritance, properties, testament, @@ -29,6 +30,7 @@ export const sectionOverview = buildSection({ ...theDeceased, ...theAnnouncer, ...testament, + ...firearmApplicant, ...inheritance, ...properties, ...files, diff --git a/libs/application/templates/announcement-of-death/src/forms/draft/subSectionFirearms.ts b/libs/application/templates/announcement-of-death/src/forms/draft/subSectionFirearms.ts new file mode 100644 index 000000000000..ec5cb8d739db --- /dev/null +++ b/libs/application/templates/announcement-of-death/src/forms/draft/subSectionFirearms.ts @@ -0,0 +1,45 @@ +import { + buildCustomField, + buildMultiField, + buildRadioField, + buildSubSection, +} from '@island.is/application/core' +import { m } from '../../lib/messages' + +export const subSectionFirearms = buildSubSection({ + id: 'firearmsStep', + title: m.firearmsTitle, + children: [ + buildMultiField({ + id: 'firearmsTitle', + title: m.firearmsTitle, + description: m.firearmsDescription, + children: [ + buildRadioField({ + id: 'hadFirearms', + title: m.firearmsHadFirearms, + width: 'full', + largeButtons: false, + defaultValue: 'no', + options: [ + { + value: 'yes', + label: m.firearmsYes, + }, + { + value: 'no', + label: m.firearmsNo, + }, + ], + }), + buildCustomField({ + title: '', + id: 'firearmApplicant', + description: m.firearmsApplicantTitle, + component: 'FirearmApplicant', + condition: (formValue) => formValue.hadFirearms === 'yes', + }), + ], + }), + ], +}) diff --git a/libs/application/templates/announcement-of-death/src/forms/overviewSections.ts b/libs/application/templates/announcement-of-death/src/forms/overviewSections.ts index 9ccc2b8bf329..be26537a83f6 100644 --- a/libs/application/templates/announcement-of-death/src/forms/overviewSections.ts +++ b/libs/application/templates/announcement-of-death/src/forms/overviewSections.ts @@ -371,6 +371,45 @@ export const files: Field[] = [ ), ] +export const firearmApplicant: Field[] = [ + buildDividerField({ + condition: (answers) => showInDone(answers.viewOverview), + }), + buildDescriptionField({ + id: 'firearmApplicant', + title: m.firearmsTitle, + description: m.firearmsDescription, + titleVariant: 'h3', + condition: (answers) => showInDone(answers.viewOverview), + }), + buildKeyValueField({ + label: m.firearmsApplicantName, + width: 'half', + value: ({ answers }) => (answers.firearmApplicant as any)?.name || '', + condition: (answers) => showInDone(answers.viewOverview), + }), + buildKeyValueField({ + label: m.firearmsApplicantNationalId, + width: 'half', + value: ({ answers }) => + formatNationalId((answers.firearmApplicant as any)?.nationalId || ''), + condition: (answers) => showInDone(answers.viewOverview), + }), + buildKeyValueField({ + label: m.firearmsApplicantPhone, + width: 'half', + value: ({ answers }) => + formatPhoneNumber((answers.firearmApplicant as any)?.phone || ''), + condition: (answers) => showInDone(answers.viewOverview), + }), + buildKeyValueField({ + label: m.firearmsApplicantEmail, + width: 'half', + value: ({ answers }) => (answers.firearmApplicant as any)?.email || '', + condition: (answers) => showInDone(answers.viewOverview), + }), +] + export const additionalInfo: Field[] = [ buildDividerField({}), buildDescriptionField({ diff --git a/libs/application/templates/announcement-of-death/src/index.ts b/libs/application/templates/announcement-of-death/src/index.ts index df97e198d7b1..c51b48073977 100644 --- a/libs/application/templates/announcement-of-death/src/index.ts +++ b/libs/application/templates/announcement-of-death/src/index.ts @@ -1,5 +1,8 @@ import AnnouncementOfDeathTemplate from './lib/announcementOfDeathTemplate' +import { AnnouncementOfDeath } from './lib/dataSchema' export const getDataProviders = () => import('./dataProviders/') export const getFields = () => import('./fields/') +export type AnnouncementOfDeathAnswers = AnnouncementOfDeath + export default AnnouncementOfDeathTemplate diff --git a/libs/application/templates/announcement-of-death/src/lib/dataSchema.ts b/libs/application/templates/announcement-of-death/src/lib/dataSchema.ts index 0bc180b7d48c..09b4fec3bcb0 100644 --- a/libs/application/templates/announcement-of-death/src/lib/dataSchema.ts +++ b/libs/application/templates/announcement-of-death/src/lib/dataSchema.ts @@ -77,6 +77,16 @@ export const dataSchema = z.object({ }), applicantEmail: customZodError(z.string().email(), m.errorEmail), applicantRelation: customZodError(z.string().min(1), m.errorRelation), + firearmApplicant: z + .object({ + nationalId: z.string(), + name: z.string(), + phone: z.string().refine((v) => isValidPhoneNumber(v), { + params: m.errorPhoneNumber, + }), + email: customZodError(z.string().email(), m.errorEmail), + }) + .optional(), assets: z.object({ assets: z .object({ @@ -118,3 +128,5 @@ export const dataSchema = z.object({ encountered: z.boolean().optional(), }), }) + +export type AnnouncementOfDeath = z.TypeOf diff --git a/libs/application/templates/announcement-of-death/src/lib/messages.ts b/libs/application/templates/announcement-of-death/src/lib/messages.ts index d7fea9eab5c6..8dbd29b74588 100644 --- a/libs/application/templates/announcement-of-death/src/lib/messages.ts +++ b/libs/application/templates/announcement-of-death/src/lib/messages.ts @@ -199,6 +199,60 @@ export const m = defineMessages({ description: 'Testament step knowledge of other testament answer no', }, + /* Firearms step */ + firearmsTitle: { + id: 'aod.application:firearmsTitle', + defaultMessage: 'Skotvopn', + description: 'Firearms step title', + }, + firearmsDescription: { + id: 'aod.application:firearmsDescription#markdown', + defaultMessage: `Skrá þarf upplýsingar um skotvopn látna og nafn og kennitölu þess sem hefur samþykkt að taka við vörslu þeirra. + Vörsluaðili þarf að vera með gilt leyfi til að varsla skotvopnin. + Hann fær sms/tölvupóst með beiðni um að samþykkja að taka við vörslu skotvopnanna.`, + description: 'Firearms step description', + }, + firearmsHadFirearms: { + id: 'aod.application:firearmsHadFirearms', + defaultMessage: 'Hafði hinn látni skotvopn?', + description: 'Firearms step had firearms', + }, + firearmsYes: { + id: 'aod.application:firearmsYes', + defaultMessage: 'Já', + description: 'Firearms step answer yes', + }, + firearmsNo: { + id: 'aod.application:firearmsNo', + defaultMessage: 'Nei', + description: 'Firearms step answer no', + }, + firearmsApplicantTitle: { + id: 'aod.application:firearmsApplicantTitle', + defaultMessage: 'Upplýsingar um umsækjanda', + description: 'Firearms step applicant title', + }, + firearmsApplicantName: { + id: 'aod.application:firearmsApplicantName', + defaultMessage: 'Nafn', + description: 'Firearms step applicant name', + }, + firearmsApplicantNationalId: { + id: 'aod.application:firearmsApplicantNationalId', + defaultMessage: 'Kennitala', + description: 'Firearms step applicant national id', + }, + firearmsApplicantEmail: { + id: 'aod.application:firearmsApplicantEmail', + defaultMessage: 'Netfang', + description: 'Firearms step applicant email', + }, + firearmsApplicantPhone: { + id: 'aod.application:firearmsApplicantPhone', + defaultMessage: 'Símanúmer', + description: 'Firearms step applicant phone', + }, + /* Inheritance step */ inheritanceTitle: { id: 'aod.application:inheritanceTitle', diff --git a/libs/application/templates/announcement-of-death/src/types.ts b/libs/application/templates/announcement-of-death/src/types.ts index b8ff7c1908b5..0079b7f0b2a7 100644 --- a/libs/application/templates/announcement-of-death/src/types.ts +++ b/libs/application/templates/announcement-of-death/src/types.ts @@ -46,6 +46,8 @@ export type Answers = { } financesDataCollectionPermission?: boolean knowledgeOfOtherWills: 'yes' | 'no' + hadFirearms: 'yes' | 'no' + firearmApplicant: FirearmApplicant marriageSettlement: boolean occupationRightViaCondominium: boolean otherProperties: OtherPropertiesEnum @@ -57,6 +59,13 @@ export type Answers = { } } & FormValue +export interface FirearmApplicant { + nationalId: string + name: string + phone: string + email: string +} + export interface ElectPersonType { roleConfirmation: RoleConfirmationEnum electedPersonName?: string From 32136431b366aa662ea9d2d1e2f3151a7c612626 Mon Sep 17 00:00:00 2001 From: kksteini <77672665+kksteini@users.noreply.github.com> Date: Wed, 15 May 2024 14:39:29 +0000 Subject: [PATCH 09/10] chore(application-driving-license): Test phone number formatting (#14804) * chore(application-driving-license): Test phone number formatting * fix import --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../driving-license-submission.service.ts | 4 ++-- .../utils/healthDeclarationMapper.ts | 4 ++-- .../utils/index.spec.ts | 19 +++++++++++++++++++ .../driving-license-submission/utils/index.ts | 10 ++++++++-- 4 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 libs/application/template-api-modules/src/lib/modules/templates/driving-license-submission/utils/index.spec.ts diff --git a/libs/application/template-api-modules/src/lib/modules/templates/driving-license-submission/driving-license-submission.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/driving-license-submission/driving-license-submission.service.ts index 1e5d88f5f7cf..75180663ebed 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/driving-license-submission/driving-license-submission.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/driving-license-submission/driving-license-submission.service.ts @@ -28,7 +28,7 @@ import { PostTemporaryLicenseWithHealthDeclarationMapper, DrivingLicenseSchema, } from './utils/healthDeclarationMapper' -import { removeCountryCode } from './utils' +import { formatPhoneNumber } from './utils' const calculateNeedsHealthCert = (healthDeclaration = {}) => { return !!Object.values(healthDeclaration).find((val) => val === 'yes') @@ -143,7 +143,7 @@ export class DrivingLicenseSubmissionService extends BaseTemplateApiService { const jurisdictionId = answers.jurisdiction const teacher = answers.drivingInstructor as string const email = answers.email as string - const phone = removeCountryCode(answers.phone as string) + const phone = formatPhoneNumber(answers.phone as string) const postHealthDeclaration = async ( nationalId: string, diff --git a/libs/application/template-api-modules/src/lib/modules/templates/driving-license-submission/utils/healthDeclarationMapper.ts b/libs/application/template-api-modules/src/lib/modules/templates/driving-license-submission/utils/healthDeclarationMapper.ts index 662f5c87ea72..7a9138954539 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/driving-license-submission/utils/healthDeclarationMapper.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/driving-license-submission/utils/healthDeclarationMapper.ts @@ -5,7 +5,7 @@ import { import { dataSchema } from '@island.is/application/templates/driving-license' import { infer as zinfer } from 'zod' -import { removeCountryCode } from './' +import { formatPhoneNumber } from './' export type DrivingLicenseSchema = zinfer @@ -55,7 +55,7 @@ export const PostTemporaryLicenseWithHealthDeclarationMapper = ( if (key in propertyMapping) { let value = answers[key as keyof DrivingLicenseSchema] if (key === 'phone') { - value = typeof value === 'string' ? removeCountryCode(value) : value + value = typeof value === 'string' ? formatPhoneNumber(value) : value } const mappedKey = propertyMapping[ key diff --git a/libs/application/template-api-modules/src/lib/modules/templates/driving-license-submission/utils/index.spec.ts b/libs/application/template-api-modules/src/lib/modules/templates/driving-license-submission/utils/index.spec.ts new file mode 100644 index 000000000000..c06df76f0c1d --- /dev/null +++ b/libs/application/template-api-modules/src/lib/modules/templates/driving-license-submission/utils/index.spec.ts @@ -0,0 +1,19 @@ +import { formatPhoneNumber } from './index' + +describe('Format Phone Number Before Submission', () => { + it('should remove country code from phone number', () => { + expect(formatPhoneNumber('6003543')).toBe('6003543') + expect(formatPhoneNumber('0035401234567')).toBe('01234567') + expect(formatPhoneNumber('00354 01234567')).toBe('01234567') + expect(formatPhoneNumber('+35401234567')).toBe('01234567') + expect(formatPhoneNumber('+354 01234567')).toBe('01234567') + expect(formatPhoneNumber(' +35401234567')).toBe('01234567') + expect(formatPhoneNumber(' +354 012 34567 ')).toBe('01234567') + expect(formatPhoneNumber('+354 012 34567 ')).toBe('01234567') + }) + + it('should remove all non-digits from phone number', () => { + expect(formatPhoneNumber('012-345-67')).toBe('01234567') + expect(formatPhoneNumber('00354 012 345 67')).toBe('01234567') + }) +}) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/driving-license-submission/utils/index.ts b/libs/application/template-api-modules/src/lib/modules/templates/driving-license-submission/utils/index.ts index ddb0ec1fbc7c..ea0909e42182 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/driving-license-submission/utils/index.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/driving-license-submission/utils/index.ts @@ -1,3 +1,9 @@ -export const removeCountryCode = (phone: string) => { - return phone.replace(/(^00354|^\+354|\D)/g, '') +// Note. The frontend application validates +// the phone number according to libphonenumber-js +// for 'IS'. +export const formatPhoneNumber = (phone: string) => { + return phone + .trim() + .replace(/(^00354|^\+354)/g, '') // Remove country code + .replace(/\D/g, '') // Remove all non-digits } From 08e214de76c4e75d2d6e0ebc203b688102d393a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Eorkell=20M=C3=A1ni=20=C3=9Eorkelsson?= Date: Wed, 15 May 2024 15:14:41 +0000 Subject: [PATCH 10/10] chore(CODEOWNERS): remove soffia from codeowners (#14813) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Þorkell Máni Þorkelsson --- .github/CODEOWNERS | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index b14aca08a2c2..6da0e304b9ce 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -166,7 +166,6 @@ codemagic.yaml /libs/clients/license-client/ @island-is/hugsmidjan @island-is/aranja /libs/clients/intellectual-properties/ @island-is/hugsmidjan /libs/clients/islykill/ @island-is/hugsmidjan -/libs/clients/national-registry/v1/ @island-is/hugsmidjan /libs/clients/national-registry/v3/ @island-is/hugsmidjan /libs/clients/district-commissioners-licenses/ @island-is/hugsmidjan /libs/clients/regulations/ @island-is/hugsmidjan