in src/hooks/useStepsContext/useStepsContext.ts [166:187]
onDropStep: onDropStep(steps, setSteps),
onSplitStep: (stepIndex, actionIndex) => {
if (actionIndex === 0) {
throw Error(`Cannot remove all actions from a step.`);
}
if (steps.length <= stepIndex) {
throw Error('Step index cannot exceed steps length.');
}
const stepToSplit = steps[stepIndex];
if (stepToSplit.actions.length <= 1) {
throw Error('Cannot split step with only one action.');
}
const reducedStepActions = stepToSplit.actions.slice(0, actionIndex);
const insertedStepActions = stepToSplit.actions.slice(actionIndex);
setSteps([
...steps.slice(0, stepIndex),
{ name: stepToSplit.name, actions: reducedStepActions },
{ actions: insertedStepActions },
...steps.slice(stepIndex + 1, steps.length),
]);
},