2022-08-05 19:36:07 +00:00
|
|
|
import { useEffect, useContext } from 'react';
|
2022-08-05 22:06:53 +00:00
|
|
|
import { Drawer } from 'antd';
|
2022-08-05 19:36:07 +00:00
|
|
|
import { useNavigate } from 'react-router-dom';
|
|
|
|
import { SessionWrapper } from './Session.styled';
|
|
|
|
import { AppContext } from 'context/AppContext';
|
|
|
|
import { ViewportContext } from 'context/ViewportContext';
|
2022-08-05 22:06:53 +00:00
|
|
|
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';
|
2022-08-04 22:20:48 +00:00
|
|
|
|
|
|
|
export function Session() {
|
2022-08-05 19:36:07 +00:00
|
|
|
|
2022-08-05 22:06:53 +00:00
|
|
|
const { state, actions } = useSession();
|
2022-08-05 19:36:07 +00:00
|
|
|
const app = useContext(AppContext);
|
|
|
|
const viewport = useContext(ViewportContext);
|
|
|
|
const navigate = useNavigate();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (app.state) {
|
|
|
|
if (!app.state.access) {
|
|
|
|
navigate('/');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [app, navigate]);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<SessionWrapper>
|
|
|
|
{ (viewport.state.display === 'xlarge') && (
|
|
|
|
<div class="desktop-layout">
|
2022-08-05 22:06:53 +00:00
|
|
|
<div class="left">
|
|
|
|
<Identity />
|
|
|
|
<Channels />
|
|
|
|
</div>
|
|
|
|
<div class="center">
|
|
|
|
{ state.conversation && (
|
|
|
|
<div class="reframe">
|
|
|
|
<Conversation cardId={state.cardId} conversationId={state.conversationId} />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{ state.contact && (
|
|
|
|
<div class="reframe">
|
|
|
|
<Contact guid={state.contactGuid} />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{ state.profile && (
|
|
|
|
<div class="reframe">
|
|
|
|
<Profile />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
<div class="right">
|
|
|
|
<Welcome />
|
|
|
|
{ state.conversation && (
|
|
|
|
<div class="reframe">
|
|
|
|
<Details cardId={state.cardId} conversationId={state.conversationId} />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{ state.cards && (
|
|
|
|
<div class="reframe">
|
|
|
|
<Cards />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
2022-08-05 19:36:07 +00:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{ (viewport.state.display === 'large' || viewport.state.display === 'medium') && (
|
|
|
|
<div class="tablet-layout">
|
2022-08-05 22:06:53 +00:00
|
|
|
<div class="left">
|
|
|
|
<Identity />
|
|
|
|
<Channels />
|
|
|
|
</div>
|
|
|
|
<div class="right">
|
|
|
|
<Welcome />
|
|
|
|
{ state.conversation && (
|
|
|
|
<div class="reframe">
|
|
|
|
<Conversation cardId={state.cardId} conversationId={state.conversationId} />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
<Drawer width={'33%'} closable={false} onClose={actions.closeDetails} visible={state.details} zIndex={10}>
|
|
|
|
{ state.details && (
|
|
|
|
<Details cardId={state.cardId} conversationId={state.conversationId} />
|
|
|
|
)}
|
|
|
|
</Drawer>
|
|
|
|
<Drawer width={'33%'} closable={false} onClose={actions.closeCards} visible={state.cards} zIndex={20}>
|
|
|
|
{ state.cards && (
|
|
|
|
<Cards />
|
|
|
|
)}
|
|
|
|
<Drawer width={'33%'} closable={false} onClose={actions.closeContact} visible={state.contact} zIndex={30}>
|
|
|
|
{ state.contact && (
|
|
|
|
<Contact guid={state.contactGuid} />
|
|
|
|
)}
|
|
|
|
</Drawer>
|
|
|
|
</Drawer>
|
|
|
|
<Drawer width={'33%'} closable={false} onClose={actions.closeProfile} visible={state.profile} zIndex={40}>
|
|
|
|
{ state.profile && (
|
|
|
|
<Profile />
|
|
|
|
)}
|
|
|
|
</Drawer>
|
|
|
|
</div>
|
2022-08-05 19:36:07 +00:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{ (viewport.state.display === 'small') && (
|
|
|
|
<div class="mobile-layout">
|
2022-08-05 22:06:53 +00:00
|
|
|
<div class="center">
|
|
|
|
<Channels />
|
|
|
|
{ state.conversation && (
|
|
|
|
<div class="reframe">
|
|
|
|
<Conversation cardId={state.cardId} conversationId={state.conversationId} />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{ state.details && (
|
|
|
|
<div class="reframe">
|
|
|
|
<Details cardId={state.cardId} conversation={state.conversationId} />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{ state.cards && (
|
|
|
|
<div class="reframe">
|
|
|
|
<Cards />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{ state.contact && (
|
|
|
|
<div class="reframe">
|
|
|
|
<Contact guid={state.contactGuid} />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{ state.profile && (
|
|
|
|
<div class="reframe">
|
|
|
|
<Profile />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
2022-08-05 19:36:07 +00:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</SessionWrapper>
|
|
|
|
);
|
2022-08-04 22:20:48 +00:00
|
|
|
}
|
|
|
|
|