59 lines
2.0 KiB
JavaScript
59 lines
2.0 KiB
JavaScript
import { Dialog, DialogTitle, IconButton } from "@mui/material";
|
|
import CreateFormContent from "./CreateFormContent";
|
|
import CloseIcon from "@mui/icons-material/Close";
|
|
import useRequest from "@/lib/hooks/useRequest";
|
|
import { CREATE_USER_ACTIVITY } from "@/core/utils/routes";
|
|
import { DialogHeader } from "next/dist/client/components/react-dev-overlay/internal/components/Dialog";
|
|
|
|
const CreateForm = ({ open, setOpen, mutate }) => {
|
|
const requestServer = useRequest({ notificationSuccess: true });
|
|
const defaultValues = {
|
|
title: "",
|
|
log_unique_code: "",
|
|
action_type: "",
|
|
};
|
|
const onSubmit = async (result) => {
|
|
const formData = new FormData();
|
|
formData.append("description", result.title);
|
|
formData.append("log_unique_code", result.log_unique_code);
|
|
formData.append("action_type", result.action_type);
|
|
await requestServer(CREATE_USER_ACTIVITY, "post", {
|
|
data: formData,
|
|
})
|
|
.then(() => {
|
|
mutate();
|
|
setOpen(false);
|
|
})
|
|
.catch(() => {});
|
|
};
|
|
return (
|
|
<Dialog open={open} fullWidth maxWidth={"xs"}>
|
|
<IconButton
|
|
aria-label="close"
|
|
onClick={() => setOpen(false)}
|
|
sx={(theme) => ({
|
|
position: "absolute",
|
|
right: 8,
|
|
top: 8,
|
|
zIndex: 50,
|
|
color: theme.palette.grey[500],
|
|
})}
|
|
>
|
|
<CloseIcon />
|
|
</IconButton>
|
|
<DialogHeader>
|
|
<DialogTitle>ثبت فعالیت کاربران</DialogTitle>
|
|
</DialogHeader>
|
|
{open && (
|
|
<CreateFormContent
|
|
defaultValues={defaultValues}
|
|
onSubmitBase={onSubmit}
|
|
setOpen={setOpen}
|
|
mutate={mutate}
|
|
/>
|
|
)}
|
|
</Dialog>
|
|
);
|
|
};
|
|
export default CreateForm;
|