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 | 1x 1x | import { PayloadAction } from "@reduxjs/toolkit";
import { PlaybookUIState } from "../../../../../types/index.ts";
import { PermanentDrawerTypes } from "../../../drawers/permanentDrawerTypes.ts";
export const deleteStep = (
state: PlaybookUIState,
{ payload }: PayloadAction<any>,
) => {
const id = payload;
Iif (id) {
const step = state.currentPlaybook!.steps.find((step) => step.id === id);
const stepIndex = state.currentPlaybook!.steps.findIndex(
(step) => step.id === id,
);
Iif (step) {
const taskIds = step.tasks.map((task) =>
typeof task === "string" ? task : task.id,
);
state.currentPlaybook!.steps.splice(stepIndex, 1);
taskIds.forEach((taskId) => {
const tasks = state.currentPlaybook!.ui_requirement.tasks;
const taskIndex = tasks.findIndex((e) => e.id === taskId);
tasks.splice(taskIndex, 1);
});
state.currentPlaybook!.step_relations =
state.currentPlaybook!.step_relations.filter((relation) => {
Iif (typeof relation.parent === "string") {
return (
relation.parent !== id &&
relation.child?.reference_id !== step?.reference_id
);
}
return (
relation.parent.reference_id !== step?.reference_id &&
relation.child?.reference_id !== step.reference_id
);
});
}
state.permanentView = PermanentDrawerTypes.DEFAULT;
}
};
|