diff --git a/apps/application-system/api/src/app/app.module.ts b/apps/application-system/api/src/app/app.module.ts index d88c0691bb5e..eaee6a8384a5 100644 --- a/apps/application-system/api/src/app/app.module.ts +++ b/apps/application-system/api/src/app/app.module.ts @@ -60,6 +60,7 @@ import { FriggClientConfig } from '@island.is/clients/mms/frigg' import { smsModuleConfig } from '@island.is/nova-sms' import { emailModuleConfig } from '@island.is/email-service' import { sharedModuleConfig } from '@island.is/application/template-api-modules' +import { UserNotificationClientConfig } from '@island.is/clients/user-notification' @Module({ imports: [ @@ -119,6 +120,7 @@ import { sharedModuleConfig } from '@island.is/application/template-api-modules' smsModuleConfig, emailModuleConfig, sharedModuleConfig, + UserNotificationClientConfig, ], }), ], diff --git a/libs/application/template-api-modules/src/lib/modules/templates/children-residence-change-v2/children-residence-change.module.ts b/libs/application/template-api-modules/src/lib/modules/templates/children-residence-change-v2/children-residence-change.module.ts index a277964e967b..ff8f569ef6f2 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/children-residence-change-v2/children-residence-change.module.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/children-residence-change-v2/children-residence-change.module.ts @@ -4,6 +4,7 @@ import { SyslumennClientModule } from '@island.is/clients/syslumenn' import { NationalRegistryClientModule } from '@island.is/clients/national-registry-v2' import { SharedTemplateAPIModule } from '../../shared' import { SmsModule } from '@island.is/nova-sms' +import { ApplicationsNotificationsModule } from '../../../notification/notifications.module' @Module({ imports: [ @@ -11,6 +12,7 @@ import { SmsModule } from '@island.is/nova-sms' SharedTemplateAPIModule, SmsModule, NationalRegistryClientModule, + ApplicationsNotificationsModule, ], providers: [ChildrenResidenceChangeServiceV2], exports: [ChildrenResidenceChangeServiceV2], diff --git a/libs/application/template-api-modules/src/lib/modules/templates/children-residence-change-v2/children-residence-change.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/children-residence-change-v2/children-residence-change.service.ts index 37e2e849aa44..d039efb1bd56 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/children-residence-change-v2/children-residence-change.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/children-residence-change-v2/children-residence-change.service.ts @@ -1,5 +1,8 @@ -import { Injectable } from '@nestjs/common' -import { TemplateApiModuleActionProps } from '../../../types' +import { Inject, Injectable } from '@nestjs/common' +import { + SharedModuleConfig, + TemplateApiModuleActionProps, +} from '../../../types' import { SyslumennService, Person, @@ -14,20 +17,17 @@ import { import { Override } from '@island.is/application/templates/family-matters-core/types' import { CRCApplication } from '@island.is/application/templates/children-residence-change-v2' import { SharedTemplateApiService } from '../../shared' -import { - applicationRejectedByOrganizationEmail, - generateApplicationSubmittedEmail, - generateSyslumennNotificationEmail, - transferRequestedEmail, -} from './emailGenerators' +import { generateSyslumennNotificationEmail } from './emailGenerators' import { Application, ApplicationTypes } from '@island.is/application/types' -import { SmsService } from '@island.is/nova-sms' import { syslumennDataFromPostalCode } from './utils' -import { applicationRejectedEmail } from './emailGenerators/applicationRejected' import { BaseTemplateApiService } from '../../base-template-api.service' -import { NationalRegistryClientService } from '@island.is/clients/national-registry-v2' import { isValidNumberForRegion } from 'libphonenumber-js' import { generateResidenceChangePdf } from './pdfGenerators' +import { NotificationsService } from '../../../notification/notifications.service' +import { NotificationType } from '../../../notification/notificationsTemplates' +import { getSlugFromType } from '@island.is/application/core' +import { ConfigService } from '@nestjs/config' +import { getConfigValue } from '../../shared/shared.utils' type Props = Override< TemplateApiModuleActionProps, @@ -39,8 +39,8 @@ export class ChildrenResidenceChangeServiceV2 extends BaseTemplateApiService { constructor( private readonly syslumennService: SyslumennService, private readonly sharedTemplateAPIService: SharedTemplateApiService, - private readonly smsService: SmsService, - private nationalRegistryApi: NationalRegistryClientService, + private readonly notificationsService: NotificationsService, + private readonly configService: ConfigService, ) { super(ApplicationTypes.CHILDREN_RESIDENCE_CHANGE_V2) } @@ -166,82 +166,160 @@ export class ChildrenResidenceChangeServiceV2 extends BaseTemplateApiService { } async sendNotificationToCounterParty({ application }: Props) { - const { answers } = application - const { counterParty } = answers + const { + externalData: { nationalRegistry, childrenCustodyInformation }, + } = application - if (counterParty.email) { - await this.sharedTemplateAPIService.sendEmail( - transferRequestedEmail, - application as unknown as Application, - ) + if ( + !childrenCustodyInformation?.data || + childrenCustodyInformation.data.length === 0 + ) { + throw new Error('No custody information available') } - if (counterParty.phoneNumber) { - await this.smsService.sendSms( - counterParty.phoneNumber, - 'Þér hafa borist drög að samningi um breytt lögheimili barns á Island.is. Samningurinn er aðgengilegur á island.is/minarsidur undir Umsóknir.', - ) + const applicant = nationalRegistry.data + const otherParent = childrenCustodyInformation.data[0].otherParent + const contractLink = await this.getApplicationLink(application) + + if (otherParent) { + this.notificationsService.sendNotification({ + type: NotificationType.AssignCounterParty, + messageParties: { + recipient: otherParent.nationalId, + sender: applicant.nationalId, + }, + args: { + applicantName: applicant.fullName, + contractLink, + }, + }) } } // Sends notification to both parties async approvedByOrganization({ application }: Props) { - const { answers, externalData } = application - const { parentA, parentB } = answers - const { nationalRegistry } = externalData + const { + externalData: { + nationalRegistry, + childrenCustodyInformation, + submitApplication, + }, + } = application + if ( + !childrenCustodyInformation?.data || + childrenCustodyInformation.data.length === 0 + ) { + throw new Error('No custody information available') + } const applicant = nationalRegistry.data - const childResidenceInfo = childrenResidenceInfo( - applicant, - externalData.childrenCustodyInformation.data, - answers.selectedChildren, - ) - const caseNumber = externalData.submitApplication?.data?.caseNumber + const otherParent = childrenCustodyInformation.data[0].otherParent + const caseNumber = submitApplication?.data?.caseNumber + const applicationLink = await this.getApplicationLink(application) - if (!childResidenceInfo.future?.address?.postalCode) { - throw new Error('Future residence postal code was not found') + if (!otherParent) { + throw new Error('Other parent was undefined') } - const pdf = await generateResidenceChangePdf(application) - const syslumennData = syslumennDataFromPostalCode( - childResidenceInfo.future.address.postalCode, - ) - - await this.sharedTemplateAPIService.sendEmail( - (props) => - generateApplicationSubmittedEmail( - props, - pdf.toString('binary'), - parentA.email, - syslumennData.name, - caseNumber, - ), - application as unknown as Application, - ) - - await this.sharedTemplateAPIService.sendEmail( - (props) => - generateApplicationSubmittedEmail( - props, - pdf.toString('binary'), - parentB.email, - syslumennData.name, - caseNumber, - ), - application as unknown as Application, - ) + this.notificationsService.sendNotification({ + type: NotificationType.ChildrenResidenceChangeApprovedByOrg, + messageParties: { + recipient: applicant.nationalId, + }, + args: { + applicationLink, + caseNumber: caseNumber || '', + }, + }) + this.notificationsService.sendNotification({ + type: NotificationType.ChildrenResidenceChangeApprovedByOrg, + messageParties: { + recipient: otherParent.nationalId, + }, + args: { + applicationLink, + caseNumber: caseNumber || '', + }, + }) } async rejectedByCounterParty({ application }: Props) { - await this.sharedTemplateAPIService.sendEmail( - applicationRejectedEmail, - application as unknown as Application, - ) + const { + externalData: { nationalRegistry, childrenCustodyInformation }, + } = application + if ( + !childrenCustodyInformation?.data || + childrenCustodyInformation.data.length === 0 + ) { + throw new Error('No custody information available') + } + const applicant = nationalRegistry.data + const otherParent = childrenCustodyInformation.data[0].otherParent + + this.notificationsService.sendNotification({ + type: NotificationType.RejectedByCounterParty, + messageParties: { + recipient: applicant.nationalId, + }, + args: { + counterPartyName: otherParent?.fullName || '', + }, + }) } async rejectedByOrganization({ application }: Props) { - await this.sharedTemplateAPIService.sendEmail( - applicationRejectedByOrganizationEmail, - application as unknown as Application, + const { + answers, + externalData: { nationalRegistry, childrenCustodyInformation }, + } = application + if ( + !childrenCustodyInformation?.data || + childrenCustodyInformation.data.length === 0 + ) { + throw new Error('No custody information available') + } + const applicant = nationalRegistry.data + const otherParent = childrenCustodyInformation.data[0].otherParent + const childResidenceInfo = childrenResidenceInfo( + applicant, + childrenCustodyInformation.data, + answers.selectedChildren, ) + const syslumennName = syslumennDataFromPostalCode( + childResidenceInfo?.future?.address?.postalCode || '', + ).name + + if (!otherParent) { + throw new Error('Other parent was undefined') + } + + this.notificationsService.sendNotification({ + type: NotificationType.RejectedByOrganization, + messageParties: { + recipient: applicant.nationalId, + }, + args: { + orgName: syslumennName, + }, + }) + this.notificationsService.sendNotification({ + type: NotificationType.RejectedByOrganization, + messageParties: { + recipient: otherParent.nationalId, + }, + args: { + orgName: syslumennName, + }, + }) + } + + private async getApplicationLink(application: CRCApplication) { + const clientLocationOrigin = getConfigValue( + this.configService, + 'clientLocationOrigin', + ) as string + + return `${clientLocationOrigin}/${ + getSlugFromType(application.typeId) as string + }/${application.id}` as string } } diff --git a/libs/application/template-api-modules/src/lib/modules/templates/european-health-insurance-card/european-health-insurance-card.module.ts b/libs/application/template-api-modules/src/lib/modules/templates/european-health-insurance-card/european-health-insurance-card.module.ts index 035139b05d16..a53e188627b1 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/european-health-insurance-card/european-health-insurance-card.module.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/european-health-insurance-card/european-health-insurance-card.module.ts @@ -1,10 +1,10 @@ import { Module } from '@nestjs/common' import { SharedTemplateAPIModule } from '../../shared' import { EuropeanHealthInsuranceCardService } from './european-health-insurance-card.service' -import { EhicClientModule } from '@island.is/clients/ehic-client-v1' +import { RightsPortalClientModule } from '@island.is/clients/icelandic-health-insurance/rights-portal' @Module({ - imports: [EhicClientModule, SharedTemplateAPIModule], + imports: [SharedTemplateAPIModule, RightsPortalClientModule], providers: [EuropeanHealthInsuranceCardService], exports: [EuropeanHealthInsuranceCardService], }) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/european-health-insurance-card/european-health-insurance-card.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/european-health-insurance-card/european-health-insurance-card.service.ts index acd4a4fc0568..46c16ccfed72 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/european-health-insurance-card/european-health-insurance-card.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/european-health-insurance-card/european-health-insurance-card.service.ts @@ -1,5 +1,4 @@ import { Inject, Injectable } from '@nestjs/common' -import { EhicApi } from '@island.is/clients/ehic-client-v1' import { LOGGER_PROVIDER } from '@island.is/logging' import type { Logger } from '@island.is/logging' import { @@ -18,7 +17,7 @@ import { } from './types' import { TemplateApiModuleActionProps } from '../../../types' import { Auth, AuthMiddleware } from '@island.is/auth-nest-tools' - +import { EhicApi } from '@island.is/clients/icelandic-health-insurance/rights-portal' @Injectable() export class EuropeanHealthInsuranceCardService extends BaseTemplateApiService { constructor( @@ -29,6 +28,10 @@ export class EuropeanHealthInsuranceCardService extends BaseTemplateApiService { super(ApplicationTypes.EUROPEAN_HEALTH_INSURANCE_CARD) } + private ehicApiWithAuth(auth: Auth) { + return this.ehicApi.withMiddleware(new AuthMiddleware(auth)) + } + /** Returns unique values of an array */ onlyUnique(value: string, index: number, array: string[]) { return array.indexOf(value) === index @@ -149,11 +152,9 @@ export class EuropeanHealthInsuranceCardService extends BaseTemplateApiService { const nridArr = this.getApplicants(application) if (nridArr?.length > 0) { try { - const resp = await this.ehicApi - .withMiddleware(new AuthMiddleware(auth as Auth)) - .cardStatus({ - applicantnationalids: this.toCommaDelimitedList(nridArr), - }) + const resp = await this.ehicApiWithAuth(auth).getEhicCardStatus({ + applicantnationalids: this.toCommaDelimitedList(nridArr), + }) if (!resp) { this.logger.error( @@ -188,12 +189,10 @@ export class EuropeanHealthInsuranceCardService extends BaseTemplateApiService { for (let i = 0; i < applicants?.length; i++) { try { - const res = await this.ehicApi - .withMiddleware(new AuthMiddleware(auth as Auth)) - .requestCard({ - applicantnationalid: applicants[i], - cardtype: CardType.PLASTIC, - }) + const res = await this.ehicApiWithAuth(auth).requestEhicCard({ + applicantnationalid: applicants[i], + cardtype: CardType.PLASTIC, + }) cardResponses.push(res) } catch (error) { this.logger.error('EHIC.API error applyForPhysicalCard', error) @@ -214,12 +213,10 @@ export class EuropeanHealthInsuranceCardService extends BaseTemplateApiService { for (let i = 0; i < applicants?.length; i++) { try { - await this.ehicApi - .withMiddleware(new AuthMiddleware(auth as Auth)) - .requestCard({ - applicantnationalid: applicants[i], - cardtype: CardType.PDF, - }) + await this.ehicApiWithAuth(auth).requestEhicCard({ + applicantnationalid: applicants[i], + cardtype: CardType.PDF, + }) } catch (error) { this.logger.error('EHIC.API error applyForTemporaryCard', error) throw error @@ -233,12 +230,14 @@ export class EuropeanHealthInsuranceCardService extends BaseTemplateApiService { for (let i = 0; i < applicants?.length; i++) { try { - const res = await this.ehicApi - .withMiddleware(new AuthMiddleware(auth as Auth)) - .fetchTempPDFCard({ - applicantnationalid: applicants[i].nationalId ?? '', - cardnumber: applicants[i].cardNumber ?? '', - }) + const { nationalId, cardNumber } = applicants[i] + if (!nationalId || !cardNumber) { + throw new Error('National ID or card number is missing') + } + const res = await this.ehicApiWithAuth(auth).fetchTempEhicPDFCard({ + applicantnationalid: nationalId, + cardnumber: cardNumber, + }) pdfArray.push(res) } catch (error) { this.logger.error('EHIC.API error getTemporaryCard', error) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/reference-template/reference-template.module.ts b/libs/application/template-api-modules/src/lib/modules/templates/reference-template/reference-template.module.ts index e5ef71eb5fa8..4dfcc00298e5 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/reference-template/reference-template.module.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/reference-template/reference-template.module.ts @@ -5,9 +5,9 @@ import { SharedTemplateAPIModule } from '../../shared' // Here you import your module service import { ReferenceTemplateService } from './reference-template.service' - +import { ApplicationsNotificationsModule } from '../../../notification/notifications.module' @Module({ - imports: [SharedTemplateAPIModule], + imports: [SharedTemplateAPIModule, ApplicationsNotificationsModule], providers: [ReferenceTemplateService], exports: [ReferenceTemplateService], }) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/reference-template/reference-template.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/reference-template/reference-template.service.ts index 47e007af950b..c991907aaced 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/reference-template/reference-template.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/reference-template/reference-template.service.ts @@ -10,27 +10,47 @@ import { import { ApplicationTypes } from '@island.is/application/types' import { BaseTemplateApiService } from '../../base-template-api.service' import { TemplateApiError } from '@island.is/nest/problem' +import { NotificationsService } from '../../../notification/notifications.service' +import { NotificationType } from '../../../notification/notificationsTemplates' const TWO_HOURS_IN_SECONDS = 2 * 60 * 60 @Injectable() export class ReferenceTemplateService extends BaseTemplateApiService { constructor( private readonly sharedTemplateAPIService: SharedTemplateApiService, + private readonly notificationsService: NotificationsService, ) { super(ApplicationTypes.EXAMPLE) } - async getReferenceData({ application }: TemplateApiModuleActionProps) { + async getReferenceData({ application, auth }: TemplateApiModuleActionProps) { await new Promise((resolve) => setTimeout(resolve, 2000)) + const applicantName = getValueViaPath( + application.externalData, + 'nationalRegistry.data.fullName', + ) as string + + this.notificationsService.sendNotification({ + type: NotificationType.ChildrenResidenceChange, + messageParties: { + recipient: auth.nationalId, + sender: auth.nationalId, + }, + args: { + applicantName, + applicationId: application.id, + }, + }) + const name = getValueViaPath( application.externalData, - 'nationalRegistry.data.name', + 'nationalRegistry.data.fullName', ) as string return { referenceData: { - name, + applicantName, some: 'data', numbers: 123, }, diff --git a/libs/application/template-api-modules/src/lib/notification/notificationTypes.ts b/libs/application/template-api-modules/src/lib/notification/notificationTypes.ts new file mode 100644 index 000000000000..98f5ea1cc708 --- /dev/null +++ b/libs/application/template-api-modules/src/lib/notification/notificationTypes.ts @@ -0,0 +1,6 @@ +import { NotificationConfig, NotificationType } from './notificationsTemplates' + +export type NotificationConfigType = typeof NotificationConfig +export type NotificationTypeKey = keyof typeof NotificationConfig +export type NotificationArgs = + NotificationConfigType[T]['keys'] diff --git a/libs/application/template-api-modules/src/lib/notification/notifications.module.ts b/libs/application/template-api-modules/src/lib/notification/notifications.module.ts new file mode 100644 index 000000000000..7f65661987d2 --- /dev/null +++ b/libs/application/template-api-modules/src/lib/notification/notifications.module.ts @@ -0,0 +1,11 @@ +import { Module } from '@nestjs/common' + +import { UserNotificationClientModule } from '@island.is/clients/user-notification' +import { NotificationsService } from './notifications.service' + +@Module({ + imports: [UserNotificationClientModule], + providers: [NotificationsService], + exports: [NotificationsService], +}) +export class ApplicationsNotificationsModule {} diff --git a/libs/application/template-api-modules/src/lib/notification/notifications.service.ts b/libs/application/template-api-modules/src/lib/notification/notifications.service.ts new file mode 100644 index 000000000000..81bdc9c883b2 --- /dev/null +++ b/libs/application/template-api-modules/src/lib/notification/notifications.service.ts @@ -0,0 +1,71 @@ +import { NotificationsApi } from '@island.is/clients/user-notification' +import { Injectable } from '@nestjs/common' +import { NotificationArgs } from './notificationTypes' +import { NotificationConfig, NotificationType } from './notificationsTemplates' + +@Injectable() +export class NotificationsService { + constructor(private readonly notificationApi: NotificationsApi) {} + + /** + * Sends a notification using the specified type and arguments. + * + * @param data - The notification data object + * @param data.type - The type of notification (User, Order, or System) + * @param data.messageParties.recipient - The recipient nationalId of the notification + * @param data.messageParties.sender - Optional. The sender nationalId of the notification + * @param data.args - The arguments specific to the notification type + + * + * @example + * // Sending a User notification + * notificationsService.sendNotification({ + * type: NotificationType.User, + * messageParties: { + * recipient: 'user@example.com', + * }, + * args: { + * username: 'johndoe', + * email: 'johndoe@example.com' + * } + * }); + * + * @example + * // Sending an Order notification with a sender + * notificationsService.sendNotification({ + * type: NotificationType.Order, + * messageParties: { + * recipient: 'customer@example.com', + * }, + * args: { + * orderId: '12345', + * orderStatus: 'Shipped' + * }, + * sender: 'orders@company.com' + * }); + */ + public sendNotification(data: { + type: T + messageParties: { + recipient: string + sender?: string + } + args?: NotificationArgs + }) { + const templateId = NotificationConfig[data.type].templateId + + const notification = { + recipient: data.messageParties.recipient, + templateId, + senderId: data.messageParties.sender, + args: Object.entries(data.args ?? {}).map(([key, value]) => ({ + key, + value: String(value), + })), + } + + this.notificationApi.notificationsControllerCreateHnippNotification({ + createHnippNotificationDto: notification, + }) + } +} diff --git a/libs/application/template-api-modules/src/lib/notification/notificationsTemplates.ts b/libs/application/template-api-modules/src/lib/notification/notificationsTemplates.ts new file mode 100644 index 000000000000..a6d227495a3d --- /dev/null +++ b/libs/application/template-api-modules/src/lib/notification/notificationsTemplates.ts @@ -0,0 +1,45 @@ +export enum NotificationType { + System = 'SystemNotification', + ChildrenResidenceChange = 'ChildrenResidenceChangeNotification', + RejectedByCounterParty = 'RejectedByCounterPartyNotification', + RejectedByOrganization = 'RejectedByOrganizationNotification', + AssignCounterParty = 'AssignCounterPartyNotification', + ChildrenResidenceChangeApprovedByOrg = 'ChildrenResidenceChangeApprovedByOrgNotification', + ReferenceTemplate = 'ReferenceTemplateNotification', + ChildrenResidenceChangeAssignParent = 'ChildrenResidenceChangeV2AssignParentNotification', +} + +export const NotificationConfig = { + [NotificationType.System]: { + templateId: 'HNIPP.TEST.INBOX.TEMPLATE', + keys: {} as { documentId: string }, + }, + [NotificationType.ChildrenResidenceChange]: { + templateId: 'HNIPP.AS.CRC.ASSIGN.PARENT', + keys: {} as { applicantName: string; applicationId: string }, + }, + [NotificationType.RejectedByCounterParty]: { + templateId: 'HNIPP.AS.CRC.REJECTED.BY.COUNTERPARTY', + keys: {} as { counterPartyName: string }, + }, + [NotificationType.RejectedByOrganization]: { + templateId: 'HNIPP.AS.CRC.REJECTED.BY.ORGANIZATION', + keys: {} as { orgName: string }, + }, + [NotificationType.AssignCounterParty]: { + templateId: 'HNIPP.AS.CRC.ASSIGN.COUNTERPARTY', + keys: {} as { applicantName: string; contractLink: string }, + }, + [NotificationType.ChildrenResidenceChangeApprovedByOrg]: { + templateId: 'HNIPP.AS.CRC.APPROVED.BY.ORGANIZATION', + keys: {} as { applicationLink: string; caseNumber: string }, + }, + [NotificationType.ReferenceTemplate]: { + templateId: 'HNIPP.AS.REF.ASSIGN.PARENT', + keys: {} as { applicantName: string; applicationId: string }, + }, + [NotificationType.ChildrenResidenceChangeAssignParent]: { + templateId: 'HNIPP.AS.CRC.V2.ASSIGN.PARENT', + keys: {} as { applicantName: string; applicationId: string }, + }, +} diff --git a/libs/application/templates/reference-template/src/dataProviders/index.ts b/libs/application/templates/reference-template/src/dataProviders/index.ts index f0ece4e77c94..29a2b6528729 100644 --- a/libs/application/templates/reference-template/src/dataProviders/index.ts +++ b/libs/application/templates/reference-template/src/dataProviders/index.ts @@ -1,11 +1,16 @@ import { defineTemplateApi } from '@island.is/application/types' import { MockProviderApi } from '@island.is/application/types' +import { + NationalRegistryUserApi, + UserProfileApi, +} from '@island.is/application/types' export interface MyParameterType { id: number } export const ReferenceDataApi = defineTemplateApi({ action: 'getReferenceData', + order: 2, params: { id: 12, }, @@ -32,6 +37,10 @@ export const MyMockProvider = MockProviderApi.configure({ }, }) +export const NationalRegistryApi = NationalRegistryUserApi.configure({ + order: 1, +}) + export interface MyParameterType { id: number } diff --git a/libs/application/templates/reference-template/src/forms/Prerequisites.ts b/libs/application/templates/reference-template/src/forms/Prerequisites.ts index 272b78109a32..27de62ca28ef 100644 --- a/libs/application/templates/reference-template/src/forms/Prerequisites.ts +++ b/libs/application/templates/reference-template/src/forms/Prerequisites.ts @@ -11,11 +11,12 @@ import { import { Application, Form, FormModes } from '@island.is/application/types' import { m } from '../lib/messages' +import { UserProfileApi } from '@island.is/application/types' import { - NationalRegistryUserApi, - UserProfileApi, -} from '@island.is/application/types' -import { ReferenceDataApi, MyMockProvider } from '../dataProviders' + ReferenceDataApi, + MyMockProvider, + NationalRegistryApi, +} from '../dataProviders' export const Prerequisites: Form = buildForm({ id: 'PrerequisitesDraft', @@ -41,7 +42,7 @@ export const Prerequisites: Form = buildForm({ subTitle: 'Reference data', }), buildDataProviderItem({ - provider: NationalRegistryUserApi, + provider: NationalRegistryApi, title: 'Þjóðskrá', subTitle: 'Upplýsingar um þig í Þjóðskrá.', }), diff --git a/libs/application/templates/reference-template/src/lib/ReferenceApplicationTemplate.ts b/libs/application/templates/reference-template/src/lib/ReferenceApplicationTemplate.ts index 5d1758fc6e33..579378424e97 100644 --- a/libs/application/templates/reference-template/src/lib/ReferenceApplicationTemplate.ts +++ b/libs/application/templates/reference-template/src/lib/ReferenceApplicationTemplate.ts @@ -12,7 +12,6 @@ import { ApplicationStateSchema, Application, DefaultEvents, - NationalRegistryUserApi, UserProfileApi, defineTemplateApi, } from '@island.is/application/types' @@ -25,6 +24,7 @@ import { ReferenceDataApi, EphemeralApi, MyMockProvider, + NationalRegistryApi, } from '../dataProviders' import { ExampleSchema } from './dataSchema' @@ -117,7 +117,7 @@ const ReferenceApplicationTemplate: ApplicationTemplate< id: 1986, }, }), - NationalRegistryUserApi.configure({ + NationalRegistryApi.configure({ params: { ageToValidate: 18, }, diff --git a/libs/clients/user-notification/src/lib/apiConfiguration.ts b/libs/clients/user-notification/src/lib/apiConfiguration.ts index 92329e55bc0d..c233d2df6e84 100644 --- a/libs/clients/user-notification/src/lib/apiConfiguration.ts +++ b/libs/clients/user-notification/src/lib/apiConfiguration.ts @@ -1,21 +1,27 @@ import { createEnhancedFetch } from '@island.is/clients/middlewares' import { ConfigType, LazyDuringDevScope } from '@island.is/nest/config' -import { Configuration, UserNotificationApi } from '../../gen/fetch' +import { + Configuration, + UserNotificationApi, + NotificationsApi, +} from '../../gen/fetch' import { UserNotificationClientConfig } from './userNotificationClient.config' -export const exportedApis = [UserNotificationApi].map((Api) => ({ - provide: Api, - scope: LazyDuringDevScope, - useFactory: (config: ConfigType) => - new Api( - new Configuration({ - fetchApi: createEnhancedFetch({ - name: 'clients-user-notification', - organizationSlug: 'stafraent-island', +export const exportedApis = [UserNotificationApi, NotificationsApi].map( + (Api) => ({ + provide: Api, + scope: LazyDuringDevScope, + useFactory: (config: ConfigType) => + new Api( + new Configuration({ + fetchApi: createEnhancedFetch({ + name: 'clients-user-notification', + organizationSlug: 'stafraent-island', + }), + basePath: `${config.basePath}`, }), - basePath: `${config.basePath}`, - }), - ), - inject: [UserNotificationClientConfig.KEY], -})) + ), + inject: [UserNotificationClientConfig.KEY], + }), +) diff --git a/libs/portals/admin/signature-collection/src/screens-parliamentary/Constituency/index.tsx b/libs/portals/admin/signature-collection/src/screens-parliamentary/Constituency/index.tsx index 0f5fd355a24b..7304c109ed0a 100644 --- a/libs/portals/admin/signature-collection/src/screens-parliamentary/Constituency/index.tsx +++ b/libs/portals/admin/signature-collection/src/screens-parliamentary/Constituency/index.tsx @@ -142,18 +142,22 @@ export const Constituency = ({ maxProgress: list.area.min, withLabel: true, }} - cta={{ - label: formatMessage(m.viewList), - variant: 'text', - onClick: () => { - navigate( - SignatureCollectionPaths.ParliamentaryConstituencyList.replace( - ':constituencyName', - constituencyName, - ).replace(':listId', list.id), - ) - }, - }} + cta={ + (allowedToProcess && !list.active) || !allowedToProcess + ? { + label: formatMessage(m.viewList), + variant: 'text', + onClick: () => { + navigate( + SignatureCollectionPaths.ParliamentaryConstituencyList.replace( + ':constituencyName', + constituencyName, + ).replace(':listId', list.id), + ) + }, + } + : undefined + } tag={ !list.reviewed ? {