databag/net/web/src/session/Session.jsx

154 lines
5.1 KiB
React
Raw Normal View History

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-07 06:41:09 +00:00
import { BottomNav } from './bottomNav/BottomNav';
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 noselect">
2022-08-05 22:06:53 +00:00
<div class="left">
2022-08-12 18:48:55 +00:00
<Identity openCards={actions.openCards} />
<div class="bottom">
<Channels />
</div>
2022-08-05 22:06:53 +00:00
</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 noselect">
2022-08-05 22:06:53 +00:00
<div class="left">
2022-08-12 18:48:55 +00:00
<Identity openCards={actions.openCards} />
<div class="bottom">
<Channels />
</div>
2022-08-05 22:06:53 +00:00
</div>
<div class="right">
<Welcome />
{ state.conversation && (
<div class="reframe">
<Conversation cardId={state.cardId} conversationId={state.conversationId} />
</div>
)}
2022-08-12 18:48:55 +00:00
<Drawer bodyStyle={{ padding: 0 }} width={'33%'} closable={false} onClose={actions.closeDetails} visible={state.details} zIndex={10}>
2022-08-05 22:06:53 +00:00
{ state.details && (
<Details cardId={state.cardId} conversationId={state.conversationId} />
)}
</Drawer>
2022-08-12 18:48:55 +00:00
<Drawer bodyStyle={{ padding: 0 }} width={'33%'} closable={false} onClose={actions.closeCards} visible={state.cards} zIndex={20}>
2022-08-05 22:06:53 +00:00
{ state.cards && (
<Cards />
)}
2022-08-12 18:48:55 +00:00
<Drawer bodyStyle={{ padding: 0 }} width={'33%'} closable={false} onClose={actions.closeContact} visible={state.contact} zIndex={30}>
2022-08-05 22:06:53 +00:00
{ 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 noselect">
2022-08-07 06:41:09 +00:00
<div class="top">
2022-08-08 06:30:34 +00:00
<div class="reframe">
<Channels />
</div>
2022-08-05 22:06:53 +00:00
{ 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-07 06:41:09 +00:00
<div class="bottom">
<BottomNav state={state} actions={actions} />
</div>
2022-08-05 19:36:07 +00:00
</div>
)}
</SessionWrapper>
);
2022-08-04 22:20:48 +00:00
}