@@ -63,7 +63,12 @@ import {
6363 onAnyActionHandler
6464} from '@countryconfig/api/custom-event/handler'
6565import { readFileSync } from 'fs'
66- import { ActionType , EventDocument } from '@opencrvs/toolkit/events'
66+ import {
67+ ActionDocument ,
68+ ActionStatus ,
69+ ActionType ,
70+ EventDocument
71+ } from '@opencrvs/toolkit/events'
6772import { Event } from './form/types/types'
6873import { onRegisterHandler } from './api/registration'
6974import { workqueueconfigHandler } from './api/workqueue/handler'
@@ -279,6 +284,7 @@ export async function createServer() {
279284 server . route ( {
280285 method : 'GET' ,
281286 path : '/ping' ,
287+ // eslint-disable-next-line no-unused-vars
282288 handler : ( request : any , h : any ) => {
283289 // Perform any health checks and return true or false for success prop
284290 return {
@@ -704,10 +710,20 @@ export async function createServer() {
704710
705711 if ( wasRequestForActionConfirmation && wasActionAcceptedImmediately ) {
706712 const event = request . payload as EventDocument
713+
714+ const eventWithOptimisticallyApprovedLastAction = {
715+ ...event ,
716+ actions : event . actions . map ( ( action , index ) =>
717+ index === event . actions . length - 1
718+ ? { ...action , status : ActionStatus . Accepted }
719+ : action
720+ ) as ActionDocument [ ]
721+ }
722+
707723 const client = getClient ( )
708724 try {
709725 await client . transaction ( ) . execute ( async ( trx ) => {
710- await importEvent ( event , trx )
726+ await importEvent ( eventWithOptimisticallyApprovedLastAction , trx )
711727 } )
712728 } catch ( error ) {
713729 // eslint-disable-next-line no-console
0 commit comments