Skip to content

Commit

Permalink
Add close icon to create modal
Browse files Browse the repository at this point in the history
  • Loading branch information
devleejb committed Jan 22, 2024
1 parent 5bb72e4 commit 9fd36b0
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions frontend/src/components/modals/CreateModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import { Button, FormControl, Modal, ModalProps, Paper, Stack, Typography } from "@mui/material";
import {
Button,
FormControl,
IconButton,
Modal,
ModalProps,
Paper,
Stack,
Typography,
} from "@mui/material";
import { FormContainer, TextFieldElement } from "react-hook-form-mui";
import CloseIcon from "@mui/icons-material/Close";

interface CreateRequest {
title: string;
Expand All @@ -13,9 +23,13 @@ interface CreateModalProps extends Omit<ModalProps, "children"> {
function CreateModal(props: CreateModalProps) {
const { title, onSuccess, ...modalProps } = props;

const handleCloseModal = () => {
modalProps?.onClose?.(new Event("Close Modal"), "escapeKeyDown");
};

const handleCreate = async (data: CreateRequest) => {
await onSuccess(data);
modalProps?.onClose?.(new Event("Close Modal"), "escapeKeyDown");
handleCloseModal();
};

return (
Expand All @@ -30,6 +44,16 @@ function CreateModal(props: CreateModalProps) {
width: 400,
}}
>
<IconButton
sx={{
position: "absolute",
top: 28,
right: 28,
}}
onClick={handleCloseModal}
>
<CloseIcon />
</IconButton>
<Stack gap={4}>
<Typography variant="h5">Create New {title}</Typography>
<FormControl>
Expand Down

0 comments on commit 9fd36b0

Please sign in to comment.