All files / src/components/DynamicAlerts/Table ActionOverlay.tsx

0% Statements 0/13
0% Branches 0/2
0% Functions 0/2
0% Lines 0/12

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                                                               
import { useDeleteWorkflowMutation } from "../../../store/features/workflow/api";
import Overlay from "../../Overlay";
import CustomButton from "../../common/CustomButton";
 
function ActionOverlay({ isOpen, toggleOverlay, item }) {
  const [deleteDynamicAlert] = useDeleteWorkflowMutation();
 
  const handleSuccess = async () => {
    const response = await deleteDynamicAlert(item.id).unwrap();
    Iif (response.success) {
      toggleOverlay();
      window.location.reload();
    }
  };
 
  Iif (!isOpen) return;
 
  return (
    <Overlay close={toggleOverlay} visible={isOpen}>
      <div className="bg-white rounded-md p-4 w-[384px]">
        <header className="text-gray-500">Delete alert "{item.name}"?</header>
        <div className="flex items-center gap-2 mt-4">
          <CustomButton onClick={toggleOverlay}>Cancel</CustomButton>
          <CustomButton onClick={handleSuccess}>Yes</CustomButton>
        </div>
      </div>
    </Overlay>
  );
}
 
export default ActionOverlay;