All files / components/Common ConfirmationModal.jsx

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

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                  10x 3x   10x                                               2x 2x                    
import Modal from "react-bootstrap/Modal";
import { Button } from "react-bootstrap";
 
export default function ConfirmationModal({
  children,
  showModal,
  setShowModal,
  onYes,
}) {
  const closeModal = () => {
    setShowModal(false);
  };
  return (
    <Modal
      show={showModal}
      onHide={closeModal}
      centered={true}
      data-testid={"ConfirmationModal-base"}
    >
      <Modal.Header>
        <Modal.Title>Are You Sure?</Modal.Title>
        <Button
          className="btn-close"
          data-testid={"ConfirmationModal-closeButton"}
          onClick={closeModal}
        ></Button>
      </Modal.Header>
      <Modal.Body>{children}</Modal.Body>
      <Modal.Footer>
        <Button type="button" onClick={closeModal}>
          No, take me back
        </Button>
        <Button
          type="button"
          className="ms-auto"
          onClick={() => {
            onYes();
            closeModal();
          }}
          variant={"danger"}
        >
          Yes, I&apos;d like to do this
        </Button>
      </Modal.Footer>
    </Modal>
  );
}