Skip to content

Commit 1bb2593

Browse files
Bal 4462 (#3471)
* fix: fixed issue where edit status was updated to in progress (#3427) * fix: fixed checkbox styles in ui package (#3430) * Bal 4370 flaky plugin rerun during submission in edit (#3428) * fix: fixed issue where edit status was updated to in progress (#3427) * feat: reworked final submission & added plugins output cleanup * fix: fixed types * refactor(workflow.service): enhance final state detection logic * refactor(workflow.service): enhance final state detection logic --------- Co-authored-by: Illia Rudniev <[email protected]>
1 parent 4b8d1a2 commit 1bb2593

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

apps/kyb-app/src/pages/CollectionFlow/versions/v2/CollectionFlowV2.tsx

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,31 +61,21 @@ export const CollectionFlowV2 = withSessionProtected(() => {
6161
setLogoLoaded(false);
6262
}, [customer?.logoImageUri]);
6363

64-
if (
65-
getCollectionFlowState(collectionFlowData?.context)?.status ===
66-
CollectionFlowStatusesEnum.approved
67-
) {
64+
const collectionFlowState = getCollectionFlowState(collectionFlowData?.context)?.status;
65+
66+
if (collectionFlowState === CollectionFlowStatusesEnum.approved) {
6867
return <Approved />;
6968
}
7069

71-
if (
72-
getCollectionFlowState(collectionFlowData?.context)?.status ===
73-
CollectionFlowStatusesEnum.rejected
74-
) {
70+
if (collectionFlowState === CollectionFlowStatusesEnum.rejected) {
7571
return <Rejected />;
7672
}
7773

78-
if (
79-
getCollectionFlowState(collectionFlowData?.context)?.status ===
80-
CollectionFlowStatusesEnum.completed
81-
) {
74+
if (collectionFlowState === CollectionFlowStatusesEnum.completed) {
8275
return <CompletedScreen redirectUrl={successRedirectUrl} />;
8376
}
8477

85-
if (
86-
getCollectionFlowState(collectionFlowData?.context)?.status ===
87-
CollectionFlowStatusesEnum.failed
88-
) {
78+
if (collectionFlowState === CollectionFlowStatusesEnum.failed) {
8979
return <FailedScreen redirectUrl={failureRedirectUrl} />;
9080
}
9181

services/workflows-service/src/workflow/workflow.service.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ import {
6363
isType,
6464
ProcessStatus,
6565
setCollectionFlowStatus,
66+
StateTag,
67+
TStateTag,
6668
TWorkflowHelpers,
6769
} from '@ballerine/common';
6870
import {
@@ -1389,10 +1391,20 @@ export class WorkflowService {
13891391
// assign runtime to user, copy the context.
13901392
const currentState = data.state;
13911393

1394+
const finalStateTags: TStateTag[] = [StateTag.APPROVED, StateTag.REJECTED];
1395+
13921396
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
13931397
// @ts-ignore
1394-
// TODO: Use snapshot.done instead
1395-
const isFinal = workflowDef.definition?.states?.[currentState]?.type === 'final';
1398+
const stateHasFinalStateTags = workflowDef.definition?.states?.[currentState]?.tags?.some(
1399+
(tag: TStateTag) => finalStateTags.includes(tag),
1400+
);
1401+
1402+
const isFinal =
1403+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1404+
// @ts-ignore
1405+
// TODO: Use snapshot.done instead
1406+
workflowDef.definition?.states?.[currentState]?.type === 'final' || stateHasFinalStateTags;
1407+
13961408
const isResolved = isFinal || data.status === WorkflowRuntimeDataStatus.completed;
13971409

13981410
const customer = await this.customerService.getByProjectId(projectId);

0 commit comments

Comments
 (0)