simon | f9d78f2 | 2022-11-25 15:47:15 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 Savoir-faire Linux Inc. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU Affero General Public License as |
| 6 | * published by the Free Software Foundation; either version 3 of the |
| 7 | * License, or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU Affero General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Affero General Public |
| 15 | * License along with this program. If not, see |
| 16 | * <https://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | import { Divider, Stack, Typography } from '@mui/material'; |
| 19 | import { useContext } from 'react'; |
| 20 | |
| 21 | import { CallContext } from '../contexts/CallProvider'; |
simon | 09fe482 | 2022-11-30 23:36:25 -0500 | [diff] [blame] | 22 | import { useConversationContext } from '../contexts/ConversationProvider'; |
simon | f9d78f2 | 2022-11-25 15:47:15 -0500 | [diff] [blame] | 23 | import ChatInterface from '../pages/ChatInterface'; |
| 24 | import { CloseButton } from './Button'; |
| 25 | |
| 26 | export default () => { |
| 27 | return ( |
| 28 | <Stack |
| 29 | width="33%" |
| 30 | height="100%" |
| 31 | sx={{ |
| 32 | backgroundColor: 'white', |
| 33 | }} |
| 34 | > |
| 35 | <CallChatDrawerHeader /> |
| 36 | <Divider |
| 37 | sx={{ |
| 38 | borderTop: '1px solid #E5E5E5', |
| 39 | }} |
| 40 | /> |
| 41 | <ChatInterface /> |
| 42 | </Stack> |
| 43 | ); |
| 44 | }; |
| 45 | |
| 46 | const CallChatDrawerHeader = () => { |
| 47 | const { setIsChatShown } = useContext(CallContext); |
simon | 09fe482 | 2022-11-30 23:36:25 -0500 | [diff] [blame] | 48 | const { conversation } = useConversationContext(); |
simon | f9d78f2 | 2022-11-25 15:47:15 -0500 | [diff] [blame] | 49 | |
| 50 | // TODO: Improve this to support multiple members |
| 51 | const contact = conversation.getFirstMember().contact; |
| 52 | |
| 53 | return ( |
| 54 | <Stack direction="row" padding={2} spacing={2} alignItems="center"> |
| 55 | <CloseButton |
| 56 | onClick={() => { |
| 57 | setIsChatShown(false); |
| 58 | }} |
| 59 | /> |
| 60 | <Stack direction="column"> |
| 61 | <Typography variant="h3" textOverflow="ellipsis"> |
| 62 | {contact.getDisplayName()} |
| 63 | </Typography> |
| 64 | </Stack> |
| 65 | </Stack> |
| 66 | ); |
| 67 | }; |