import { useEffect, useContext } from 'react'; import { Drawer } from 'antd'; import { useNavigate } from 'react-router-dom'; import { SessionWrapper } from './Session.styled'; import { AppContext } from 'context/AppContext'; import { ViewportContext } from 'context/ViewportContext'; import { useSession } from './useSession.hook'; import { Conversation } from './conversation/Conversation'; import { Details } from './details/Details'; import { Identity } from './identity/Identity'; import { Channels } from './channels/Channels'; import { Cards } from './cards/Cards'; import { Contact } from './contact/Contact'; import { Profile } from './profile/Profile'; import { Welcome } from './welcome/Welcome'; export function Session() { const { state, actions } = useSession(); const app = useContext(AppContext); const viewport = useContext(ViewportContext); const navigate = useNavigate(); useEffect(() => { if (app.state) { if (!app.state.access) { navigate('/'); } } }, [app, navigate]); return ( { (viewport.state.display === 'xlarge') && (
{ state.conversation && (
)} { state.contact && (
)} { state.profile && (
)}
{ state.conversation && (
)} { state.cards && (
)}
)} { (viewport.state.display === 'large' || viewport.state.display === 'medium') && (
{ state.conversation && (
)} { state.details && (
)} { state.cards && ( )} { state.contact && ( )} { state.profile && ( )}
)} { (viewport.state.display === 'small') && (
{ state.conversation && (
)} { state.details && (
)} { state.cards && (
)} { state.contact && (
)} { state.profile && (
)}
)}
); }