53 lines
1.8 KiB
JavaScript
53 lines
1.8 KiB
JavaScript
import { IconButton, Tooltip } from "@mui/material";
|
|
import { useState } from "react";
|
|
import useRequest from "@/lib/hooks/useRequest";
|
|
import EditIcon from "@mui/icons-material/Edit";
|
|
import { GET_AZMAYESH_LIST } from "@/core/utils/routes";
|
|
import CandUAzmayesh from "@/components/dashboard/azmayesh/Forms/CandUAzmayesh";
|
|
|
|
const AzmayeshUpdate = ({ rowId, mutate }) => {
|
|
const requestServer = useRequest({ auth: true });
|
|
const [openUpdateDialog, setOpenUpdateDialog] = useState(false);
|
|
const [updateInfo, setUpdateInfo] = useState(null);
|
|
const [loadingOpen, setLoadingOpen] = useState(false);
|
|
|
|
const handleGetInfo = () => {
|
|
setLoadingOpen(true);
|
|
setOpenUpdateDialog(true);
|
|
requestServer(`${GET_AZMAYESH_LIST}/${rowId}`, "get")
|
|
.then((response) => {
|
|
setUpdateInfo(response.data.data);
|
|
})
|
|
.catch(() => {})
|
|
.finally(() => {
|
|
setLoadingOpen(false);
|
|
});
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<Tooltip title="ویرایش آزمایش" arrow placement="right">
|
|
<IconButton
|
|
color="success"
|
|
sx={{ textTransform: "unset", alignSelf: "center" }}
|
|
onClick={handleGetInfo}
|
|
>
|
|
<EditIcon />
|
|
</IconButton>
|
|
</Tooltip>
|
|
{openUpdateDialog && (
|
|
<CandUAzmayesh
|
|
open={openUpdateDialog}
|
|
setOpen={setOpenUpdateDialog}
|
|
mutate={mutate}
|
|
updateInfo={updateInfo}
|
|
rowId={rowId}
|
|
loadingOpen={loadingOpen}
|
|
fromUpdate={true}
|
|
/>
|
|
)}
|
|
</>
|
|
);
|
|
};
|
|
export default AzmayeshUpdate;
|