forked from prepared911/full-stack-take-home
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChatroomsPage.tsx
35 lines (31 loc) · 1.14 KB
/
ChatroomsPage.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { AddComment } from "@mui/icons-material";
import { Box, Button, Container, Typography } from "@mui/material";
import { useState } from "react";
import { useChatroomsListQuery } from "~src/codegen/graphql";
import { ChatroomsList } from "./ChatroomsList";
import { CreateChatroomModal } from "./CreateChatroomModal";
export const ChatroomsPage: React.FC = () => {
const { data, loading } = useChatroomsListQuery();
const [showCreateChatroomModal, setShowCreateChatroomModal] = useState(false);
const chatrooms = data?.chatrooms ?? [];
return (
<Container>
<Box display="flex" justifyContent="space-between" marginBottom={2}>
<Typography variant="h5">Chatrooms</Typography>
<Button
size="small"
variant="contained"
startIcon={<AddComment />}
onClick={() => setShowCreateChatroomModal(true)}
>
New Chatroom
</Button>
</Box>
<ChatroomsList loading={loading} chatrooms={chatrooms} />
<CreateChatroomModal
open={showCreateChatroomModal}
handleClose={() => setShowCreateChatroomModal(false)}
/>
</Container>
);
};