From e8d097756993cffdfd61f5c54b21ddab5e1d694b Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Thu, 27 Feb 2025 11:55:04 +0000 Subject: [PATCH] Resolve #86c24bdcu "Feature/restore fast react " --- .../RowActions/RestoreForm/RestoreContent.jsx | 42 +++++++++++++++++++ .../RowActions/RestoreForm/index.jsx | 32 ++++++++++++++ .../fastReact/supervisor/RowActions/index.jsx | 3 ++ src/core/utils/routes.js | 1 + 4 files changed, 78 insertions(+) create mode 100644 src/components/dashboard/fastReact/supervisor/RowActions/RestoreForm/RestoreContent.jsx create mode 100644 src/components/dashboard/fastReact/supervisor/RowActions/RestoreForm/index.jsx diff --git a/src/components/dashboard/fastReact/supervisor/RowActions/RestoreForm/RestoreContent.jsx b/src/components/dashboard/fastReact/supervisor/RowActions/RestoreForm/RestoreContent.jsx new file mode 100644 index 0000000..06c86a6 --- /dev/null +++ b/src/components/dashboard/fastReact/supervisor/RowActions/RestoreForm/RestoreContent.jsx @@ -0,0 +1,42 @@ +import { RESTORE_FAST_REACT } from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { Button, DialogActions, DialogContent, Stack, Typography } from "@mui/material"; +import { useState } from "react"; + +const RestoreContent = ({ rowId, mutate, setOpenRestoreDialog }) => { + const [submitting, setSubmitting] = useState(false); + const requestServer = useRequest({ notificationSuccess: true }); + const handleClick = () => { + setSubmitting(true); + requestServer(`${RESTORE_FAST_REACT}/${rowId}`, "post") + .then(() => { + mutate(); + setOpenRestoreDialog(false); + setSubmitting(false); + }) + .catch(() => { + setSubmitting(false); + }); + }; + return ( + <> + + + + آیا از بازگردانی فعالیت اطمینان دارید؟ + + + + + + + + + ); +}; + +export default RestoreContent; diff --git a/src/components/dashboard/fastReact/supervisor/RowActions/RestoreForm/index.jsx b/src/components/dashboard/fastReact/supervisor/RowActions/RestoreForm/index.jsx new file mode 100644 index 0000000..2632c20 --- /dev/null +++ b/src/components/dashboard/fastReact/supervisor/RowActions/RestoreForm/index.jsx @@ -0,0 +1,32 @@ +import React, { useState } from "react"; +import { Tooltip, IconButton, Dialog, DialogTitle } from "@mui/material"; +import ReplyIcon from "@mui/icons-material/Reply"; +import RestoreContent from "./RestoreContent"; +const RestoreForm = ({ rowId, mutate }) => { + const [openRestoreDialog, setOpenRestoreDialog] = useState(false); + + return ( + <> + + setOpenRestoreDialog(true)}> + + + + setOpenRestoreDialog(false)} + PaperProps={{ + sx: { + boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px", + }, + }} + dir="rtl" + maxWidth={"md"} + > + بازگردانی فعالیت + + + + ); +}; +export default RestoreForm; diff --git a/src/components/dashboard/fastReact/supervisor/RowActions/index.jsx b/src/components/dashboard/fastReact/supervisor/RowActions/index.jsx index bf60960..b889295 100644 --- a/src/components/dashboard/fastReact/supervisor/RowActions/index.jsx +++ b/src/components/dashboard/fastReact/supervisor/RowActions/index.jsx @@ -2,12 +2,14 @@ import { Box } from "@mui/material"; import ConfirmForm from "./ConfirmDialog"; import RejectForm from "./RejectDialog"; import { usePermissions } from "@/lib/hooks/usePermissions"; +import RestoreForm from "./RestoreForm"; const RowActions = ({ row, mutate }) => { const { data: userPermissions } = usePermissions(); const hasSupervisePermission = userPermissions.some((item) => ["supervise-fast-react", "supervise-fast-react-province"].includes(item) ); + const hasRestorePermission = userPermissions.includes("restore-fast-react"); return ( {hasSupervisePermission && row.original?.status === 0 && ( @@ -16,6 +18,7 @@ const RowActions = ({ row, mutate }) => { {hasSupervisePermission && row.original?.status === 0 && ( )} + {hasRestorePermission && } ); }; diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index 1bee5c2..7fa077c 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -119,3 +119,4 @@ export const REJECT_BY_FAST_REACT_SUPERVISOR = api + "/api/v3/road_observations/ export const GET_FAST_REACT_OPERATOR = api + "/api/v3/road_observations/operator_index"; export const GET_FAST_REACT_REFER_LIST = api + "/api/v3/road_observations/refer_list"; export const REFER_FAST_REACT = api + "/api/v3/road_observations/refer"; +export const RESTORE_FAST_REACT = api + "/api/v3/road_observations/restore";