import { observer } from 'mobx-react-lite'; import { toDirective } from '@/components/utils'; import { AppState } from '@/ui_models/app_state'; import { WebApplication } from '@/ui_models/application'; import { ConfirmSignoutContainer } from '@/components/ConfirmSignoutModal'; import Authentication from '@/components/AccountMenu/Authentication'; import Footer from '@/components/AccountMenu/Footer'; import User from '@/components/AccountMenu/User'; import { useEffect } from 'preact/hooks'; type Props = { appState: AppState; application: WebApplication; }; const AccountMenu = observer(({ application, appState }: Props) => { const { show: showAccountMenu, showLogin, showRegister, setShowLogin, setShowRegister, closeAccountMenu } = appState.accountMenu; const user = application.getUser(); useEffect(() => { // Reset "Login" and "Registration" sections state when hiding account menu, // so the next time account menu is opened these sections are closed if (!showAccountMenu) { setShowLogin(false); setShowRegister(false); } }, [setShowLogin, setShowRegister, showAccountMenu]); return (
Account
Close
{!showLogin && !showRegister && user && (
)}
); }); export const AccountMenuDirective = toDirective( AccountMenu );