forked from prepared911/full-stack-take-home
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CreateChatroomModal.tsx
50 lines (46 loc) · 1.13 KB
/
CreateChatroomModal.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { Box, Card, Modal } from "@mui/material";
import {
ChatroomsListDocument,
useCreateChatroomMutation,
} from "~src/codegen/graphql";
import {
CreateChatroomForm,
CreateChatroomFormProps,
} from "./CreateChatroomForm";
export type CreateChatroomModalProps = {
open: boolean;
handleClose: () => void;
};
export const CreateChatroomModal: React.FC<CreateChatroomModalProps> = ({
open,
handleClose,
}) => {
const [createChatroom] = useCreateChatroomMutation({
refetchQueries: [ChatroomsListDocument],
});
const handleSubmit: CreateChatroomFormProps["onSubmit"] = async (
variables
) => {
createChatroom({ variables });
};
return (
<Modal open={open} onClose={handleClose}>
<Box
position="absolute"
display="flex"
alignItems="center"
justifyContent="center"
sx={{ inset: 0 }}
>
<Card variant="outlined" sx={{ minWidth: 400, padding: 2 }}>
{open && (
<CreateChatroomForm
onSubmit={handleSubmit}
handleClose={handleClose}
/>
)}
</Card>
</Box>
</Modal>
);
};