40 lines
1.5 KiB
JavaScript
40 lines
1.5 KiB
JavaScript
import { ROLE_SERVICE } from "@/core/utils/routes";
|
|
import useRequest from "@/lib/hooks/useRequest";
|
|
import { Button, DialogActions, DialogContent, Stack, Typography } from "@mui/material";
|
|
import { useState } from "react";
|
|
|
|
const DeleteContent = ({ rowId, mutate, setOpenDeleteDialog }) => {
|
|
const [submitting, setSubmitting] = useState(false);
|
|
const requestServer = useRequest({ notificationSuccess: true });
|
|
const handleClick = async () => {
|
|
setSubmitting(true);
|
|
try {
|
|
await requestServer(`${ROLE_SERVICE}/${rowId}`, "delete");
|
|
mutate();
|
|
setOpenDeleteDialog(false);
|
|
} catch (error) {
|
|
} finally {
|
|
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;
|