MCPcopy Create free account
hub / github.com/dhavalCode/ai-image-generator / ErrorModal

Function ErrorModal

client/src/components/ErrorModal.tsx:12–88  ·  view source on GitHub ↗
({ open, setIsOpen })

Source from the content-addressed store, hash-verified

10}
11
12const ErrorModal: React.FC<ErrorModalProps> = ({ open, setIsOpen }) => {
13 const modalRef = useRef<HTMLDivElement>(null)
14
15 useEffect(() => {
16 if (open) {
17 document.body.style.overflow = 'hidden'
18 document.addEventListener('click', handleClickOutside)
19 } else {
20 document.body.style.overflow = 'unset'
21 document.removeEventListener('click', handleClickOutside)
22 }
23
24 return () => {
25 document.body.style.overflow = 'unset'
26 document.removeEventListener('click', handleClickOutside)
27 }
28 // eslint-disable-next-line react-hooks/exhaustive-deps
29 }, [open])
30
31 const handleClickOutside = (event: MouseEvent) => {
32 if (
33 modalRef.current &&
34 !modalRef.current.contains(event.target as Node)
35 ) {
36 setIsOpen(false)
37 }
38 }
39
40 const handleClose = () => {
41 setIsOpen(false)
42 }
43
44 return (
45 <>
46 <div
47 className={classNames('modal', 'backdrop-blur-sm', {
48 'modal-open': open,
49 })}
50 >
51 <div className="modal-box relative" ref={modalRef}>
52 <label
53 className="absolute btn-ghost btn-circle btn btn-sm text-lg btn-primary right-3 top-3 hover:scale-105 transition-all duration-150"
54 onClick={handleClose}
55 >
56
57 </label>
58
59 <div className="overflow-y-auto">
60 <div className="mt-7 w-full flex justify-center">
61 <img
62 className="rounded-xl max-h-96"
63 src={errorImg}
64 alt={'Internal Server Error'}
65 />
66 </div>
67 <p className="mb-7 mt-4 text-center text-base">
68 We are currently experiencing high demand for image
69 generation service, and as a result, we may be

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected