import { Box, ButtonBase, Divider, Typography, useTheme } from '@mui/material'; import { 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 { navigationControllerAtom } from '../../atoms/global'; import { AppsNavBarLeft, AppsNavBarParent } from '../Apps/Apps-styles'; import { NavBack } from '../../assets/Icons/NavBack.tsx'; import RefreshIcon from '@mui/icons-material/Refresh'; import { useAtom } from 'jotai'; export const WalletsAppWrapper = () => { const iframeRef = useRef(null); const [isOpen, setIsOpen] = useState(false); const [navigationController, setNavigationController] = useAtom( navigationControllerAtom ); const [selectedTab, setSelectedTab] = useState({ tabId: '5558589', name: 'Q-Wallets', service: 'APP', path: 'qortal?authOnMount=true', }); const theme = useTheme(); 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, }); } }} > )} ); };