All files / src/components/Playbooks/create/nodes TaskNode.tsx

0% Statements 0/26
0% Branches 0/5
0% Functions 0/3
0% Lines 0/26

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 49 50 51 52 53 54 55 56 57 58                                                                                                                   
import TaskTitle from "../../card/TaskTitle.tsx";
import handleTaskBorderColor from "../../../../utils/playbook/handleTaskBorderColor.ts";
import TaskInformation from "../../card/TaskInformation.tsx";
import {
  playbookSelector,
  setCurrentVisibleTask,
} from "../../../../store/features/playbook/playbookSlice.ts";
import { PermanentDrawerTypes } from "../../../../store/features/drawers/permanentDrawerTypes.ts";
import { useDispatch, useSelector } from "react-redux";
import useCurrentTask from "../../../../hooks/playbooks/task/useCurrentTask.ts";
import usePermanentDrawerState from "../../../../hooks/common/usePermanentDrawerState.ts";
 
const taskDetailsId = PermanentDrawerTypes.TASK_DETAILS;
 
function TaskNode({ taskId }) {
  const [task] = useCurrentTask(taskId);
  const dispatch = useDispatch();
  const { toggle, openDrawer, permanentView, addAdditionalData } =
    usePermanentDrawerState();
  const { currentVisibleTask } = useSelector(playbookSelector);
 
  const handleNoAction = (e) => {
    e.preventDefault();
    e.stopPropagation();
  };
 
  const handleClick = (e) => {
    handleNoAction(e);
    Iif (permanentView === taskDetailsId && currentVisibleTask === taskId) {
      toggle(taskDetailsId);
      return;
    }
    addAdditionalData({});
    dispatch(setCurrentVisibleTask(taskId));
    openDrawer(taskDetailsId);
  };
 
  return (
    <>
      <div
        onClick={handleClick}
        className={`${
          currentVisibleTask === taskId ? "border-violet-500 border-2" : ""
        } rounded-md overflow-hidden border-2 border-transparent`}
        style={{ borderColor: handleTaskBorderColor(taskId) }}>
        <div className="">
          <TaskTitle taskId={task?.id} />
        </div>
        <div className="">
          <TaskInformation taskId={task?.id} />
        </div>
      </div>
    </>
  );
}
 
export default TaskNode;