From 908633b336e9ec6bbba5daa403cfb9063ed5fde8 Mon Sep 17 00:00:00 2001 From: mdshamoon Date: Fri, 16 Apr 2021 17:48:22 +0530 Subject: [PATCH 1/2] delay node updated --- src/components/flow/routers/helpers.ts | 5 ++- .../flow/routers/sequence/SequenceForm.tsx | 10 ++--- .../flow/routers/sequence/helpers.ts | 43 +++++++++++++++---- 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/src/components/flow/routers/helpers.ts b/src/components/flow/routers/helpers.ts index 1667a099b..a17c44d2c 100644 --- a/src/components/flow/routers/helpers.ts +++ b/src/components/flow/routers/helpers.ts @@ -16,7 +16,8 @@ import { UIConfig, WebhookExitNames, CallClassifier, - OpenTicket + OpenTicket, + Delay } from 'flowTypes'; import { RenderNode } from 'store/flowContext'; import { createUUID, snakify } from 'utils'; @@ -37,7 +38,7 @@ export const createRenderNode = ( router: Router, exits: Exit[], type: Types, - actions: Action[] = [], + actions: Action[] | Delay[] = [], uiConfig: { [key: string]: any } = {} ): RenderNode => { const renderNode: RenderNode = { diff --git a/src/components/flow/routers/sequence/SequenceForm.tsx b/src/components/flow/routers/sequence/SequenceForm.tsx index cc38f0bbf..9adf22359 100644 --- a/src/components/flow/routers/sequence/SequenceForm.tsx +++ b/src/components/flow/routers/sequence/SequenceForm.tsx @@ -1,8 +1,8 @@ import { react as bindCallbacks } from 'auto-bind'; import * as React from 'react'; import Dialog, { ButtonSet } from 'components/dialog/Dialog'; -import { ActionFormProps } from 'components/flow/props'; -import { actionToState, stateToAction } from 'components/flow/routers/sequence/helpers'; +import { RouterFormProps } from 'components/flow/props'; +import { actionToState, stateToNode } from 'components/flow/routers/sequence/helpers'; import TypeList from 'components/nodeeditor/TypeList'; import { FormState } from 'store/nodeEditor'; import i18n from 'config/i18n'; @@ -15,8 +15,8 @@ export interface SequenceFormState extends FormState { minutes: string; } -export default class SequenceForm extends React.Component { - constructor(props: ActionFormProps) { +export default class SequenceForm extends React.Component { + constructor(props: RouterFormProps) { super(props); this.state = actionToState(this.props.nodeSettings); @@ -30,7 +30,7 @@ export default class SequenceForm extends React.Component { let delayNode: SequenceFormState = { @@ -11,9 +14,10 @@ export const actionToState = (settings: NodeEditorSettings): SequenceFormState = hours: '0', minutes: '0' }; + + // console.log(settings); if (settings.originalAction && settings.originalAction.type === 'wait_for_time') { const action = settings.originalAction as Delay; - if (action.delay) { const delayInSeconds = parseInt(action.delay); delayNode.days = Math.floor(delayInSeconds / (3600 * 24)).toString(); @@ -25,16 +29,39 @@ export const actionToState = (settings: NodeEditorSettings): SequenceFormState = return delayNode; }; -export const stateToAction = (settings: NodeEditorSettings, state: SequenceFormState): any => { +export const stateToNode = (settings: NodeEditorSettings, state: SequenceFormState): any => { const { days, hours, minutes } = state; const delayInSeconds = parseInt(days) * 86400 + parseInt(hours) * 3600 + parseInt(minutes) * 60; + const { cases, exits, defaultCategory, caseConfig, categories } = resolveRoutes( + [], + false, + settings.originalNode.node, + 'Completed' + ); - const result = { - type: Types.wait_for_time, - uuid: getActionUUID(settings, Types.send_msg), - delay: delayInSeconds.toString() + const router: SwitchRouter = { + type: RouterTypes.switch, + default_category_uuid: defaultCategory, + cases, + categories, + operand: DEFAULT_OPERAND }; - return result; + const newRenderNode = createRenderNode( + settings.originalNode.node.uuid, + router, + exits, + Types.wait_for_time, + [ + { + type: Types.wait_for_time, + uuid: getActionUUID(settings, Types.send_msg), + delay: delayInSeconds.toString() + } + ], + { cases: caseConfig } + ); + + return newRenderNode; }; From ef697e9053132a97176dd16a367377c24ea3d901 Mon Sep 17 00:00:00 2001 From: mdshamoon Date: Fri, 16 Apr 2021 17:53:21 +0530 Subject: [PATCH 2/2] code cleanup --- src/components/flow/routers/sequence/helpers.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/flow/routers/sequence/helpers.ts b/src/components/flow/routers/sequence/helpers.ts index f398883f8..6d05b9c00 100644 --- a/src/components/flow/routers/sequence/helpers.ts +++ b/src/components/flow/routers/sequence/helpers.ts @@ -14,8 +14,6 @@ export const actionToState = (settings: NodeEditorSettings): SequenceFormState = hours: '0', minutes: '0' }; - - // console.log(settings); if (settings.originalAction && settings.originalAction.type === 'wait_for_time') { const action = settings.originalAction as Delay; if (action.delay) {