import { Box, ButtonBase, Divider, Typography } from "@mui/material"; import React, { useCallback, useEffect, useMemo, useRef, useState, } from "react"; import CloseIcon from "@mui/icons-material/Close"; import AppViewerContainer from "../Apps/AppViewerContainer"; import { executeEvent, subscribeToEvent, unsubscribeFromEvent, } from "../../utils/events"; import { useRecoilState } from "recoil"; import { navigationControllerAtom } from "../../atoms/global"; import { AppsNavBarLeft, AppsNavBarParent } from "../Apps/Apps-styles"; import NavBack from "../../assets/svgs/NavBack.svg"; import RefreshIcon from "@mui/icons-material/Refresh"; export const WalletsAppWrapper = () => { const iframeRef = useRef(null); const [isOpen, setIsOpen] = useState(false); const [navigationController, setNavigationController] = useRecoilState( navigationControllerAtom ); const [selectedTab, setSelectedTab] = useState({ tabId: "5558589", name: "Q-Wallets", service: "APP", path: '/qortal?authOnMount=true' }); const isDisableBackButton = useMemo(() => { if (selectedTab && navigationController[selectedTab?.tabId]?.hasBack) return false; if (selectedTab && !navigationController[selectedTab?.tabId]?.hasBack) return true; return false; }, [navigationController, selectedTab]); const openWalletsAppFunc = useCallback( (e) => { setIsOpen(true); }, [setIsOpen] ); useEffect(() => { subscribeToEvent("openWalletsApp", openWalletsAppFunc); return () => { unsubscribeFromEvent("openWalletsApp", openWalletsAppFunc); }; }, [openWalletsAppFunc]); const handleClose = ()=> { setIsOpen(false); iframeRef.current = null } return ( <> {isOpen && ( Q-Wallets { executeEvent(`navigateBackApp-${selectedTab?.tabId}`, {}); }} disabled={isDisableBackButton} sx={{ opacity: !isDisableBackButton ? 1 : 0.1, cursor: !isDisableBackButton ? "pointer" : "default", }} > { if (selectedTab?.refreshFunc) { selectedTab.refreshFunc(selectedTab?.tabId); } else { executeEvent("refreshApp", { tabId: selectedTab?.tabId, }); } }}> )} ); };