From da6c3b04be0b44c673a670641fefc6753a277bd9 Mon Sep 17 00:00:00 2001 From: Hazem Krimi Date: Thu, 17 Jun 2021 03:27:32 +0100 Subject: [PATCH] Add messaginge sidebar component --- src/components/MessagingSidebar/index.tsx | 118 ++++++++++++++++++++++ src/components/MessagingSidebar/styles.ts | 34 +++++++ 2 files changed, 152 insertions(+) create mode 100644 src/components/MessagingSidebar/index.tsx create mode 100644 src/components/MessagingSidebar/styles.ts diff --git a/src/components/MessagingSidebar/index.tsx b/src/components/MessagingSidebar/index.tsx new file mode 100644 index 0000000..4169886 --- /dev/null +++ b/src/components/MessagingSidebar/index.tsx @@ -0,0 +1,118 @@ +import { useEffect, useState } from 'react'; +import { useHistory, useLocation } from 'react-router'; +import { useLazyQuery, useReactiveVar } from '@apollo/client'; +import { roleVar } from '../../graphql/state'; +import { Box, Button, Text } from '..'; +import { Wrapper } from './styles'; +import { + GetProjectThreadsQuery, + GetProjectThreadsQueryVariables, + ThreadObject, +} from '../../graphql/types.support'; +import { GET_PROJECT_THREADS } from '../../graphql/chat.api.support'; +import { Add, Empty } from '../../assets'; +import { clientSupport } from '../..'; + +type MessagingSidebarProps = { + onClose: () => void; +}; + +const MessagingSidebar = ({ onClose }: MessagingSidebarProps) => { + const role = useReactiveVar(roleVar); + const location = useLocation(); + const history = useHistory(); + const [projectThreads, setProjectThreads] = useState>(); + + useEffect(() => { + (async () => { + if (/\/project/i.test(location.pathname)) { + const threads = await clientSupport.query< + GetProjectThreadsQuery, + GetProjectThreadsQueryVariables + >({ + query: GET_PROJECT_THREADS, + variables: { + projectId: location.pathname.split('/')[2]!, + }, + }); + setProjectThreads(threads?.data?.getProjectThreads!); + } + })(); + + // eslint-disable-next-line + }, [location.pathname]); + + return ( + + + + + + + Messaging Support + + +