40 lines
1.6 KiB
JavaScript
40 lines
1.6 KiB
JavaScript
import { Button, DialogActions, DialogContent, Stack, Typography } from "@mui/material";
|
|
import React, { useState } from "react";
|
|
import useRequest from "@/lib/hooks/useRequest";
|
|
import { DELETE_TOLL_HOUSE_ITEM } from "@/core/utils/routes";
|
|
|
|
const DeleteContent = ({ rowId, mutate, setOpenDeleteDialog }) => {
|
|
const [submitting, setSubmitting] = useState(false);
|
|
const requestServer = useRequest({ notificationSuccess: true });
|
|
const handleClick = () => {
|
|
setSubmitting(true);
|
|
requestServer(`${DELETE_TOLL_HOUSE_ITEM}/${rowId}`, "delete")
|
|
.then(() => {
|
|
mutate();
|
|
setOpenDeleteDialog(false);
|
|
setSubmitting(false);
|
|
})
|
|
.catch(() => {
|
|
setSubmitting(false);
|
|
});
|
|
};
|
|
return (
|
|
<>
|
|
<DialogContent>
|
|
<Stack alignItems="center" spacing={2}>
|
|
<Typography mt={2}>آیا از حذف راهدارخانه اطمینان دارید؟</Typography>
|
|
</Stack>
|
|
</DialogContent>
|
|
<DialogActions sx={{ justifyContent: "center", paddingBottom: 2, width: "100%" }}>
|
|
<Button onClick={() => setOpenDeleteDialog(false)} variant="outlined" color="secondary">
|
|
خیر !
|
|
</Button>
|
|
<Button onClick={handleClick} variant="contained" color="error" disabled={submitting}>
|
|
{submitting ? "درحال حذف..." : "بله اطمینان دارم"}
|
|
</Button>
|
|
</DialogActions>
|
|
</>
|
|
);
|
|
};
|
|
export default DeleteContent;
|