@opencrvs/toolkit 2.0.0-rc.6f16968 → 2.0.0-rc.6f77a66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,8 @@
1
+ import { Action, RequestedCorrectionAction } from '../ActionDocument';
1
2
  import { Flag, CustomFlag } from '../Flag';
2
3
  import { EventConfig } from '../EventConfig';
3
4
  import { EventDocument } from '../EventDocument';
5
+ export declare function findPendingCorrectionAction(writeActions: Action[]): RequestedCorrectionAction | undefined;
4
6
  /**
5
7
  * This function resolves custom flags for an event based on its actions.
6
8
  * Flags are not stored to the event state or any database directly, instead they are always computed/evaluated from the event actions.
@@ -6388,19 +6388,22 @@ var import_date_fns3 = require("date-fns");
6388
6388
  function isEditInProgress(actions) {
6389
6389
  return actions.at(-1)?.type === ActionType.EDIT;
6390
6390
  }
6391
- function isCorrectionRequested(actions) {
6392
- return actions.reduce((prev, { type }) => {
6393
- if (type === ActionType.REQUEST_CORRECTION) {
6394
- return true;
6395
- }
6396
- if (type === ActionType.APPROVE_CORRECTION) {
6397
- return false;
6391
+ function findPendingCorrectionAction(writeActions2) {
6392
+ let correctionRequestAction;
6393
+ for (let i = writeActions2.length - 1; i >= 0; i--) {
6394
+ const action = writeActions2[i];
6395
+ if (action.type === ActionType.APPROVE_CORRECTION || action.type === ActionType.REJECT_CORRECTION) {
6396
+ break;
6398
6397
  }
6399
- if (type === ActionType.REJECT_CORRECTION) {
6400
- return false;
6398
+ if (action.type === ActionType.REQUEST_CORRECTION && action.status === ActionStatus.Accepted) {
6399
+ correctionRequestAction = action;
6400
+ break;
6401
6401
  }
6402
- return prev;
6403
- }, false);
6402
+ }
6403
+ return correctionRequestAction;
6404
+ }
6405
+ function isCorrectionRequested(actions) {
6406
+ return findPendingCorrectionAction(actions) !== void 0;
6404
6407
  }
6405
6408
  function isDeclarationIncomplete(actions) {
6406
6409
  return getStatusFromActions(actions) === EventStatus.enum.NOTIFIED;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/toolkit",
3
- "version": "2.0.0-rc.6f16968",
3
+ "version": "2.0.0-rc.6f77a66",
4
4
  "description": "OpenCRVS toolkit for building country configurations",
5
5
  "license": "MPL-2.0",
6
6
  "bin": {