Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | 1x 1x 1x 1x 1x | import { PayloadAction } from "@reduxjs/toolkit";
import {
LogicalOperator,
PlaybookUIState,
Step,
} from "../../../../../types/index.ts";
import generateUUIDWithoutHyphens from "../../../../../utils/common/generateUUIDWithoutHyphens.ts";
import { v4 as uuidv4 } from "uuid";
const emptyStep: Step = {
id: "",
tasks: [],
ui_requirement: {
isOpen: true,
showError: false,
},
};
export const addStep = (
state: PlaybookUIState,
{ payload }: PayloadAction<any>,
) => {
const { parentId, id, addCondition } = payload;
const stepId = id ?? generateUUIDWithoutHyphens();
const newStep: Step = {
...emptyStep,
id: stepId,
reference_id: uuidv4(),
description: `Step`,
tasks: [],
};
state.currentPlaybook?.steps.push(newStep);
const parentStep = state.currentPlaybook?.steps.find(
(step) => step.id === parentId,
);
Iif (
state.currentPlaybook &&
(!state.currentPlaybook?.step_relations ||
state.currentPlaybook?.step_relations?.length === 0)
) {
state.currentPlaybook.step_relations = [];
}
state.currentPlaybook?.step_relations?.push({
id: `edge-${parentId}-${stepId}`,
parent: parentStep!,
child: newStep,
condition: addCondition
? {
logical_operator: LogicalOperator.AND_LO,
rule_sets: [
{
rules: [],
logical_operator: LogicalOperator.AND_LO,
},
],
}
: undefined,
});
};
|