import React from 'react'; import { useTranslation } from 'react-i18next'; import { useDispatch } from 'react-redux'; import styled from 'styled-components'; import { NavigationMenu } from './components/NavigationMenu'; import { IsMobileProp } from './misc/is-mobile-prop'; import { useGetMetaQuery, useGetSessionQuery } from './services/session'; import { useSelector } from './store'; import { setDrawerShown } from './store/slices/screen'; const Container = styled.div` padding: var(--margin); position: relative; `; const Sidebar = styled.nav` width: 320px; position: fixed; top: var(--margin); left: var(--margin); `; const Main = styled.main` flex: 1; margin-top: 80px; margin-left: ${p => !p.isMobile ? `${320 + 16}px` : 0}; min-width: 0; `; const MobileHeader = styled.header` position: fixed; top: 0; left: 0; right: 0; height: 64px; background: var(--panel); > h1 { font-size: 1rem; margin-bottom: 0; } `; export const GeneralLayout: React.FC = ({children}) => { const { data: session } = useGetSessionQuery(undefined); const { data: meta } = useGetMetaQuery(undefined); const { isMobile, title, isDrawerShown } = useSelector(state => state.screen); const {t} = useTranslation(); const dispatch = useDispatch(); return ( {isMobile && (

{t(title ?? 'title')}

)}
{!isMobile && ( )}
{session && meta && meta.currentTokenVersion !== session.tokenVersion && (
{t('shouldUpdateToken')} {t('update')}
)} {children}
dispatch(setDrawerShown(false))}>
e.stopPropagation()}>
); };