All files / src/utils/conditionals handleTaskTypeOptions.ts

0% Statements 0/13
0% Branches 0/11
0% Functions 0/4
0% Lines 0/13

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                                               
import { currentPlaybookSelector } from "../../store/features/playbook/playbookSlice.ts";
import { store } from "../../store/index.ts";
import { Step, Task } from "../../types/index.ts";
 
function handleTaskTypeOptions(step: Step | undefined): Task[] {
  const currentPlaybook = currentPlaybookSelector(store.getState());
  const tasks = currentPlaybook?.ui_requirement.tasks ?? [];
  const stepTasks: Task[] =
    step?.tasks
      ?.map((task: Task | string) => {
        const taskData: Task | undefined = tasks.find(
          (e) => e.id === (typeof task === "string" ? task : task.id),
        );
        Iif (Object.keys(taskData?.ui_requirement?.errors ?? {}).length > 0) {
          return undefined;
        }
        return taskData;
      })
      ?.filter((task: Task | undefined) => task !== undefined) ?? [];
  return stepTasks ?? [];
}
 
export default handleTaskTypeOptions;