All files / src/components/AddStepCondition index.tsx

0% Statements 0/14
0% Branches 0/3
0% Functions 0/2
0% Lines 0/14

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                                                                             
import { useSelector } from "react-redux";
import { additionalStateSelector } from "../../store/features/drawers/drawersSlice.ts";
import CustomButton from "../common/CustomButton/index.tsx";
import { Add, InfoOutlined } from "@mui/icons-material";
import useEdgeConditions from "../../hooks/playbooks/useEdgeConditions.ts";
import useIsPrefetched from "../../hooks/playbooks/useIsPrefetched.ts";
import StepConditions from "./StepConditions.tsx";
import { Tooltip } from "@mui/material";
 
function AddStepCondition() {
  const { id } = useSelector(additionalStateSelector);
  const { addNewStepRule, step_rules } = useEdgeConditions(id);
  const isPrefetched = useIsPrefetched();
 
  return (
    <div className="flex flex-wrap items-center gap-2 my-4">
      {step_rules?.map((rule, i) => (
        <StepConditions rule={rule} ruleIndex={i} />
      ))}
 
      {!isPrefetched && step_rules.length === 0 && (
        <>
          <CustomButton className="!w-fit my-2" onClick={addNewStepRule}>
            <Add fontSize="inherit" /> Add time condition
          </CustomButton>
        </>
      )}
      <Tooltip title="Add a time condition to step execution">
        <InfoOutlined
          fontSize="small"
          className="text-violet-500 cursor-pointer"
        />
      </Tooltip>
    </div>
  );
}
 
export default AddStepCondition;