Files
frontend/src/components/dashboard/azmayesh/RowActions/AzmayeshUpdate/index.jsx
AmirHossein Mahmoodi 12d6d08bef Feature/amiriis missions
2025-06-25 07:41:03 +00:00

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();
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;