-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy patherror-modal.tsx
More file actions
45 lines (40 loc) · 1.28 KB
/
error-modal.tsx
File metadata and controls
45 lines (40 loc) · 1.28 KB
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
import React, { useState } from "react";
interface ErrorModalProps {
message: string | null;
onClose: () => void;
}
const ErrorModal = ({ message, onClose = () => {} }: ErrorModalProps) => {
const [isVisible, setIsVisible] = useState(true);
if (!isVisible || !message) {
return null;
}
function onModalClose() {
setIsVisible(false);
onClose();
}
return (
// Backdrop overlay
<div
className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50 backdrop-blur-sm"
onClick={onModalClose} // Close when clicking outside the modal
>
{/* Modal content container */}
<div
className="relative m-auto flex w-full max-w-md flex-col rounded bg-white p-6 text-black"
onClick={(e) => e.stopPropagation()} // Prevent closing when clicking inside the modal
>
<h2 className="text-xl font-bold md:leading-loose">Error</h2>
<p className="leading-normal">{message}</p>
<div className="mt-8 inline-flex justify-end">
<button
className="text-grey-darkest flex-1 rounded bg-error px-4 py-2 text-white md:flex-none"
onClick={onModalClose}
>
Close
</button>
</div>
</div>
</div>
);
};
export default ErrorModal;