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 + + +