Resolve #86c24bd8t "Feature/fast react operator "
This commit is contained in:
12
src/app/(withAuth)/dashboard/fast-react/operator/page.js
Normal file
12
src/app/(withAuth)/dashboard/fast-react/operator/page.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import OperatorPage from "@/components/dashboard/fastReact/operator";
|
||||||
|
import WithPermission from "@/core/middlewares/withPermission";
|
||||||
|
const Page = () => {
|
||||||
|
return (
|
||||||
|
<WithPermission permission_name={["show-fast-react-edarate-shahri"]}>
|
||||||
|
<OperatorPage />
|
||||||
|
{/* <ActivityCodeLog activity_code={1137} /> */}
|
||||||
|
</WithPermission>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Page;
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
"use client";
|
|
||||||
import PageLoading from "@/core/components/PageLoading";
|
|
||||||
|
|
||||||
const Loading = () => {
|
|
||||||
return <PageLoading />;
|
|
||||||
};
|
|
||||||
export default Loading;
|
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
import DialogLoading from "@/core/components/DialogLoading";
|
||||||
|
import { GET_FAST_REACT_REFER_LIST } from "@/core/utils/routes";
|
||||||
|
import useRequest from "@/lib/hooks/useRequest";
|
||||||
|
import {
|
||||||
|
DialogContent,
|
||||||
|
Table,
|
||||||
|
TableBody,
|
||||||
|
TableCell,
|
||||||
|
TableContainer,
|
||||||
|
TableHead,
|
||||||
|
TableRow,
|
||||||
|
Typography,
|
||||||
|
} from "@mui/material";
|
||||||
|
import moment from "jalali-moment";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
|
const ReferListContent = ({ rowId }) => {
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [data, setData] = useState(null);
|
||||||
|
const request = useRequest();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchData = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const response = await request(`${GET_FAST_REACT_REFER_LIST}/${rowId}`);
|
||||||
|
setData(response.data.data);
|
||||||
|
} catch (error) {
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
fetchData();
|
||||||
|
}, [rowId]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<DialogContent>
|
||||||
|
{loading ? (
|
||||||
|
<DialogLoading />
|
||||||
|
) : data.length !== 0 ? (
|
||||||
|
<TableContainer sx={{ maxHeight: 600 }}>
|
||||||
|
<Table stickyHeader sx={{ minWidth: 800 }}>
|
||||||
|
<TableHead>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell>کاربر</TableCell>
|
||||||
|
<TableCell>از اداره</TableCell>
|
||||||
|
<TableCell>از اداره</TableCell>
|
||||||
|
<TableCell>تاریخ</TableCell>
|
||||||
|
<TableCell>توضیحات</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableHead>
|
||||||
|
<TableBody>
|
||||||
|
{data.map((refer, index) => {
|
||||||
|
return (
|
||||||
|
<TableRow
|
||||||
|
key={index}
|
||||||
|
sx={{ "&:last-child td, &:last-child th": { border: 0 } }}
|
||||||
|
>
|
||||||
|
<TableCell>{refer.user}</TableCell>
|
||||||
|
<TableCell>{`${refer.from_province} | ${refer.from_edareh}`}</TableCell>
|
||||||
|
<TableCell>{`${refer.to_province} | ${refer.to_edareh}`}</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
{moment(refer.created_at).locale("fa").format("HH:mm | yyyy/MM/DD")}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>{refer.description}</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</TableContainer>
|
||||||
|
) : (
|
||||||
|
<Typography textAlign={"center"}>ارجاعی در سامانه یافت نشد</Typography>
|
||||||
|
)}
|
||||||
|
</DialogContent>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default ReferListContent;
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import { Button, Dialog, DialogActions, DialogTitle, IconButton, Tooltip } from "@mui/material";
|
||||||
|
import ListAltIcon from "@mui/icons-material/ListAlt";
|
||||||
|
import ReferListContent from "./ReferListContent";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
|
const ReferList = ({ rowId }) => {
|
||||||
|
const [openReferListDialog, setOpenReferListDialog] = useState(false);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Tooltip title="لیست ارجاعات">
|
||||||
|
<IconButton color="primary" onClick={() => setOpenReferListDialog(true)}>
|
||||||
|
<ListAltIcon />
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
<Dialog
|
||||||
|
fullWidth
|
||||||
|
open={openReferListDialog}
|
||||||
|
onClose={() => setOpenReferListDialog(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"}
|
||||||
|
>
|
||||||
|
<DialogTitle sx={{ fontSize: "large" }}>لیست ارجاعات</DialogTitle>
|
||||||
|
{openReferListDialog && <ReferListContent rowId={rowId} />}
|
||||||
|
<DialogActions>
|
||||||
|
<Button
|
||||||
|
onClick={() => setOpenReferListDialog(false)}
|
||||||
|
variant="outlined"
|
||||||
|
color="secondary"
|
||||||
|
autoFocus
|
||||||
|
>
|
||||||
|
بستن
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default ReferList;
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
import { Box } from "@mui/material";
|
import { Box } from "@mui/material";
|
||||||
|
import ReferList from "./ReferList";
|
||||||
|
|
||||||
const RowActions = ({ row, mutate }) => {
|
const RowActions = ({ row, mutate }) => {
|
||||||
return <Box sx={{ display: "flex", gap: 1 }}></Box>;
|
return (
|
||||||
|
<Box sx={{ display: "flex", gap: 1 }}>
|
||||||
|
<ReferList rowId={row.getValue("id")} />
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
export default RowActions;
|
export default RowActions;
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
import { Button, CircularProgress, IconButton, useMediaQuery } from "@mui/material";
|
||||||
|
import { useMemo, useState } from "react";
|
||||||
|
import moment from "jalali-moment";
|
||||||
|
import FileSaver from "file-saver";
|
||||||
|
import DescriptionIcon from "@mui/icons-material/Description";
|
||||||
|
import useRequest from "@/lib/hooks/useRequest";
|
||||||
|
import { EXPORT_ROAD_ITEMS_SUPERVISOR_LIST } from "@/core/utils/routes";
|
||||||
|
import { useTheme } from "@emotion/react";
|
||||||
|
import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure";
|
||||||
|
import isArrayEmpty from "@/core/utils/isArrayEmpty";
|
||||||
|
|
||||||
|
const PrintExcel = ({ table, filterData }) => {
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const theme = useTheme();
|
||||||
|
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
|
||||||
|
const requestServer = useRequest();
|
||||||
|
const activeFilters = Object.entries(filterData).reduce((acc, [key, filter]) => {
|
||||||
|
if (filter.value && (!Array.isArray(filter.value) || filter.value.some((item) => item.trim() !== ""))) {
|
||||||
|
acc.push({ id: key, value: filter.value });
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const filterParams = useMemo(() => {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
if (activeFilters.length > 0) {
|
||||||
|
activeFilters.map((filter, index) => {
|
||||||
|
const filteredFilterData = DataTableFilterDataStructure(filterData, isArrayEmpty);
|
||||||
|
params.set("filters", JSON.stringify(filteredFilterData.length === 0 ? [] : filteredFilterData));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
params.set("filters", JSON.stringify([]));
|
||||||
|
}
|
||||||
|
return params;
|
||||||
|
}, [activeFilters]);
|
||||||
|
|
||||||
|
const clickHandler = () => {
|
||||||
|
setLoading(true);
|
||||||
|
requestServer(`${EXPORT_ROAD_ITEMS_SUPERVISOR_LIST}?${filterParams}`, "get", {
|
||||||
|
requestOptions: { responseType: "blob" },
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
const filename = `خروجی کارتابل ارزیابی فعالیت روزانه تاریخ_${moment().format("jYYYY_jMM_jDD")}.xlsx`;
|
||||||
|
FileSaver.saveAs(response.data, filename);
|
||||||
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{isMobile ? (
|
||||||
|
<IconButton aria-label="خروجی اکسل" color="primary" onClick={clickHandler}>
|
||||||
|
<DescriptionIcon sx={{ fontSize: "25px" }} />
|
||||||
|
</IconButton>
|
||||||
|
) : (
|
||||||
|
<Button
|
||||||
|
color="primary"
|
||||||
|
variant="contained"
|
||||||
|
size="small"
|
||||||
|
disabled={loading}
|
||||||
|
sx={{ textTransform: "unset", alignSelf: "center" }}
|
||||||
|
startIcon={loading ? <CircularProgress size={18} color="inherit" /> : <DescriptionIcon />}
|
||||||
|
onClick={clickHandler}
|
||||||
|
>
|
||||||
|
خروجی اکسل
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PrintExcel;
|
||||||
305
src/components/dashboard/fastReact/operator/OperatorList.jsx
Normal file
305
src/components/dashboard/fastReact/operator/OperatorList.jsx
Normal file
@@ -0,0 +1,305 @@
|
|||||||
|
import DataTableWithAuth from "@/core/components/DataTableWithAuth";
|
||||||
|
import { GET_FAST_REACT_OPERATOR } from "@/core/utils/routes";
|
||||||
|
import EngineeringIcon from "@mui/icons-material/Engineering";
|
||||||
|
import ThreePIcon from "@mui/icons-material/ThreeP";
|
||||||
|
import { Box, Stack, Typography } from "@mui/material";
|
||||||
|
import moment from "jalali-moment";
|
||||||
|
import { useMemo } from "react";
|
||||||
|
import RowActions from "./RowActions";
|
||||||
|
import DescriptionForm from "./RowActions/DescriptionDialog";
|
||||||
|
import ImageDialog from "./RowActions/ImageDialog";
|
||||||
|
import LocationForm from "./RowActions/LocationDialog";
|
||||||
|
import Toolbar from "./Toolbar";
|
||||||
|
|
||||||
|
const OperatorList = () => {
|
||||||
|
const statusOptions = [
|
||||||
|
{ value: "", label: "همه وضعیت ها" },
|
||||||
|
{ value: 0, label: "درحال بررسی" },
|
||||||
|
{ value: 1, label: "تایید شده" },
|
||||||
|
{ value: 2, label: "عدم تایید" },
|
||||||
|
];
|
||||||
|
|
||||||
|
const columns = useMemo(
|
||||||
|
() => [
|
||||||
|
{
|
||||||
|
accessorKey: "id",
|
||||||
|
header: "کد یکتا",
|
||||||
|
id: "road_observeds__id",
|
||||||
|
enableColumnFilter: true,
|
||||||
|
datatype: "text",
|
||||||
|
filterMode: "equals",
|
||||||
|
sortDescFirst: false,
|
||||||
|
columnFilterModeOptions: ["equals", "contains"],
|
||||||
|
grow: false,
|
||||||
|
size: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorKey: "fk_RegisteredEventMessage",
|
||||||
|
header: "کد سوانح",
|
||||||
|
id: "fk_RegisteredEventMessage",
|
||||||
|
enableColumnFilter: true,
|
||||||
|
datatype: "text",
|
||||||
|
filterMode: "equals",
|
||||||
|
sortDescFirst: false,
|
||||||
|
columnFilterModeOptions: ["equals", "contains"],
|
||||||
|
grow: false,
|
||||||
|
size: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorKey: "Title",
|
||||||
|
header: "موضوع گزارش",
|
||||||
|
id: "Title",
|
||||||
|
enableColumnFilter: true,
|
||||||
|
datatype: "text",
|
||||||
|
filterMode: "equals",
|
||||||
|
sortDescFirst: false,
|
||||||
|
columnFilterModeOptions: ["equals", "contains"],
|
||||||
|
grow: false,
|
||||||
|
size: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorKey: "FeatureTypeTitle",
|
||||||
|
header: "نوع گزارش",
|
||||||
|
id: "FeatureTypeTitle",
|
||||||
|
enableColumnFilter: true,
|
||||||
|
datatype: "text",
|
||||||
|
filterMode: "equals",
|
||||||
|
sortDescFirst: false,
|
||||||
|
columnFilterModeOptions: ["equals", "contains"],
|
||||||
|
grow: false,
|
||||||
|
size: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorKey: "Description",
|
||||||
|
header: "توضیح گزارش",
|
||||||
|
id: "Description",
|
||||||
|
enableColumnFilter: false,
|
||||||
|
datatype: "text",
|
||||||
|
filterMode: "equals",
|
||||||
|
sortDescFirst: false,
|
||||||
|
columnFilterModeOptions: ["equals", "contains"],
|
||||||
|
grow: false,
|
||||||
|
size: 100,
|
||||||
|
muiTableBodyCellProps: {
|
||||||
|
sx: {
|
||||||
|
borderLeft: "1px solid #e1e1e1",
|
||||||
|
py: 0,
|
||||||
|
"&:first-of-type": {
|
||||||
|
borderLeft: "unset",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Cell: ({ renderedCellValue }) => {
|
||||||
|
if (renderedCellValue) {
|
||||||
|
return (
|
||||||
|
<Stack alignItems={"center"} justifyContent={"center"}>
|
||||||
|
<DescriptionForm description={renderedCellValue} title={"توضیحات گزارش"} />
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return <Typography variant="body2">بدون توضیحات</Typography>;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: "موقعیت",
|
||||||
|
id: "location",
|
||||||
|
enableColumnFilter: false,
|
||||||
|
enableSorting: false,
|
||||||
|
datatype: "array",
|
||||||
|
grow: false,
|
||||||
|
size: 100,
|
||||||
|
muiTableBodyCellProps: {
|
||||||
|
sx: {
|
||||||
|
borderLeft: "1px solid #e1e1e1",
|
||||||
|
py: 0,
|
||||||
|
"&:first-of-type": {
|
||||||
|
borderLeft: "unset",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Cell: ({ row }) => {
|
||||||
|
return (
|
||||||
|
<Stack alignItems={"center"} justifyContent={"center"}>
|
||||||
|
<LocationForm start_lat={row.original.lat} start_lng={row.original.lng} />
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: "تصاویر",
|
||||||
|
id: "images",
|
||||||
|
enableColumnFilter: false,
|
||||||
|
enableSorting: false,
|
||||||
|
datatype: "array",
|
||||||
|
grow: false,
|
||||||
|
size: 100,
|
||||||
|
muiTableBodyCellProps: {
|
||||||
|
sx: {
|
||||||
|
borderLeft: "1px solid #e1e1e1",
|
||||||
|
py: 0,
|
||||||
|
"&:first-of-type": {
|
||||||
|
borderLeft: "unset",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Cell: ({ row }) => {
|
||||||
|
if (!row.original?.image_before && !row.original?.image_after) return <>بدون تصویر</>;
|
||||||
|
return (
|
||||||
|
<Stack alignItems={"center"} justifyContent={"center"}>
|
||||||
|
{row.original?.image_before && row.original?.image_after && (
|
||||||
|
<ImageDialog
|
||||||
|
image_before={row.original?.image_before}
|
||||||
|
image_after={row.original?.image_after}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorKey: "MobileForSendEventSms",
|
||||||
|
header: "شماره تماس گیرنده",
|
||||||
|
id: "MobileForSendEventSms",
|
||||||
|
enableColumnFilter: true,
|
||||||
|
datatype: "text",
|
||||||
|
filterMode: "equals",
|
||||||
|
sortDescFirst: false,
|
||||||
|
columnFilterModeOptions: ["equals", "contains"],
|
||||||
|
grow: false,
|
||||||
|
size: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => moment(row.created_at).locale("fa").format("HH:mm | yyyy/MM/DD"),
|
||||||
|
header: "تاریخ ثبت",
|
||||||
|
id: "created_at",
|
||||||
|
enableColumnFilter: true,
|
||||||
|
datatype: "date",
|
||||||
|
filterMode: "between",
|
||||||
|
grow: false,
|
||||||
|
size: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => moment(row.rms_last_activity).locale("fa").format("HH:mm | yyyy/MM/DD"),
|
||||||
|
header: "تاریخ اقدام",
|
||||||
|
id: "rms_last_activity",
|
||||||
|
enableColumnFilter: true,
|
||||||
|
datatype: "date",
|
||||||
|
filterMode: "between",
|
||||||
|
grow: false,
|
||||||
|
size: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorKey: "rms_description",
|
||||||
|
header: "توضیح مامور",
|
||||||
|
id: "rms_description",
|
||||||
|
enableColumnFilter: false,
|
||||||
|
datatype: "text",
|
||||||
|
filterMode: "equals",
|
||||||
|
sortDescFirst: false,
|
||||||
|
columnFilterModeOptions: ["equals", "contains"],
|
||||||
|
grow: false,
|
||||||
|
size: 100,
|
||||||
|
muiTableBodyCellProps: {
|
||||||
|
sx: {
|
||||||
|
borderLeft: "1px solid #e1e1e1",
|
||||||
|
py: 0,
|
||||||
|
"&:first-of-type": {
|
||||||
|
borderLeft: "unset",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Cell: ({ renderedCellValue }) => {
|
||||||
|
if (renderedCellValue) {
|
||||||
|
return (
|
||||||
|
<Stack alignItems={"center"} justifyContent={"center"}>
|
||||||
|
<DescriptionForm
|
||||||
|
description={renderedCellValue}
|
||||||
|
title={"توضیحات مامور"}
|
||||||
|
icon={EngineeringIcon}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return <Typography variant="body2">بدون توضیحات</Typography>;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorKey: "supervisor_description",
|
||||||
|
header: "توضیح کارشناس",
|
||||||
|
id: "supervisor_description",
|
||||||
|
enableColumnFilter: false,
|
||||||
|
datatype: "text",
|
||||||
|
filterMode: "equals",
|
||||||
|
sortDescFirst: false,
|
||||||
|
columnFilterModeOptions: ["equals", "contains"],
|
||||||
|
grow: false,
|
||||||
|
size: 100,
|
||||||
|
muiTableBodyCellProps: {
|
||||||
|
sx: {
|
||||||
|
borderLeft: "1px solid #e1e1e1",
|
||||||
|
py: 0,
|
||||||
|
"&:first-of-type": {
|
||||||
|
borderLeft: "unset",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Cell: ({ renderedCellValue }) => {
|
||||||
|
if (renderedCellValue) {
|
||||||
|
return (
|
||||||
|
<Stack alignItems={"center"} justifyContent={"center"}>
|
||||||
|
<DescriptionForm
|
||||||
|
description={renderedCellValue}
|
||||||
|
title={"توضیحات کارشناس"}
|
||||||
|
icon={ThreePIcon}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return <Typography variant="body2">بدون توضیحات</Typography>;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorKey: "status",
|
||||||
|
header: "وضعیت",
|
||||||
|
id: "status",
|
||||||
|
enableColumnFilter: true,
|
||||||
|
datatype: "numeric",
|
||||||
|
filterMode: "equals",
|
||||||
|
sortDescFirst: true,
|
||||||
|
grow: false,
|
||||||
|
size: 100,
|
||||||
|
columnSelectOption: () => {
|
||||||
|
return statusOptions.map((status) => ({
|
||||||
|
value: status.value,
|
||||||
|
label: status.label,
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
Cell: ({ row }) => <>{row.original.status_fa}</>,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Box sx={{ p: 1, border: 1, borderColor: "divider", borderRadius: 1 }}>
|
||||||
|
<DataTableWithAuth
|
||||||
|
need_filter={true}
|
||||||
|
columns={columns}
|
||||||
|
sorting={[
|
||||||
|
{ id: "status", desc: true },
|
||||||
|
{ id: "id", desc: true },
|
||||||
|
]}
|
||||||
|
table_url={GET_FAST_REACT_OPERATOR}
|
||||||
|
page_name={"operatorFastReact"}
|
||||||
|
table_name={"OperatorList"}
|
||||||
|
TableToolbar={Toolbar}
|
||||||
|
enableRowActions
|
||||||
|
positionActionsColumn={"last"}
|
||||||
|
RowActions={RowActions}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default OperatorList;
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import { Dialog, DialogContent, DialogTitle, IconButton, Tooltip, Typography, Card, CardContent } from "@mui/material";
|
||||||
|
import { useState } from "react";
|
||||||
|
import RemoveRedEyeIcon from "@mui/icons-material/RemoveRedEye";
|
||||||
|
import CloseIcon from "@mui/icons-material/Close";
|
||||||
|
|
||||||
|
const DescriptionForm = ({ description, title, icon: IconComponent = RemoveRedEyeIcon }) => {
|
||||||
|
const [openOfficerDescriptionDialog, setOpenOfficerDescriptionDialog] = useState(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Tooltip title={title}>
|
||||||
|
<IconButton color="primary" onClick={() => setOpenOfficerDescriptionDialog(true)}>
|
||||||
|
<IconComponent />
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
<Dialog
|
||||||
|
open={openOfficerDescriptionDialog}
|
||||||
|
onClose={() => setOpenOfficerDescriptionDialog(false)}
|
||||||
|
PaperProps={{
|
||||||
|
sx: {
|
||||||
|
transition: "all .3s",
|
||||||
|
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||||
|
borderRadius: 2,
|
||||||
|
padding: 1,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
maxWidth="sm"
|
||||||
|
fullWidth
|
||||||
|
dir="rtl"
|
||||||
|
>
|
||||||
|
<DialogTitle sx={{ display: "flex", justifyContent: "space-between", padding: "16px 24px" }}>
|
||||||
|
<Typography variant="body1" sx={{ fontWeight: "bold", fontSize: "large" }}>
|
||||||
|
{title}
|
||||||
|
</Typography>
|
||||||
|
<IconButton onClick={() => setOpenOfficerDescriptionDialog(false)} size="small">
|
||||||
|
<CloseIcon />
|
||||||
|
</IconButton>
|
||||||
|
</DialogTitle>
|
||||||
|
<DialogContent>
|
||||||
|
<Card elevation={0}>
|
||||||
|
<CardContent>
|
||||||
|
<Typography variant="body2">{description || "هیچ توضیحی موجود نیست"} </Typography>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default DescriptionForm;
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import { Box, DialogContent, Paper, Stack, Typography, useTheme } from "@mui/material";
|
||||||
|
import Image from "next/image";
|
||||||
|
|
||||||
|
const ImageFormContent = ({ image, title }) => {
|
||||||
|
const theme = useTheme();
|
||||||
|
return (
|
||||||
|
<Stack
|
||||||
|
spacing={2}
|
||||||
|
alignItems="center"
|
||||||
|
justifyContent="center"
|
||||||
|
sx={{
|
||||||
|
my: 2,
|
||||||
|
padding: 2,
|
||||||
|
borderRadius: "12px",
|
||||||
|
border: `1px solid ${theme.palette.primary.main}`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography
|
||||||
|
variant="h6"
|
||||||
|
sx={{
|
||||||
|
color: theme.palette.primary.dark,
|
||||||
|
fontWeight: "bold",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{title}
|
||||||
|
</Typography>
|
||||||
|
<Box sx={{ width: "100%", position: "relative", aspectRatio: "16/9" }}>
|
||||||
|
<Image
|
||||||
|
src={image}
|
||||||
|
alt="Image"
|
||||||
|
fill={true}
|
||||||
|
loading="lazy"
|
||||||
|
style={{
|
||||||
|
objectFit: "contain",
|
||||||
|
marginBottom: "16px",
|
||||||
|
borderRadius: "12px",
|
||||||
|
border: `1px solid ${theme.palette.divider}`,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default ImageFormContent;
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import PhotoLibraryIcon from "@mui/icons-material/PhotoLibrary";
|
||||||
|
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, IconButton, Tooltip } from "@mui/material";
|
||||||
|
import { useState } from "react";
|
||||||
|
import ImageFormContent from "./ImageFormContent";
|
||||||
|
|
||||||
|
const ImageDialog = ({ image_before, image_after }) => {
|
||||||
|
const [openImageDialog, setOpenImageDialog] = useState(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Tooltip title="تصاویر">
|
||||||
|
<IconButton color="primary" onClick={() => setOpenImageDialog(true)}>
|
||||||
|
<PhotoLibraryIcon />
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
<Dialog
|
||||||
|
fullWidth
|
||||||
|
open={openImageDialog}
|
||||||
|
onClose={() => setOpenImageDialog(false)}
|
||||||
|
PaperProps={{
|
||||||
|
sx: {
|
||||||
|
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
maxWidth={"sm"}
|
||||||
|
scroll="paper"
|
||||||
|
>
|
||||||
|
<DialogTitle sx={{ fontSize: "large" }}>تصاویر</DialogTitle>
|
||||||
|
<DialogContent>
|
||||||
|
{openImageDialog && (
|
||||||
|
<>
|
||||||
|
<ImageFormContent image={image_before} title={"عکس قبل از اقدام"} />
|
||||||
|
<ImageFormContent image={image_after} title={"عکس بعد از اقدام"} />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
<Button onClick={() => setOpenImageDialog(false)} variant="outlined" color="secondary">
|
||||||
|
بستن
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default ImageDialog;
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
"use client";
|
||||||
|
import { Box, Button, DialogActions, DialogContent, Stack } from "@mui/material";
|
||||||
|
import React from "react";
|
||||||
|
import dynamic from "next/dynamic";
|
||||||
|
import MapLoading from "@/core/components/MapLayer/Loading";
|
||||||
|
import ShowLocationMarker from "@/core/components/ShowLocationMarker";
|
||||||
|
const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
|
||||||
|
loading: () => <MapLoading />,
|
||||||
|
ssr: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const LocationFormContent = ({ setOpenLocationDialog, start_lat, start_lng }) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<DialogContent>
|
||||||
|
<Box sx={{ width: "400px", height: "400px" }}>
|
||||||
|
<MapLayer>
|
||||||
|
<ShowLocationMarker start_lat={start_lat} start_lng={start_lng} />
|
||||||
|
</MapLayer>
|
||||||
|
</Box>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions sx={{ justifyContent: "center", paddingBottom: 2, width: "100%" }}>
|
||||||
|
<Button onClick={() => setOpenLocationDialog(false)} variant="outlined" color="secondary">
|
||||||
|
بستن
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default LocationFormContent;
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import React, { useState } from "react";
|
||||||
|
import { Tooltip, IconButton, Dialog, DialogTitle } from "@mui/material";
|
||||||
|
import ExploreIcon from "@mui/icons-material/Explore";
|
||||||
|
import LocationFormContent from "./LocationFormContent";
|
||||||
|
const LocationForm = ({ start_lat, start_lng }) => {
|
||||||
|
const [openLocationDialog, setOpenLocationDialog] = useState(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Tooltip title="موقعیت">
|
||||||
|
<IconButton color="primary" onClick={() => setOpenLocationDialog(true)}>
|
||||||
|
<ExploreIcon />
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
<Dialog
|
||||||
|
open={openLocationDialog}
|
||||||
|
onClose={() => setOpenLocationDialog(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"}
|
||||||
|
>
|
||||||
|
<DialogTitle>موقعیت</DialogTitle>
|
||||||
|
<LocationFormContent
|
||||||
|
start_lat={start_lat}
|
||||||
|
start_lng={start_lng}
|
||||||
|
setOpenLocationDialog={setOpenLocationDialog}
|
||||||
|
/>
|
||||||
|
</Dialog>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default LocationForm;
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import { Box } from "@mui/material";
|
||||||
|
|
||||||
|
const RowActions = ({ row, mutate }) => {
|
||||||
|
return <Box sx={{ display: "flex", gap: 1 }}></Box>;
|
||||||
|
};
|
||||||
|
export default RowActions;
|
||||||
13
src/components/dashboard/fastReact/operator/Toolbar.jsx
Normal file
13
src/components/dashboard/fastReact/operator/Toolbar.jsx
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import PrintExcel from "./ExcelPrint";
|
||||||
|
import ComplaintList from "../complaintList";
|
||||||
|
import { Stack } from "@mui/material";
|
||||||
|
|
||||||
|
const Toolbar = ({ table, filterData, mutate }) => {
|
||||||
|
return (
|
||||||
|
<Stack direction={"row"} spacing={2}>
|
||||||
|
<PrintExcel table={table} filterData={filterData} />
|
||||||
|
<ComplaintList mutate={mutate} />
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default Toolbar;
|
||||||
15
src/components/dashboard/fastReact/operator/index.jsx
Normal file
15
src/components/dashboard/fastReact/operator/index.jsx
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
"use client";
|
||||||
|
import PageTitle from "@/core/components/PageTitle";
|
||||||
|
import { Stack } from "@mui/material";
|
||||||
|
import SupervisorList from "./OperatorList";
|
||||||
|
import OperatorList from "./OperatorList";
|
||||||
|
|
||||||
|
const OperatorPage = () => {
|
||||||
|
return (
|
||||||
|
<Stack spacing={1}>
|
||||||
|
<PageTitle title={"ارزیابی"} />
|
||||||
|
<OperatorList />
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default OperatorPage;
|
||||||
@@ -1,20 +1,20 @@
|
|||||||
import {Box} from "@mui/material";
|
import { Box } from "@mui/material";
|
||||||
import ConfirmForm from "./ConfirmDialog";
|
import ConfirmForm from "./ConfirmDialog";
|
||||||
import RejectForm from "./RejectDialog";
|
import RejectForm from "./RejectDialog";
|
||||||
import {usePermissions} from "@/lib/hooks/usePermissions";
|
import { usePermissions } from "@/lib/hooks/usePermissions";
|
||||||
|
|
||||||
const RowActions = ({row, mutate}) => {
|
const RowActions = ({ row, mutate }) => {
|
||||||
const {data: userPermissions} = usePermissions();
|
const { data: userPermissions } = usePermissions();
|
||||||
const hasSupervisePermission = userPermissions.some((item) =>
|
const hasSupervisePermission = userPermissions.some((item) =>
|
||||||
["supervise-fast-react", "supervise-fast-react-province"].includes(item)
|
["supervise-fast-react", "supervise-fast-react-province"].includes(item)
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<Box sx={{display: "flex", gap: 1}}>
|
<Box sx={{ display: "flex", gap: 1 }}>
|
||||||
{hasSupervisePermission && row.original?.status === 0 && (
|
{hasSupervisePermission && row.original?.status === 0 && (
|
||||||
<ConfirmForm rowId={row.getValue("id")} mutate={mutate}/>
|
<ConfirmForm rowId={row.getValue("id")} mutate={mutate} />
|
||||||
)}
|
)}
|
||||||
{hasSupervisePermission && row.original?.status === 0 &&(
|
{hasSupervisePermission && row.original?.status === 0 && (
|
||||||
<RejectForm rowId={row.getValue("id")} mutate={mutate}/>
|
<RejectForm rowId={row.getValue("id")} mutate={mutate} />
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -374,14 +374,6 @@ export const pageMenu = [
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: "roadObservationsManagmentList",
|
|
||||||
label: "رسیدگی به شکایات",
|
|
||||||
type: "page",
|
|
||||||
route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_observations",
|
|
||||||
icon: <AssignmentLateIcon sx={{ width: "inherit", height: "inherit" }} />,
|
|
||||||
permissions: ["show-fast-react", "show-fast-react-province", "show-fast-react-edarate-shahri"],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: "roadObservationsManagmentOparation",
|
id: "roadObservationsManagmentOparation",
|
||||||
label: "عملیات",
|
label: "عملیات",
|
||||||
@@ -394,8 +386,8 @@ export const pageMenu = [
|
|||||||
id: "roadObservationsManagmentOparationCartable",
|
id: "roadObservationsManagmentOparationCartable",
|
||||||
label: "کارتابل",
|
label: "کارتابل",
|
||||||
type: "page",
|
type: "page",
|
||||||
route: process.env.NEXT_PUBLIC_API_URL + "/v2/road_observations/operator/cartable",
|
route: "/dashboard/fast-react/operator",
|
||||||
permissions: ["show-fast-react", "show-fast-react-province", "show-fast-react-edarate-shahri"],
|
permissions: ["show-fast-react-edarate-shahri"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -116,3 +116,5 @@ export const GET_FAST_REACT_SUPERVISOR = api + "/api/v3/road_observations/superv
|
|||||||
export const GET_FAST_REACT_COMPLAINTS = api + "/api/v3/road_observations/complaints_index";
|
export const GET_FAST_REACT_COMPLAINTS = api + "/api/v3/road_observations/complaints_index";
|
||||||
export const VERIFY_BY_FAST_REACT_SUPERVISOR = api + "/api/v3/road_observations/verify";
|
export const VERIFY_BY_FAST_REACT_SUPERVISOR = api + "/api/v3/road_observations/verify";
|
||||||
export const REJECT_BY_FAST_REACT_SUPERVISOR = api + "/api/v3/road_observations/verify";
|
export const REJECT_BY_FAST_REACT_SUPERVISOR = api + "/api/v3/road_observations/verify";
|
||||||
|
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";
|
||||||
|
|||||||
Reference in New Issue
Block a user