recipe_app/frontend/src/components/Modal.tsx

27 lines
992 B
TypeScript

interface ModalProps {
isOpen: boolean;
onClose: () => void;
message: string;
confirmAction: () => void;
cancelAction: () => void;
}
const Modal = ({ isOpen, onClose, message, confirmAction, cancelAction }: ModalProps) => {
if (!isOpen) return null;
return (
<div className="modal-overlay fixed top-0 left-0 w-full h-full bg-black bg-opacity-50 flex justify-center items-center" onClick={onClose}>
<div className="modal-content bg-amber-200 p-12 rounded-md shadow-md" onClick={(e) => e.stopPropagation()}>
<div className="modal-msg">
<span aria-labelledby="message">{message}</span>
</div>
<div className="modal-buttons">
<button className="bg-amber-600 rounded-md m-4 pt-1 pb-1 pr-2 pl-2" onClick={confirmAction}>Yes, Delete</button>
<button className="bg-amber-600 rounded-md m-4 pt-1 pb-1 pr-2 pl-2" onClick={cancelAction}>Cancel</button>
</div>
</div>
</div>
);
};
export default Modal;