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 | import { useDispatch, useSelector } from "react-redux"; import { playbookSelector, popFromExecutionStack, } from "../../store/features/playbook/playbookSlice.ts"; import { useGetPlaybookExecutionQuery } from "../../store/features/playbook/api/index.ts"; import { useEffect } from "react"; import { Step } from "../../types"; function useExecutionStack() { const { executionStack, executionId, currentPlaybook } = useSelector(playbookSelector); const steps = currentPlaybook?.ui_requirement.executedSteps ?? []; const playbookSteps = currentPlaybook?.steps; const dispatch = useDispatch(); const { refetch } = useGetPlaybookExecutionQuery(); const executingStep = (playbookSteps ?? []).find( (step: Step) => step.ui_requirement.outputLoading, ); const nextStep: Step | undefined = structuredClone( playbookSteps?.find( (e: Step) => e.id === executionStack[executionStack.length - 1], ), ); useEffect(() => { Iif (!executingStep?.ui_requirement.outputLoading && executionId) { refetch(); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [executingStep?.ui_requirement.outputLoading]); const pop = () => { dispatch(popFromExecutionStack()); }; return { executionStack, steps, nextStep, executingStep, pop, }; } export default useExecutionStack; |