From 45197280d4270240ad03b40dedc1edbfa47a64b4 Mon Sep 17 00:00:00 2001 From: suryac Date: Wed, 8 Jul 2026 19:27:03 +0530 Subject: [PATCH] fix:chain activity for dynamic form loading --- src/App.tsx | 17 +++++++++-------- src/components/forms/DynamicForm.tsx | 18 ++++++++++++++++-- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index f7b760a..bf3ee6a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -14,17 +14,18 @@ function App() { } /> }> - } /> - } /> + } /> + } /> - } /> - } /> + } /> + } /> - } /> - } /> + } /> + } /> - } /> - } /> + } /> + } /> + } /> diff --git a/src/components/forms/DynamicForm.tsx b/src/components/forms/DynamicForm.tsx index 314824e..d8624e7 100644 --- a/src/components/forms/DynamicForm.tsx +++ b/src/components/forms/DynamicForm.tsx @@ -17,6 +17,7 @@ import { WfLookupField, RadioField, } from './fields'; +import { ORDER_BOOKING } from '../../api/config'; export interface DynamicFormProps { client: ZinoClient; @@ -172,8 +173,21 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: } let pending = [...chainQueue]; - const newActivities = (schema.activity_chain || []).filter( - a => a.activity_uid !== currentActivityId + let chainSource = (res as any).activity_chain || schema.activity_chain || []; + + // Centralized activity chaining logic + if (currentActivityId === ORDER_BOOKING.activities.PRODUCTIVITY_OF_VISIT.uid) { + const actionValue = String(payload[ORDER_BOOKING.activities.PRODUCTIVITY_OF_VISIT.fields.action] || '').toLowerCase().trim(); + const normalized = actionValue.replace(/[\s_]+/g, ''); + if (normalized === 'order') { + chainSource = [{ activity_uid: ORDER_BOOKING.activities.PLACE_ORDER.uid, activity_name: 'Place Order' }]; + } else if (normalized === 'noorder') { + chainSource = [{ activity_uid: ORDER_BOOKING.activities.POTENTIAL_MINING.uid, activity_name: 'Potential Mining' }]; + } + } + + const newActivities = chainSource.filter( + (a: any) => a.activity_uid !== currentActivityId ); // Remove any existing occurrences from pending to avoid duplicates