diff --git a/apps/judicial-system/backend/src/app/modules/case/case.controller.ts b/apps/judicial-system/backend/src/app/modules/case/case.controller.ts index 954025e9b815..cca384ac525a 100644 --- a/apps/judicial-system/backend/src/app/modules/case/case.controller.ts +++ b/apps/judicial-system/backend/src/app/modules/case/case.controller.ts @@ -150,7 +150,7 @@ export class CaseController { const createdCase = await this.caseService.create(caseToCreate, user) - this.eventService.postEvent(CaseEvent.CREATE, createdCase as Case) + this.eventService.postEvent('CREATE', createdCase) return createdCase } @@ -419,10 +419,7 @@ export class CaseController { ) // No need to wait - this.eventService.postEvent( - transition.transition as unknown as CaseEvent, - updatedCase ?? theCase, - ) + this.eventService.postEvent(transition.transition, updatedCase ?? theCase) return updatedCase ?? theCase } @@ -891,7 +888,7 @@ export class CaseController { const extendedCase = await this.caseService.extend(theCase, user) - this.eventService.postEvent(CaseEvent.EXTEND, extendedCase as Case) + this.eventService.postEvent('EXTEND', extendedCase as Case) return extendedCase } diff --git a/apps/judicial-system/backend/src/app/modules/case/case.service.ts b/apps/judicial-system/backend/src/app/modules/case/case.service.ts index faaa1375015f..65a7daca3a84 100644 --- a/apps/judicial-system/backend/src/app/modules/case/case.service.ts +++ b/apps/judicial-system/backend/src/app/modules/case/case.service.ts @@ -1671,7 +1671,7 @@ export class CaseService { await this.addMessagesForUpdatedCaseToQueue(theCase, updatedCase, user) if (receivingCase) { - this.eventService.postEvent(CaseEvent.RECEIVE, updatedCase) + this.eventService.postEvent(CaseTransition.RECEIVE, updatedCase) } if (returnUpdatedCase) { diff --git a/apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts b/apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts index 0f49489d0179..9149585ce497 100644 --- a/apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts +++ b/apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts @@ -54,7 +54,7 @@ export class InternalCaseController { const createdCase = await this.internalCaseService.create(caseToCreate) - this.eventService.postEvent(CaseEvent.CREATE_XRD, createdCase as Case) + this.eventService.postEvent('CREATE_XRD', createdCase as Case) return createdCase } diff --git a/apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts b/apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts index 1947fce47527..ebee2422a741 100644 --- a/apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts +++ b/apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts @@ -511,7 +511,7 @@ export class InternalCaseService { ) }) - this.eventService.postEvent(CaseEvent.ARCHIVE, theCase) + this.eventService.postEvent('ARCHIVE', theCase) return { caseArchived: true } } diff --git a/apps/judicial-system/backend/src/app/modules/case/limitedAccessCase.controller.ts b/apps/judicial-system/backend/src/app/modules/case/limitedAccessCase.controller.ts index aee8f67f1e40..7e17c55bab85 100644 --- a/apps/judicial-system/backend/src/app/modules/case/limitedAccessCase.controller.ts +++ b/apps/judicial-system/backend/src/app/modules/case/limitedAccessCase.controller.ts @@ -182,10 +182,7 @@ export class LimitedAccessCaseController { user, ) - this.eventService.postEvent( - transition.transition as unknown as CaseEvent, - updatedCase, - ) + this.eventService.postEvent(transition.transition, updatedCase) return updatedCase } diff --git a/apps/judicial-system/backend/src/app/modules/event/event.service.ts b/apps/judicial-system/backend/src/app/modules/event/event.service.ts index ce212f4a386e..e66825a614af 100644 --- a/apps/judicial-system/backend/src/app/modules/event/event.service.ts +++ b/apps/judicial-system/backend/src/app/modules/event/event.service.ts @@ -12,7 +12,10 @@ import { formatDate, readableIndictmentSubtypes, } from '@island.is/judicial-system/formatters' -import { isIndictmentCase } from '@island.is/judicial-system/types' +import { + CaseTransition, + isIndictmentCase, +} from '@island.is/judicial-system/types' import { type Case } from '../case' import { DateLog } from '../case/models/dateLog.model' @@ -37,50 +40,42 @@ const errorEmojis = [ ':x:', ] -const caseEvent = { +const caseEvent: Record = { + [CaseTransition.ACCEPT]: ':white_check_mark: Samþykkt', + [CaseTransition.APPEAL]: ':judge: Kæra', + ARCHIVE: ':file_cabinet: Sett í geymslu', + [CaseTransition.ASK_FOR_CANCELLATION]: ':interrobang: Beðið um aftuköllun', + [CaseTransition.ASK_FOR_CONFIRMATION]: ':question: Beðið um staðfestingu', + [CaseTransition.COMPLETE]: ':white_check_mark: Lokið', + [CaseTransition.COMPLETE_APPEAL]: ':white_check_mark: Kæru lokið', + [CaseTransition.DELETE]: ':fire: Afturkallað', + [CaseTransition.DENY_INDICTMENT]: ':no_entry_sign: Ákæru hafnað', + [CaseTransition.DISMISS]: ':woman-shrugging: Vísað frá', CREATE: ':new: Mál stofnað', CREATE_XRD: ':new: Mál stofnað í gegnum Strauminn', EXTEND: ':recycle: Mál framlengt', - OPEN: ':unlock: Opnað fyrir dómstól', - ASK_FOR_CONFIRMATION: ':question: Beðið um staðfestingu', - SUBMIT: ':mailbox_with_mail: Sent', + [CaseTransition.OPEN]: ':unlock: Opnað fyrir dómstól', + [CaseTransition.RECEIVE]: ':eyes: Móttekið', + [CaseTransition.RECEIVE_APPEAL]: ':eyes: Kæra móttekin', + [CaseTransition.REJECT]: ':negative_squared_cross_mark: Hafnað', + [CaseTransition.REOPEN]: ':construction: Opnað aftur', + [CaseTransition.REOPEN_APPEAL]: ':building_construction: Kæra opnuð aftur', RESUBMIT: ':mailbox_with_mail: Sent aftur', - RECEIVE: ':eyes: Móttekið', - ACCEPT: ':white_check_mark: Samþykkt', - REJECT: ':negative_squared_cross_mark: Hafnað', - DISMISS: ':woman-shrugging: Vísað frá', - COMPLETE: ':white_check_mark: Lokið', - DELETE: ':fire: Afturkallað', + [CaseTransition.RETURN_INDICTMENT]: ':woman-gesturing-no: Ákæru afturkallað', SCHEDULE_COURT_DATE: ':timer_clock: Fyrirtökutíma úthlutað', - ARCHIVE: ':file_cabinet: Sett í geymslu', - REOPEN: ':construction: Opnað aftur', - APPEAL: ':judge: Kæra', - RECEIVE_APPEAL: ':eyes: Kæra móttekin', - COMPLETE_APPEAL: ':white_check_mark: Kæru lokið', - REOPEN_APPEAL: ':building_construction: Kæra opnuð aftur', + [CaseTransition.SUBMIT]: ':mailbox_with_mail: Sent', + [CaseTransition.WITHDRAW_APPEAL]: + ':leftwards_arrow_with_hook: Kæru afturkallað', } -export enum CaseEvent { - CREATE = 'CREATE', - CREATE_XRD = 'CREATE_XRD', - EXTEND = 'EXTEND', - OPEN = 'OPEN', - ASK_FOR_CONFIRMATION = 'ASK_FOR_CONFIRMATION', - SUBMIT = 'SUBMIT', - RESUBMIT = 'RESUBMIT', - RECEIVE = 'RECEIVE', - ACCEPT = 'ACCEPT', - REJECT = 'REJECT', - DELETE = 'DELETE', - SCHEDULE_COURT_DATE = 'SCHEDULE_COURT_DATE', - DISMISS = 'DISMISS', - ARCHIVE = 'ARCHIVE', - REOPEN = 'REOPEN', - APPEAL = 'APPEAL', - RECEIVE_APPEAL = 'RECEIVE_APPEAL', - COMPLETE_APPEAL = 'COMPLETE_APPEAL', - REOPEN_APPEAL = 'REOPEN_APPEAL', -} +export type CaseEvent = + | CaseTransition + | 'ARCHIVE' + | 'CREATE' + | 'CREATE_XRD' + | 'EXTEND' + | 'RESUBMIT' + | 'SCHEDULE_COURT_DATE' @Injectable() export class EventService { @@ -120,7 +115,7 @@ export class EventService { ? `\n>Landsréttur *${theCase.appealCaseNumber}*` : '' const extraText = - event === CaseEvent.SCHEDULE_COURT_DATE + event === 'SCHEDULE_COURT_DATE' ? `\n>Dómari ${ theCase.judge?.name ?? 'er ekki skráður' }\n>Dómritari ${ diff --git a/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts b/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts index 4e8bccbaf4af..2c6aa5278d6d 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts @@ -416,7 +416,7 @@ export class InternalNotificationService extends BaseNotificationService { } else if (theCase.state === CaseState.RECEIVED) { promises.push(this.sendResubmittedToCourtSmsNotificationToCourt(theCase)) - this.eventService.postEvent(CaseEvent.RESUBMIT, theCase) + this.eventService.postEvent('RESUBMIT', theCase) } if ( @@ -768,7 +768,7 @@ export class InternalNotificationService extends BaseNotificationService { theCase: Case, user: User, ): Promise { - this.eventService.postEvent(CaseEvent.SCHEDULE_COURT_DATE, theCase) + this.eventService.postEvent('SCHEDULE_COURT_DATE', theCase) const promises: Promise[] = [] 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 a93d21be152f..8a9e78671c95 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 @@ -56,11 +56,7 @@ export class NotificationService { break case NotificationType.COURT_DATE: if (eventOnly) { - this.eventService.postEvent( - CaseEvent.SCHEDULE_COURT_DATE, - theCase, - true, - ) + this.eventService.postEvent('SCHEDULE_COURT_DATE', theCase, true) // We still want to send the defender a link to the case even if // the judge chooses not to send a calendar invitation diff --git a/libs/judicial-system/types/src/lib/case.ts b/libs/judicial-system/types/src/lib/case.ts index d7bf2d87385a..ff5dd9085aaf 100644 --- a/libs/judicial-system/types/src/lib/case.ts +++ b/libs/judicial-system/types/src/lib/case.ts @@ -132,50 +132,50 @@ export enum CaseAppealState { } export enum CaseTransition { - OPEN = 'OPEN', + ACCEPT = 'ACCEPT', + APPEAL = 'APPEAL', + ASK_FOR_CANCELLATION = 'ASK_FOR_CANCELLATION', ASK_FOR_CONFIRMATION = 'ASK_FOR_CONFIRMATION', + COMPLETE = 'COMPLETE', + COMPLETE_APPEAL = 'COMPLETE_APPEAL', + DELETE = 'DELETE', DENY_INDICTMENT = 'DENY_INDICTMENT', - SUBMIT = 'SUBMIT', - ASK_FOR_CANCELLATION = 'ASK_FOR_CANCELLATION', + DISMISS = 'DISMISS', + OPEN = 'OPEN', RECEIVE = 'RECEIVE', - RETURN_INDICTMENT = 'RETURN_INDICTMENT', - COMPLETE = 'COMPLETE', - ACCEPT = 'ACCEPT', + RECEIVE_APPEAL = 'RECEIVE_APPEAL', REJECT = 'REJECT', - DISMISS = 'DISMISS', - DELETE = 'DELETE', REOPEN = 'REOPEN', - APPEAL = 'APPEAL', - RECEIVE_APPEAL = 'RECEIVE_APPEAL', - COMPLETE_APPEAL = 'COMPLETE_APPEAL', REOPEN_APPEAL = 'REOPEN_APPEAL', + RETURN_INDICTMENT = 'RETURN_INDICTMENT', + SUBMIT = 'SUBMIT', WITHDRAW_APPEAL = 'WITHDRAW_APPEAL', } export enum IndictmentCaseTransition { + ASK_FOR_CANCELLATION = CaseTransition.ASK_FOR_CANCELLATION, ASK_FOR_CONFIRMATION = CaseTransition.ASK_FOR_CONFIRMATION, + COMPLETE = CaseTransition.COMPLETE, + DELETE = CaseTransition.DELETE, DENY_INDICTMENT = CaseTransition.DENY_INDICTMENT, - SUBMIT = CaseTransition.SUBMIT, - ASK_FOR_CANCELLATION = CaseTransition.ASK_FOR_CANCELLATION, RECEIVE = CaseTransition.RECEIVE, RETURN_INDICTMENT = CaseTransition.RETURN_INDICTMENT, - COMPLETE = CaseTransition.COMPLETE, - DELETE = CaseTransition.DELETE, + SUBMIT = CaseTransition.SUBMIT, } export enum RequestCaseTransition { + ACCEPT = CaseTransition.ACCEPT, + APPEAL = CaseTransition.APPEAL, + COMPLETE_APPEAL = CaseTransition.COMPLETE_APPEAL, + DELETE = CaseTransition.DELETE, + DISMISS = CaseTransition.DISMISS, OPEN = CaseTransition.OPEN, - SUBMIT = CaseTransition.SUBMIT, RECEIVE = CaseTransition.RECEIVE, - ACCEPT = CaseTransition.ACCEPT, + RECEIVE_APPEAL = CaseTransition.RECEIVE_APPEAL, REJECT = CaseTransition.REJECT, - DISMISS = CaseTransition.DISMISS, - DELETE = CaseTransition.DELETE, REOPEN = CaseTransition.REOPEN, - APPEAL = CaseTransition.APPEAL, - RECEIVE_APPEAL = CaseTransition.RECEIVE_APPEAL, - COMPLETE_APPEAL = CaseTransition.COMPLETE_APPEAL, REOPEN_APPEAL = CaseTransition.REOPEN_APPEAL, + SUBMIT = CaseTransition.SUBMIT, WITHDRAW_APPEAL = CaseTransition.WITHDRAW_APPEAL, }