import React, {useState, useEffect} from "react"; import styles from "./Modal.module.css"; import AccountUpdatePage from "../components/AccountUpdatePage.js"; import CreateClerk from "../pages/CreateClerk" import CreateCafe from "../pages/CreateCafe" import CreateTenant from "../pages/CreateTenant" import TablesPage from "./TablesPage.js"; import PaymentOptions from "./PaymentOptions.js"; import Transaction from "../pages/Transaction"; import Transaction_item from "../pages/Transaction_item"; import Transaction_pending from "../pages/Transaction_pending"; import Transaction_confirmed from "../pages/Transaction_confirmed"; import Transaction_success from "../pages/Transaction_success"; import Transaction_end from "../pages/Transaction_end"; import Transaction_failed from "../pages/Transaction_failed"; import Payment_claimed from "../pages/Payment_claimed"; import MaterialList from "../pages/MaterialList.js"; import MaterialMutationsPage from "../pages/MaterialMutationsPage.js"; import Reports from "../pages/Reports.js"; import NotificationRequest from "../pages/NotificationRequest.js"; import NotificationBlocked from "../pages/NotificationBlocked.js"; import WelcomePageEditor from "../pages/WelcomePageEditor.js"; import GuidePage from "../pages/GuidePage"; import Join from "../pages/Join"; import Loading from "../pages/Loading"; import Message from "../pages/Message"; import PlayerPrompt from "../pages/PlayerPrompt"; import Login from "../pages/Login"; import ResetPassword from "../pages/ResetPassword"; import { getImageUrl } from "../helpers/itemHelper.js"; import CreateCoupon from "../pages/CreateCoupon"; import CheckCoupon from "../pages/CheckCoupon"; import CreateUserWithCoupon from "../pages/CreateUserWithCoupon"; const Modal = ({ user, shop, isOpen, onClose, modalContent, deviceType, setModal, handleMoveToTransaction, depth,welcomePageConfig, onModalCloseFunction, onModalYesFunction }) => { const [shopImg, setShopImg] = useState(''); const [updateKey, setUpdateKey] = useState(0); useEffect(() => { if (welcomePageConfig) { const parsedConfig = JSON.parse(welcomePageConfig); setShopImg( getImageUrl(parsedConfig.image) || "") } }, [welcomePageConfig]); useEffect(() => { setUpdateKey(updateKey+1); }, [shop]); if (!isOpen) return null; // Function to handle clicks on the overlay const handleOverlayClick = (event) => { console.log(onModalCloseFunction) if (onModalCloseFunction) { onModalCloseFunction(); // Execute the passed closure } onClose(); // Close the modal }; const handleNo = (event) => { if(onModalCloseFunction) onModalCloseFunction(); onClose(); } // Function to handle clicks on the modal content const handleContentClick = (event) => { // Prevent click event from propagating to the overlay event.stopPropagation(); }; if(modalContent == '') handleOverlayClick(); return (