diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/HistoryContent.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/HistoryContent.jsx new file mode 100644 index 0000000..71f59c1 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/HistoryContent.jsx @@ -0,0 +1,17 @@ +import { Button, DialogActions, DialogContent } from "@mui/material"; +import TableContent from "./TableContent"; +const HistoryContent = ({ setOpenReferReasonDialog, rowId }) => { + return ( + <> + + + + + + + + ); +}; +export default HistoryContent; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/TableContent.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/TableContent.jsx new file mode 100644 index 0000000..cd3afb0 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/TableContent.jsx @@ -0,0 +1,56 @@ +import { Box, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, CircularProgress, Typography } from "@mui/material"; +import "moment/locale/fa"; +import { useHistory } from "@/lib/hooks/useHistory"; + +const TableContent = ({ rowId }) => { + const { historyData, loading, error } = useHistory(rowId); + + if (loading) { + return ( + + + + ); + } + + if (error) { + return ( + + {error} + + ); + } + + if (!historyData.length) { + return ( + + اطلاعاتی وجود ندارد + + ); + } + + return ( + + + + + + وضعیت + توضیحات کارشناس + + + + {historyData.map((row) => ( + + {row.previous_state_name} + {row.expert_description} + + ))} + +
+
+
+ ); +}; + +export default TableContent; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/index.jsx new file mode 100644 index 0000000..234ac15 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/History/index.jsx @@ -0,0 +1,33 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { RestorePage } from "@mui/icons-material"; +import HistoryContent from "./HistoryContent"; +import { useState } from "react"; + +const History = ({ rowId }) => { + const [openReferReasonDialog, setOpenReferReasonDialog] = useState(false); + + return ( + <> + + setOpenReferReasonDialog(true)}> + + + + + تاریخچه + + + + ); +}; + +export default History; diff --git a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx index cb1517b..a432d18 100644 --- a/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/city-admin/RowActions/index.jsx @@ -1,5 +1,6 @@ import { Box } from "@mui/material"; import FeedbackAction from "./FeedbackAction"; +import History from "./History"; const RowActions = ({ row, mutate }) => { return ( @@ -9,6 +10,7 @@ const RowActions = ({ row, mutate }) => { ) : ( "-" )} + ); }; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/HistoryContent.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/HistoryContent.jsx new file mode 100644 index 0000000..71f59c1 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/HistoryContent.jsx @@ -0,0 +1,17 @@ +import { Button, DialogActions, DialogContent } from "@mui/material"; +import TableContent from "./TableContent"; +const HistoryContent = ({ setOpenReferReasonDialog, rowId }) => { + return ( + <> + + + + + + + + ); +}; +export default HistoryContent; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/TableContent.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/TableContent.jsx new file mode 100644 index 0000000..cd3afb0 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/TableContent.jsx @@ -0,0 +1,56 @@ +import { Box, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, CircularProgress, Typography } from "@mui/material"; +import "moment/locale/fa"; +import { useHistory } from "@/lib/hooks/useHistory"; + +const TableContent = ({ rowId }) => { + const { historyData, loading, error } = useHistory(rowId); + + if (loading) { + return ( + + + + ); + } + + if (error) { + return ( + + {error} + + ); + } + + if (!historyData.length) { + return ( + + اطلاعاتی وجود ندارد + + ); + } + + return ( + + + + + + وضعیت + توضیحات کارشناس + + + + {historyData.map((row) => ( + + {row.previous_state_name} + {row.expert_description} + + ))} + +
+
+
+ ); +}; + +export default TableContent; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/index.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/index.jsx new file mode 100644 index 0000000..234ac15 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/History/index.jsx @@ -0,0 +1,33 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { RestorePage } from "@mui/icons-material"; +import HistoryContent from "./HistoryContent"; +import { useState } from "react"; + +const History = ({ rowId }) => { + const [openReferReasonDialog, setOpenReferReasonDialog] = useState(false); + + return ( + <> + + setOpenReferReasonDialog(true)}> + + + + + تاریخچه + + + + ); +}; + +export default History; diff --git a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/index.jsx index 06ea132..1251678 100644 --- a/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/general-manager/RowActions/index.jsx @@ -1,12 +1,21 @@ import { Box } from "@mui/material"; import ConfirmAction from "./ConfirmAction"; import RejectAction from "./RejectAction"; +import History from "./History"; const RowActions = ({ row, mutate }) => { + // const stateId = row.original.state_id; + // + // const disabled = { + // referral: stateId !== 2, + // reject: stateId !== 2 && stateId !== 5, + // confirm: stateId !== 2 && stateId !== 5 && stateId !== 13, + // }; return ( + ); }; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx index 7820320..3903560 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ConfirmAction/index.jsx @@ -2,6 +2,7 @@ import ThumbUpIcon from "@mui/icons-material/ThumbUp"; import { IconButton, Tooltip } from "@mui/material"; const ConfirmAction = ({ onClick, disabled }) => { + if (disabled) return return ( <> diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/HistoryContent.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/HistoryContent.jsx new file mode 100644 index 0000000..71f59c1 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/HistoryContent.jsx @@ -0,0 +1,17 @@ +import { Button, DialogActions, DialogContent } from "@mui/material"; +import TableContent from "./TableContent"; +const HistoryContent = ({ setOpenReferReasonDialog, rowId }) => { + return ( + <> + + + + + + + + ); +}; +export default HistoryContent; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/TableContent.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/TableContent.jsx new file mode 100644 index 0000000..cd3afb0 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/TableContent.jsx @@ -0,0 +1,56 @@ +import { Box, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, CircularProgress, Typography } from "@mui/material"; +import "moment/locale/fa"; +import { useHistory } from "@/lib/hooks/useHistory"; + +const TableContent = ({ rowId }) => { + const { historyData, loading, error } = useHistory(rowId); + + if (loading) { + return ( + + + + ); + } + + if (error) { + return ( + + {error} + + ); + } + + if (!historyData.length) { + return ( + + اطلاعاتی وجود ندارد + + ); + } + + return ( + + + + + + وضعیت + توضیحات کارشناس + + + + {historyData.map((row) => ( + + {row.previous_state_name} + {row.expert_description} + + ))} + +
+
+
+ ); +}; + +export default TableContent; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/index.jsx new file mode 100644 index 0000000..234ac15 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/History/index.jsx @@ -0,0 +1,33 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { RestorePage } from "@mui/icons-material"; +import HistoryContent from "./HistoryContent"; +import { useState } from "react"; + +const History = ({ rowId }) => { + const [openReferReasonDialog, setOpenReferReasonDialog] = useState(false); + + return ( + <> + + setOpenReferReasonDialog(true)}> + + + + + تاریخچه + + + + ); +}; + +export default History; diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx index 85a693f..a5326f5 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/ReferralAction/index.jsx @@ -2,6 +2,7 @@ import { Reply } from "@mui/icons-material"; import { IconButton, Tooltip } from "@mui/material"; const ReferralAction = ({ onClick, disabled }) => { + if (disabled) return return ( <> diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx index e467e87..a4647b7 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/RejectAction/index.jsx @@ -2,6 +2,7 @@ import ThumbDownIcon from "@mui/icons-material/ThumbDown"; import { IconButton, Tooltip } from "@mui/material"; const RejectAction = ({ onClick, disabled }) => { + if (disabled) return return ( <> diff --git a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx index 6cc004d..ed3df15 100644 --- a/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx +++ b/src/components/dashboard/inquiryPrivacy/privacy-office/RowActions/index.jsx @@ -4,6 +4,7 @@ import ActionDialog from "./ActionsDialog"; import ConfirmAction from "./ConfirmAction"; import ReferralAction from "./ReferralAction"; import RejectAction from "./RejectAction"; +import History from "./History"; const RowActions = ({ row: { original }, mutate }) => { const [modal, setModal] = useState({ @@ -31,6 +32,7 @@ const RowActions = ({ row: { original }, mutate }) => { return ( <> + handleOpenModal("refer_request", original)} disabled={disabled.referral} diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/HistoryContent.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/HistoryContent.jsx new file mode 100644 index 0000000..71f59c1 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/HistoryContent.jsx @@ -0,0 +1,17 @@ +import { Button, DialogActions, DialogContent } from "@mui/material"; +import TableContent from "./TableContent"; +const HistoryContent = ({ setOpenReferReasonDialog, rowId }) => { + return ( + <> + + + + + + + + ); +}; +export default HistoryContent; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/TableContent.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/TableContent.jsx new file mode 100644 index 0000000..cd3afb0 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/TableContent.jsx @@ -0,0 +1,56 @@ +import { Box, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, CircularProgress, Typography } from "@mui/material"; +import "moment/locale/fa"; +import { useHistory } from "@/lib/hooks/useHistory"; + +const TableContent = ({ rowId }) => { + const { historyData, loading, error } = useHistory(rowId); + + if (loading) { + return ( + + + + ); + } + + if (error) { + return ( + + {error} + + ); + } + + if (!historyData.length) { + return ( + + اطلاعاتی وجود ندارد + + ); + } + + return ( + + + + + + وضعیت + توضیحات کارشناس + + + + {historyData.map((row) => ( + + {row.previous_state_name} + {row.expert_description} + + ))} + +
+
+
+ ); +}; + +export default TableContent; diff --git a/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/index.jsx b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/index.jsx new file mode 100644 index 0000000..234ac15 --- /dev/null +++ b/src/components/dashboard/inquiryPrivacy/technical-deputy/RowActions/History/index.jsx @@ -0,0 +1,33 @@ +import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material"; +import { RestorePage } from "@mui/icons-material"; +import HistoryContent from "./HistoryContent"; +import { useState } from "react"; + +const History = ({ rowId }) => { + const [openReferReasonDialog, setOpenReferReasonDialog] = useState(false); + + return ( + <> + + setOpenReferReasonDialog(true)}> + + + + + تاریخچه + + + + ); +}; + +export default History; diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index f479220..bbbe9f3 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -243,3 +243,6 @@ export const GET_PRIVACY_ADMIN_LIST = api + "/api/v3/harim/harim_office"; export const PRIVACY_ADMIN_ACTION_API = api + "/api/v3/harim/harim_office"; export const GET_INQUIRY_PRIVACY_TABLE_LIST = api + "/api/v3/harim/technical_deputy"; export const GET_GENERAL_MANAGER_LIST = api + "/api/v3/harim/general_manager"; + +// History +export const GET_HISTORY_LIST = api + "/api/v3/harim/detail/histories"; diff --git a/src/lib/hooks/useHistory.js b/src/lib/hooks/useHistory.js new file mode 100644 index 0000000..df1836c --- /dev/null +++ b/src/lib/hooks/useHistory.js @@ -0,0 +1,30 @@ +import { useState, useEffect } from "react"; +import useRequest from "@/lib/hooks/useRequest"; +import { GET_HISTORY_LIST } from "@/core/utils/routes"; + +export const useHistory = (rowId) => { + const requestServer = useRequest(); + const [historyData, setHistoryData] = useState([]); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + if (!rowId) return; + + const fetchHistory = async () => { + try { + setLoading(true); + const response = await requestServer(`${GET_HISTORY_LIST}/${rowId}`); + setHistoryData(response.data.data); + } catch (err) { + setError(err.message); + } finally { + setLoading(false); + } + }; + + fetchHistory(); + }, [rowId]); + + return { historyData, loading, error }; +};