From 7db4268c761251a3dfee34cc80c60ea1383803c9 Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Wed, 27 Aug 2025 08:12:37 +0000 Subject: [PATCH 1/2] Feature/amiriis report road safety --- .../dashboard/road-safety/operator/page.js | 2 +- .../road-safety/reports/access-road/page.js | 19 + .../reports/construction-activity/page.js | 19 + .../reports/utility-passing-activity/page.js | 19 + .../dashboard/road-safety/supervisor/page.js | 2 +- .../roadSafety/operator/OperatorList.jsx | 6 +- .../reports/accessRoad/ExcelPrint/index.jsx | 72 ++ .../ReportLists.jsx | 767 +++++++++++------- .../{reportPage => accessRoad}/Toolbar.jsx | 22 +- .../{reportPage => accessRoad}/index.jsx | 471 +++++------ .../ExcelPrint/index.jsx | 137 ++-- .../constructionActivity/ReportLists.jsx | 463 +++++++++++ .../reports/constructionActivity/Toolbar.jsx | 11 + .../reports/constructionActivity/index.jsx | 207 +++++ .../DialogInfoItem/ContentInfoItem.jsx | 2 +- .../reportPage/Search/FromDateController.jsx | 28 - .../reportPage/Search/SearchReportField.jsx | 49 -- .../reportPage/Search/SelectAxisType.jsx | 45 - .../reportPage/Search/SelectProvince.jsx | 45 - .../reportPage/Search/ToDateController.jsx | 30 - .../reports/reportPage/Search/index.jsx | 13 - .../ExcelPrint/index.jsx | 70 ++ .../utilityPassingActivity/ReportLists.jsx | 463 +++++++++++ .../utilityPassingActivity/Toolbar.jsx | 11 + .../reports/utilityPassingActivity/index.jsx | 207 +++++ .../roadSafety/supervisor/SupervisorList.jsx | 10 +- src/core/components/Toasts/error.jsx | 22 +- src/core/utils/groupByEdareAxisStep.js | 12 + src/core/utils/groupByProvinceAxisStep.js | 12 + src/core/utils/pageMenuDev.js | 42 +- src/core/utils/routes.js | 31 +- 31 files changed, 2421 insertions(+), 888 deletions(-) create mode 100644 src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/access-road/page.js create mode 100644 src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/construction-activity/page.js create mode 100644 src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/utility-passing-activity/page.js create mode 100644 src/components/dashboard/roadSafety/reports/accessRoad/ExcelPrint/index.jsx rename src/components/dashboard/roadSafety/reports/{reportPage => accessRoad}/ReportLists.jsx (54%) rename src/components/dashboard/roadSafety/reports/{reportPage => accessRoad}/Toolbar.jsx (96%) rename src/components/dashboard/roadSafety/reports/{reportPage => accessRoad}/index.jsx (60%) rename src/components/dashboard/roadSafety/reports/{reportPage => constructionActivity}/ExcelPrint/index.jsx (81%) create mode 100644 src/components/dashboard/roadSafety/reports/constructionActivity/ReportLists.jsx create mode 100644 src/components/dashboard/roadSafety/reports/constructionActivity/Toolbar.jsx create mode 100644 src/components/dashboard/roadSafety/reports/constructionActivity/index.jsx delete mode 100644 src/components/dashboard/roadSafety/reports/reportPage/Search/FromDateController.jsx delete mode 100644 src/components/dashboard/roadSafety/reports/reportPage/Search/SearchReportField.jsx delete mode 100644 src/components/dashboard/roadSafety/reports/reportPage/Search/SelectAxisType.jsx delete mode 100644 src/components/dashboard/roadSafety/reports/reportPage/Search/SelectProvince.jsx delete mode 100644 src/components/dashboard/roadSafety/reports/reportPage/Search/ToDateController.jsx delete mode 100644 src/components/dashboard/roadSafety/reports/reportPage/Search/index.jsx create mode 100644 src/components/dashboard/roadSafety/reports/utilityPassingActivity/ExcelPrint/index.jsx create mode 100644 src/components/dashboard/roadSafety/reports/utilityPassingActivity/ReportLists.jsx create mode 100644 src/components/dashboard/roadSafety/reports/utilityPassingActivity/Toolbar.jsx create mode 100644 src/components/dashboard/roadSafety/reports/utilityPassingActivity/index.jsx create mode 100644 src/core/utils/groupByEdareAxisStep.js create mode 100644 src/core/utils/groupByProvinceAxisStep.js diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/operator/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/operator/page.js index 49ec925..a71e098 100644 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/operator/page.js +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/operator/page.js @@ -2,7 +2,7 @@ import WithPermission from "@/core/middlewares/withPermission"; import OperatorPage from "@/components/dashboard/roadSafety/operator"; // import ActivityCodeLog from "@/core/components/ActivityCodeLog"; export const metadata = { - title: "کارتابل عملیات نگهداری حریم", + title: "کارتابل عملیات نگهداری حریم راه", }; const Page = () => { return ( diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/access-road/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/access-road/page.js new file mode 100644 index 0000000..8de26fd --- /dev/null +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/access-road/page.js @@ -0,0 +1,19 @@ +import ReportAccessRoadPage from "@/components/dashboard/roadSafety/reports/accessRoad"; +import WithPermission from "@/core/middlewares/withPermission"; +export const metadata = { + title: "گزارش بر اساس راه دسترسی غیر مجاز", +}; +const Page = () => { + return ( + + + + ); +}; +export default Page; diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/construction-activity/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/construction-activity/page.js new file mode 100644 index 0000000..8f8ffbe --- /dev/null +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/construction-activity/page.js @@ -0,0 +1,19 @@ +import ReportConstructionActivityPage from "@/components/dashboard/roadSafety/reports/constructionActivity"; +import WithPermission from "@/core/middlewares/withPermission"; +export const metadata = { + title: "گزارش بر اساس ساخت و ساز غیر مجاز", +}; +const Page = () => { + return ( + + + + ); +}; +export default Page; diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/utility-passing-activity/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/utility-passing-activity/page.js new file mode 100644 index 0000000..096a8dc --- /dev/null +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/reports/utility-passing-activity/page.js @@ -0,0 +1,19 @@ +import ReportUtilityPassingActivityPage from "@/components/dashboard/roadSafety/reports/utilityPassingActivity"; +import WithPermission from "@/core/middlewares/withPermission"; +export const metadata = { + title: "گزارش بر اساس عبور تاسیسات زیربنایی غیر مجاز", +}; +const Page = () => { + return ( + + + + ); +}; +export default Page; diff --git a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/supervisor/page.js b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/supervisor/page.js index 590d405..f66ac18 100644 --- a/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/supervisor/page.js +++ b/src/app/(withAuth)/(dashboardLayout)/dashboard/road-safety/supervisor/page.js @@ -2,7 +2,7 @@ import SupervisorPage from "@/components/dashboard/roadSafety/supervisor"; import WithPermission from "@/core/middlewares/withPermission"; // import ActivityCodeLog from "@/core/components/ActivityCodeLog"; export const metadata = { - title: "کارتابل ارزیابی نگهداری حریم", + title: "کارتابل ارزیابی نگهداری حریم راه", }; const Page = () => { return ( diff --git a/src/components/dashboard/roadSafety/operator/OperatorList.jsx b/src/components/dashboard/roadSafety/operator/OperatorList.jsx index ff90466..f014fae 100644 --- a/src/components/dashboard/roadSafety/operator/OperatorList.jsx +++ b/src/components/dashboard/roadSafety/operator/OperatorList.jsx @@ -206,8 +206,8 @@ const OperatorList = () => { {row.original.is_finished == 1 ? "خاتمه یافته" : row.original.is_finished == 0 - ? "در جریان" - : "-"} + ? "در جریان" + : "-"} ), }, @@ -369,7 +369,7 @@ const OperatorList = () => { return ( {row.original.judiciary_document_upload_date !== "0000-00-00 00:00:00" && - row.original.judiciary_document_upload_date ? ( + row.original.judiciary_document_upload_date ? ( ) : ( <>- diff --git a/src/components/dashboard/roadSafety/reports/accessRoad/ExcelPrint/index.jsx b/src/components/dashboard/roadSafety/reports/accessRoad/ExcelPrint/index.jsx new file mode 100644 index 0000000..ada0e8c --- /dev/null +++ b/src/components/dashboard/roadSafety/reports/accessRoad/ExcelPrint/index.jsx @@ -0,0 +1,72 @@ +"use client"; +import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure"; +import isArrayEmpty from "@/core/utils/isArrayEmpty"; +import { + EXPORT_COUNTRY_ROAD_SAFETY_REPORT, + EXPORT_PROVINCE_ROAD_SAFETY_REPORT, + EXPORT_ROAD_SAFETY_CITY_ACTIVITY_ACCESS_ROAD_REPORT, + EXPORT_ROAD_SAFETY_PROVINCE_ACTIVITY_ACCESS_ROAD_REPORTT, +} from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { useTheme } from "@emotion/react"; +import DescriptionIcon from "@mui/icons-material/Description"; +import { Button, CircularProgress, IconButton, useMediaQuery } from "@mui/material"; +import FileSaver from "file-saver"; +import moment from "jalali-moment"; +import { useState } from "react"; + +const PrintExcel = ({ table, filterData }) => { + const theme = useTheme(); + const isMobile = useMediaQuery(theme.breakpoints.down("sm")); + const [loading, setLoading] = useState(false); + const requestServer = useRequest({ notificationSuccess: true }); + + const clickHandler = () => { + setLoading(true); + const filters = DataTableFilterDataStructure(filterData, isArrayEmpty); + const filterParams = new URLSearchParams(); + let requestUrl; + filterParams.set("filters", JSON.stringify(filters || [])); + if (filterData.province_id.value === "") { + requestUrl = EXPORT_ROAD_SAFETY_PROVINCE_ACTIVITY_ACCESS_ROAD_REPORTT; + } else { + filterParams.set("province_id", filterData.province_id.value); + requestUrl = EXPORT_ROAD_SAFETY_CITY_ACTIVITY_ACCESS_ROAD_REPORT; + } + + requestServer(`${requestUrl}?${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 ? ( + + + + ) : ( + + )} + + ); +}; +export default PrintExcel; diff --git a/src/components/dashboard/roadSafety/reports/reportPage/ReportLists.jsx b/src/components/dashboard/roadSafety/reports/accessRoad/ReportLists.jsx similarity index 54% rename from src/components/dashboard/roadSafety/reports/reportPage/ReportLists.jsx rename to src/components/dashboard/roadSafety/reports/accessRoad/ReportLists.jsx index e406ea5..c5de8fd 100644 --- a/src/components/dashboard/roadSafety/reports/reportPage/ReportLists.jsx +++ b/src/components/dashboard/roadSafety/reports/accessRoad/ReportLists.jsx @@ -1,304 +1,463 @@ -"use client"; -import DataTableWithAuth from "@/core/components/DataTableWithAuth"; -import { Box } from "@mui/material"; -import { useMemo } from "react"; -import Toolbar from "./Toolbar"; - -const ReportLists = ({ data, filterData, setFilterData, isLoading }) => { - const columns = useMemo(() => { - return [ - { - accessorKey: "edare_name", - header: "اداره کل", - id: "edare_name", - enableColumnFilter: false, - enableSorting: false, - datatype: "text", - grow: false, - size: 50, - }, - - { - accessorKey: "sum", - header: "تعداد کل", - id: "sum", - enableColumnFilter: false, - enableSorting: false, - datatype: "text", - grow: false, - size: 50, - muiTableBodyCellProps: { - sx: { - textAlign: "center", - borderLeft: "1px solid #e1e1e1", - py: 0, - "&:first-of-type": { - borderLeft: "unset", - }, - }, - }, - Cell: ({ renderedCellValue }) => { - return (renderedCellValue / 1).toLocaleString(); - }, - }, - { - header: "ساخت و ساز غیر مجاز", - enableColumnFilter: false, - enableSorting: false, - datatype: "text", - id: "id_89", - grow: false, - size: 50, - columns: [ - { - accessorFn: (row) => (row["89"] ? row["89"]["1"] : 0), - header: "گام اول (شناسایی)", - id: "id_89.1", - enableColumnFilter: false, - enableSorting: false, - datatype: "text", - grow: false, - size: 50, - muiTableBodyCellProps: { - sx: { - textAlign: "center", - borderLeft: "1px solid #e1e1e1", - py: 0, - "&:first-of-type": { - borderLeft: "unset", - }, - }, - }, - Cell: ({ renderedCellValue }) => { - return (renderedCellValue / 1).toLocaleString(); - }, - }, - { - accessorFn: (row) => (row["89"] ? row["89"]["2"] : 0), - header: "گام دوم (مستندات قضایی)", - id: "id_89.2", - enableColumnFilter: false, - enableSorting: false, - datatype: "text", - grow: false, - size: 50, - muiTableBodyCellProps: { - sx: { - textAlign: "center", - borderLeft: "1px solid #e1e1e1", - py: 0, - "&:first-of-type": { - borderLeft: "unset", - }, - }, - }, - Cell: ({ renderedCellValue }) => { - return (renderedCellValue / 1).toLocaleString(); - }, - }, - { - accessorFn: (row) => (row["89"] ? row["89"]["3"] : 0), - header: "گام سوم (برخورد)", - id: "id_89.3", - enableColumnFilter: false, - enableSorting: false, - datatype: "text", - grow: false, - size: 50, - muiTableBodyCellProps: { - sx: { - textAlign: "center", - borderLeft: "1px solid #e1e1e1", - py: 0, - "&:first-of-type": { - borderLeft: "unset", - }, - }, - }, - Cell: ({ renderedCellValue }) => { - return (renderedCellValue / 1).toLocaleString(); - }, - }, - ], - }, - { - header: "راه دسترسی غیر مجاز", - enableColumnFilter: false, - enableSorting: false, - datatype: "text", - id: "id_90", - grow: false, - size: 50, - columns: [ - { - accessorFn: (row) => (row["90"] ? row["90"]["1"] : 0), - header: "گام اول (شناسایی)", - id: "id_90.1", - enableColumnFilter: false, - enableSorting: false, - datatype: "text", - grow: false, - size: 50, - muiTableBodyCellProps: { - sx: { - textAlign: "center", - borderLeft: "1px solid #e1e1e1", - py: 0, - "&:first-of-type": { - borderLeft: "unset", - }, - }, - }, - Cell: ({ renderedCellValue }) => { - return (renderedCellValue / 1).toLocaleString(); - }, - }, - { - accessorFn: (row) => (row["90"] ? row["90"]["2"] : 0), - header: "گام دوم (مستندات قضایی)", - id: "id_90.2", - enableColumnFilter: false, - enableSorting: false, - datatype: "text", - grow: false, - size: 50, - muiTableBodyCellProps: { - sx: { - textAlign: "center", - borderLeft: "1px solid #e1e1e1", - py: 0, - "&:first-of-type": { - borderLeft: "unset", - }, - }, - }, - Cell: ({ renderedCellValue }) => { - return (renderedCellValue / 1).toLocaleString(); - }, - }, - { - accessorFn: (row) => (row["90"] ? row["90"]["3"] : 0), - header: "گام سوم (برخورد)", - id: "id_90.3", - enableColumnFilter: false, - enableSorting: false, - datatype: "text", - grow: false, - size: 50, - muiTableBodyCellProps: { - sx: { - textAlign: "center", - borderLeft: "1px solid #e1e1e1", - py: 0, - "&:first-of-type": { - borderLeft: "unset", - }, - }, - }, - Cell: ({ renderedCellValue }) => { - return (renderedCellValue / 1).toLocaleString(); - }, - }, - ], - }, - { - header: "عبور تاسیسات زیربنایی غیر مجاز", - enableColumnFilter: false, - enableSorting: false, - datatype: "text", - id: "id_91", - grow: false, - size: 50, - columns: [ - { - accessorFn: (row) => (row["91"] ? row["91"]["1"] : 0), - header: "گام اول (شناسایی)", - id: "id_91.1", - enableColumnFilter: false, - enableSorting: false, - datatype: "text", - grow: false, - size: 50, - muiTableBodyCellProps: { - sx: { - textAlign: "center", - borderLeft: "1px solid #e1e1e1", - py: 0, - "&:first-of-type": { - borderLeft: "unset", - }, - }, - }, - Cell: ({ renderedCellValue }) => { - return (renderedCellValue / 1).toLocaleString(); - }, - }, - { - accessorFn: (row) => (row["91"] ? row["91"]["2"] : 0), - header: "گام دوم (مستندات قضایی)", - id: "id_91.2", - enableColumnFilter: false, - enableSorting: false, - datatype: "text", - grow: false, - size: 50, - muiTableBodyCellProps: { - sx: { - textAlign: "center", - borderLeft: "1px solid #e1e1e1", - py: 0, - "&:first-of-type": { - borderLeft: "unset", - }, - }, - }, - Cell: ({ renderedCellValue }) => { - return (renderedCellValue / 1).toLocaleString(); - }, - }, - { - accessorFn: (row) => (row["91"] ? row["91"]["3"] : 0), - header: "گام سوم (برخورد)", - id: "id_91.3", - enableColumnFilter: false, - enableSorting: false, - datatype: "text", - grow: false, - size: 50, - muiTableBodyCellProps: { - sx: { - textAlign: "center", - borderLeft: "1px solid #e1e1e1", - py: 0, - "&:first-of-type": { - borderLeft: "unset", - }, - }, - }, - Cell: ({ renderedCellValue }) => { - return (renderedCellValue / 1).toLocaleString(); - }, - }, - ], - }, - ]; - }, []); - - return ( - - - - ); -}; - -export default ReportLists; +"use client"; +import DataTableWithAuth from "@/core/components/DataTableWithAuth"; +import { Box } from "@mui/material"; +import { useMemo } from "react"; +import Toolbar from "./Toolbar"; + +const ReportLists = ({ data, filterData, setFilterData, isLoading }) => { + const columns = useMemo(() => { + return [ + { + accessorKey: "edare_name", + header: "اداره کل", + id: "edare_name", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + }, + { + accessorFn: (row) => (row["1"] ? row["1"].total_sum : 0), + header: "تعداد کل", + id: "sum", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + header: "آزادراه", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + id: "id_1", + grow: false, + size: 50, + columns: [ + { + accessorFn: (row) => (row["1"] ? row["1"].s1 : 0), + header: "گام اول", + id: "id_1.1", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["1"] ? row["1"].s2 : 0), + header: "گام دوم", + id: "id_1.2", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["1"] ? row["1"].s3 : 0), + header: "گام سوم", + id: "id_1.3", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + ], + }, + { + header: "بزرگراه", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + id: "id_2", + grow: false, + size: 50, + columns: [ + { + accessorFn: (row) => (row["2"] ? row["2"].s1 : 0), + header: "گام اول", + id: "id_2.1", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["2"] ? row["2"].s2 : 0), + header: "گام دوم", + id: "id_2.2", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["2"] ? row["2"].s3 : 0), + header: "گام سوم", + id: "id_2.3", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + ], + }, + { + header: "اصلی", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + id: "id_3", + grow: false, + size: 50, + columns: [ + { + accessorFn: (row) => (row["3"] ? row["3"].s1 : 0), + header: "گام اول", + id: "id_3.1", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["3"] ? row["3"].s2 : 0), + header: "گام دوم", + id: "id_3.2", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["3"] ? row["3"].s3 : 0), + header: "گام سوم", + id: "id_3.3", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + ], + }, + { + header: "فرعی", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + id: "id_4", + grow: false, + size: 50, + columns: [ + { + accessorFn: (row) => (row["4"] ? row["4"].s1 : 0), + header: "گام اول", + id: "id_4.1", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["4"] ? row["4"].s2 : 0), + header: "گام دوم", + id: "id_4.2", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["4"] ? row["4"].s3 : 0), + header: "گام سوم", + id: "id_4.3", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + ], + }, + { + header: "روستایی", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + id: "id_5", + grow: false, + size: 50, + columns: [ + { + accessorFn: (row) => (row["5"] ? row["5"].s1 : 0), + header: "گام اول", + id: "id_5.1", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["5"] ? row["5"].s2 : 0), + header: "گام دوم", + id: "id_5.2", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["5"] ? row["5"].s3 : 0), + header: "گام سوم", + id: "id_5.3", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + ], + }, + ]; + }, []); + + return ( + + + + ); +}; + +export default ReportLists; diff --git a/src/components/dashboard/roadSafety/reports/reportPage/Toolbar.jsx b/src/components/dashboard/roadSafety/reports/accessRoad/Toolbar.jsx similarity index 96% rename from src/components/dashboard/roadSafety/reports/reportPage/Toolbar.jsx rename to src/components/dashboard/roadSafety/reports/accessRoad/Toolbar.jsx index 3e5ab8c..7dd930f 100644 --- a/src/components/dashboard/roadSafety/reports/reportPage/Toolbar.jsx +++ b/src/components/dashboard/roadSafety/reports/accessRoad/Toolbar.jsx @@ -1,11 +1,11 @@ -import PrintExcel from "./ExcelPrint"; -import { Box } from "@mui/material"; - -const Toolbar = ({ table, filterData, mutate }) => { - return ( - - - - ); -}; -export default Toolbar; +import PrintExcel from "./ExcelPrint"; +import { Box } from "@mui/material"; + +const Toolbar = ({ table, filterData, mutate }) => { + return ( + + + + ); +}; +export default Toolbar; diff --git a/src/components/dashboard/roadSafety/reports/reportPage/index.jsx b/src/components/dashboard/roadSafety/reports/accessRoad/index.jsx similarity index 60% rename from src/components/dashboard/roadSafety/reports/reportPage/index.jsx rename to src/components/dashboard/roadSafety/reports/accessRoad/index.jsx index 5d7a2cd..f80b82c 100644 --- a/src/components/dashboard/roadSafety/reports/reportPage/index.jsx +++ b/src/components/dashboard/roadSafety/reports/accessRoad/index.jsx @@ -1,264 +1,207 @@ -"use client"; -import CustomSelectByDependency from "@/core/components/FilterDrawer/fieldsType/CustomSelectByDependency"; -import PageTitle from "@/core/components/PageTitle"; -import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure"; -import isArrayEmpty from "@/core/utils/isArrayEmpty"; -import { GET_ROAD_SAFETY_CITY_ACTIVITY_REPORT, GET_ROAD_SAFETY_PROVINCE_ACTIVITY_REPORT } from "@/core/utils/routes"; -import { useAuth } from "@/lib/contexts/auth"; -import { usePermissions } from "@/lib/hooks/usePermissions"; -import useProvinces from "@/lib/hooks/useProvince"; -import useRequest from "@/lib/hooks/useRequest"; -import useSafetyAndPrivacyGetItems from "@/lib/hooks/useSafetyAndPrivacyGetItems"; -import { LinearProgress, Stack } from "@mui/material"; -import { useEffect, useMemo, useState } from "react"; -import ReportLists from "./ReportLists"; - -const statusOptions = [ - { value: "", label: "همه وضعیت ها" }, - { value: 1, label: "گام اول (شناسایی)" }, - { value: 2, label: "گام دوم (مستندات قضایی)" }, - { value: 3, label: "گام سوم (برخورد)" }, -]; -const axisOptions = [ - { value: "", label: "همه محور ها" }, - { value: 1, label: "آزادراه" }, - { value: 2, label: "بزرگراه" }, - { value: 3, label: "اصلی" }, - { value: 4, label: "فرعی" }, - { value: 5, label: "روستایی" }, -]; - -const ReportPage = () => { - const { data: userPermissions } = usePermissions(); - const hasProvincesPermission = userPermissions.includes("show-safety-and-privacy-operator-cartable"); - const { user } = useAuth(); - const requestServer = useRequest(); - const [data, setData] = useState(null); - const [isLoading, setLoading] = useState(true); - const defaultValues = useMemo( - () => [ - { - header: "استان", - id: "province_id", - filterMode: "equals", - datatype: "numeric", - value: hasProvincesPermission ? "" : user.province_id, - enable: hasProvincesPermission, - SelectComponent: (props) => { - const { provinces, errorProvinces, loadingProvinces } = useProvinces(); - const getSelectOptions = useMemo(() => { - if (loadingProvinces) { - return [{ value: "loading", label: "در حال بارگذاری..." }]; - } - if (errorProvinces) { - return [{ value: "error", label: "خطا در بارگذاری" }]; - } - return [ - { value: "", label: "کل کشور" }, - ...provinces.map((province) => ({ - value: province.id, - label: province.name_fa, - })), - ]; - }, [provinces, errorProvinces, loadingProvinces]); - return ( - - ); - }, - }, - { - header: "مورد مشاهده شده", - id: "info_id", - filterMode: "equals", - datatype: "numeric", - value: "", - enable: true, - SelectComponent: (props) => { - const { itemsList, loadingItemsList, errorItemsList } = useSafetyAndPrivacyGetItems(); - - const getSelectOptions = useMemo(() => { - if (loadingItemsList) { - return [{ value: "loading", label: "در حال بارگذاری..." }]; - } - if (errorItemsList) { - return [{ value: "error", label: "خطا در بارگذاری" }]; - } - return [ - { value: "", label: "همه موارد" }, - ...itemsList.map((item) => ({ - value: item.id, - label: item.name, - })), - ]; - }, [itemsList, loadingItemsList, errorItemsList]); - - return ( - - ); - }, - }, - { - header: "نوع محور", - id: "axis_type_id", - filterMode: "equals", - datatype: "numeric", - value: "", - enable: true, - selectOption: () => { - return axisOptions.map((status) => ({ - value: status.value, - label: status.label, - })); - }, - }, - { - header: "وضعیت", - id: "step", - filterMode: "equals", - datatype: "numeric", - value: "", - enable: true, - selectOption: () => { - return statusOptions.map((status) => ({ - value: status.value, - label: status.label, - })); - }, - }, - { - header: "تاریخ ثبت", - id: "created_at", - filterMode: "between", - datatype: "date", - value: ["", ""], - enable: true, - }, - { - header: "تاریخ بازدید", - id: "activity_date_time", - filterMode: "between", - datatype: "date", - value: ["", ""], - enable: true, - }, - { - header: "تاریخ بارگذاری مستندات", - id: "judiciary_document_upload_date", - filterMode: "between", - datatype: "date", - value: ["", ""], - enable: true, - }, - { - header: "تاریخ اقدام", - id: "action_date", - filterMode: "between", - datatype: "date", - value: ["", ""], - enable: true, - }, - ], - [hasProvincesPermission, user.province_id] - ); - - const [filterData, setFilterData] = useState( - defaultValues.reduce((acc, item) => { - acc[item.id] = item; - return acc; - }, {}) - ); - - useEffect(() => { - const fetchData = async () => { - try { - setLoading(true); - const filters = DataTableFilterDataStructure(filterData, isArrayEmpty); - const params = new URLSearchParams(); - params.set("filters", JSON.stringify(filters || [])); - if (filterData.province_id.value === "") { - try { - const response = await requestServer( - `${GET_ROAD_SAFETY_PROVINCE_ACTIVITY_REPORT}?${params.toString()}` - ); - const result = response.data.data; - const nationalReportForItem = result.activities.find((report) => report.province_id === -1); - const nationalReport = { - edare_name: "کل کشور", - ...nationalReportForItem, - }; - - setData([ - nationalReport, - ...result.provinces.map((province) => { - const filteredReports = result.activities.find( - (report) => report.province_id === province.id - ); - return { - ...filteredReports, - edare_name: province.name_fa, - }; - }), - ]); - } catch (e) { - console.log(e); - } - } else { - params.set("province_id", filterData.province_id.value); - try { - const response = await requestServer( - `${GET_ROAD_SAFETY_CITY_ACTIVITY_REPORT}?${params.toString()}` - ); - const result = response.data.data; - const nationalReportForItem = result.activities.find( - (report) => report.edare_shahri_id == "-1" - ); - const nationalReport = { - ...nationalReportForItem, - edare_name: "کل استان", - }; - setData([ - nationalReport, - ...result.edarateShahri.map((edare) => { - const filteredReports = result.activities.find( - (report) => report.edare_shahri_id == edare.id - ); - return { - edare_name: edare.name_fa, - ...filteredReports, - }; - }), - ]); - } catch (e) { - console.log(e); - } - } - } catch (error) { - console.log(error); - } finally { - setLoading(false); - } - }; - - fetchData(); - }, [filterData]); - - return ( - - - {!data ? ( - - ) : ( - - )} - - ); -}; -export default ReportPage; +"use client"; +import CustomSelectByDependency from "@/core/components/FilterDrawer/fieldsType/CustomSelectByDependency"; +import PageTitle from "@/core/components/PageTitle"; +import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure"; +import isArrayEmpty from "@/core/utils/isArrayEmpty"; +import { + GET_ROAD_SAFETY_CITY_ACTIVITY_ACCESS_ROAD_REPORT, + GET_ROAD_SAFETY_PROVINCE_ACTIVITY_ACCESS_ROAD_REPORT, +} from "@/core/utils/routes"; +import { useAuth } from "@/lib/contexts/auth"; +import { usePermissions } from "@/lib/hooks/usePermissions"; +import useProvinces from "@/lib/hooks/useProvince"; +import useRequest from "@/lib/hooks/useRequest"; +import { LinearProgress, Stack } from "@mui/material"; +import { useEffect, useMemo, useState } from "react"; +import ReportLists from "./ReportLists"; +import groupByProvinceAxisStep from "@/core/utils/groupByProvinceAxisStep"; +import groupByEdareAxisStep from "@/core/utils/groupByEdareAxisStep"; + +const ReportAccessRoadPage = () => { + const { data: userPermissions } = usePermissions(); + const hasProvincesPermission = userPermissions.includes("show-safety-and-privacy-operator-cartable"); + const { user } = useAuth(); + const requestServer = useRequest(); + const [data, setData] = useState(null); + const [isLoading, setLoading] = useState(true); + + const defaultValues = useMemo( + () => [ + { + header: "استان", + id: "province_id", + filterMode: "equals", + datatype: "numeric", + value: hasProvincesPermission ? "" : user.province_id, + enable: hasProvincesPermission, + SelectComponent: (props) => { + const { provinces, errorProvinces, loadingProvinces } = useProvinces(); + const getSelectOptions = useMemo(() => { + if (loadingProvinces) { + return [{ value: "loading", label: "در حال بارگذاری..." }]; + } + if (errorProvinces) { + return [{ value: "error", label: "خطا در بارگذاری" }]; + } + return [ + { value: "", label: "کل کشور" }, + ...provinces.map((province) => ({ + value: province.id, + label: province.name_fa, + })), + ]; + }, [provinces, errorProvinces, loadingProvinces]); + return ( + + ); + }, + }, + { + header: "مورد", + id: "info_id", + filterMode: "equals", + datatype: "numeric", + value: "90", + enable: false, + }, + { + header: "تاریخ ثبت", + id: "created_at", + filterMode: "between", + datatype: "date", + value: ["", ""], + enable: true, + }, + { + header: "تاریخ بازدید", + id: "activity_date_time", + filterMode: "between", + datatype: "date", + value: ["", ""], + enable: true, + }, + { + header: "تاریخ بارگذاری مستندات", + id: "judiciary_document_upload_date", + filterMode: "between", + datatype: "date", + value: ["", ""], + enable: true, + }, + { + header: "تاریخ اقدام", + id: "action_date", + filterMode: "between", + datatype: "date", + value: ["", ""], + enable: true, + }, + ], + [hasProvincesPermission, user.province_id] + ); + + const [filterData, setFilterData] = useState( + defaultValues.reduce((acc, item) => { + acc[item.id] = item; + return acc; + }, {}) + ); + + useEffect(() => { + const fetchData = async () => { + try { + setLoading(true); + const filters = DataTableFilterDataStructure(filterData, isArrayEmpty); + const params = new URLSearchParams(); + params.set("filters", JSON.stringify(filters || [])); + if (filterData.province_id.value === "") { + try { + const response = await requestServer( + `${GET_ROAD_SAFETY_PROVINCE_ACTIVITY_ACCESS_ROAD_REPORT}?${params.toString()}` + ); + + const result = response.data.data; + const grouped = groupByProvinceAxisStep(result.activities); + + const nationalReportForItem = grouped[-1]; + const nationalReport = { + edare_name: "کل کشور", + ...nationalReportForItem, + }; + + setData([ + nationalReport, + ...result.provinces.map((province) => { + const filteredReports = grouped[province.id]; + return { + ...filteredReports, + edare_name: province.name_fa, + }; + }), + ]); + } catch (e) { + console.log(e); + } + } else { + params.set("province_id", filterData.province_id.value); + try { + const response = await requestServer( + `${GET_ROAD_SAFETY_CITY_ACTIVITY_ACCESS_ROAD_REPORT}?${params.toString()}` + ); + const result = response.data.data; + const grouped = groupByEdareAxisStep(result.activities); + + const nationalReportForItem = grouped[-1]; + const nationalReport = { + ...nationalReportForItem, + edare_name: "کل استان", + }; + setData([ + nationalReport, + ...result.edarateShahri.map((edare) => { + const filteredReports = grouped[edare.id]; + return { + edare_name: edare.name_fa, + ...filteredReports, + }; + }), + ]); + } catch (e) { + console.log(e); + } + } + } catch (error) { + console.log(error); + } finally { + setLoading(false); + } + }; + + fetchData(); + }, [filterData]); + + console.log(data); + + return ( + + + {!data ? ( + + ) : ( + <> + + + )} + + ); +}; +export default ReportAccessRoadPage; diff --git a/src/components/dashboard/roadSafety/reports/reportPage/ExcelPrint/index.jsx b/src/components/dashboard/roadSafety/reports/constructionActivity/ExcelPrint/index.jsx similarity index 81% rename from src/components/dashboard/roadSafety/reports/reportPage/ExcelPrint/index.jsx rename to src/components/dashboard/roadSafety/reports/constructionActivity/ExcelPrint/index.jsx index a924431..8c13897 100644 --- a/src/components/dashboard/roadSafety/reports/reportPage/ExcelPrint/index.jsx +++ b/src/components/dashboard/roadSafety/reports/constructionActivity/ExcelPrint/index.jsx @@ -1,67 +1,70 @@ -"use client"; -import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure"; -import isArrayEmpty from "@/core/utils/isArrayEmpty"; -import { EXPORT_COUNTRY_ROAD_SAFETY_REPORT, EXPORT_PROVINCE_ROAD_SAFETY_REPORT } from "@/core/utils/routes"; -import useRequest from "@/lib/hooks/useRequest"; -import { useTheme } from "@emotion/react"; -import DescriptionIcon from "@mui/icons-material/Description"; -import { Button, CircularProgress, IconButton, useMediaQuery } from "@mui/material"; -import FileSaver from "file-saver"; -import moment from "jalali-moment"; -import { useState } from "react"; - -const PrintExcel = ({ table, filterData }) => { - const theme = useTheme(); - const isMobile = useMediaQuery(theme.breakpoints.down("sm")); - const [loading, setLoading] = useState(false); - const requestServer = useRequest({ notificationSuccess: true }); - - const clickHandler = () => { - setLoading(true); - const filters = DataTableFilterDataStructure(filterData, isArrayEmpty); - const filterParams = new URLSearchParams(); - let requestUrl; - filterParams.set("filters", JSON.stringify(filters || [])); - if (filterData.province_id.value === "") { - requestUrl = EXPORT_COUNTRY_ROAD_SAFETY_REPORT; - } else { - filterParams.set("province_id", filterData.province_id.value); - requestUrl = EXPORT_PROVINCE_ROAD_SAFETY_REPORT; - } - - requestServer(`${requestUrl}?${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 ? ( - - - - ) : ( - - )} - - ); -}; -export default PrintExcel; +"use client"; +import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure"; +import isArrayEmpty from "@/core/utils/isArrayEmpty"; +import { + EXPORT_ROAD_SAFETY_CITY_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORT, + EXPORT_ROAD_SAFETY_PROVINCE_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORTT, +} from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { useTheme } from "@emotion/react"; +import DescriptionIcon from "@mui/icons-material/Description"; +import { Button, CircularProgress, IconButton, useMediaQuery } from "@mui/material"; +import FileSaver from "file-saver"; +import moment from "jalali-moment"; +import { useState } from "react"; + +const PrintExcel = ({ table, filterData }) => { + const theme = useTheme(); + const isMobile = useMediaQuery(theme.breakpoints.down("sm")); + const [loading, setLoading] = useState(false); + const requestServer = useRequest({ notificationSuccess: true }); + + const clickHandler = () => { + setLoading(true); + const filters = DataTableFilterDataStructure(filterData, isArrayEmpty); + const filterParams = new URLSearchParams(); + let requestUrl; + filterParams.set("filters", JSON.stringify(filters || [])); + if (filterData.province_id.value === "") { + requestUrl = EXPORT_ROAD_SAFETY_PROVINCE_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORTT; + } else { + filterParams.set("province_id", filterData.province_id.value); + requestUrl = EXPORT_ROAD_SAFETY_CITY_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORT; + } + + requestServer(`${requestUrl}?${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 ? ( + + + + ) : ( + + )} + + ); +}; +export default PrintExcel; diff --git a/src/components/dashboard/roadSafety/reports/constructionActivity/ReportLists.jsx b/src/components/dashboard/roadSafety/reports/constructionActivity/ReportLists.jsx new file mode 100644 index 0000000..37fa24a --- /dev/null +++ b/src/components/dashboard/roadSafety/reports/constructionActivity/ReportLists.jsx @@ -0,0 +1,463 @@ +"use client"; +import DataTableWithAuth from "@/core/components/DataTableWithAuth"; +import { Box } from "@mui/material"; +import { useMemo } from "react"; +import Toolbar from "./Toolbar"; + +const ReportLists = ({ data, filterData, setFilterData, isLoading }) => { + const columns = useMemo(() => { + return [ + { + accessorKey: "edare_name", + header: "اداره کل", + id: "edare_name", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + }, + { + accessorFn: (row) => (row["1"] ? row["1"].total_sum : 0), + header: "تعداد کل", + id: "sum", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + header: "آزادراه", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + id: "id_1", + grow: false, + size: 50, + columns: [ + { + accessorFn: (row) => (row["1"] ? row["1"].s1 : 0), + header: "گام اول", + id: "id_1.1", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["1"] ? row["1"].s2 : 0), + header: "گام دوم", + id: "id_1.2", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["1"] ? row["1"].s3 : 0), + header: "گام سوم", + id: "id_1.3", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + ], + }, + { + header: "بزرگراه", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + id: "id_2", + grow: false, + size: 50, + columns: [ + { + accessorFn: (row) => (row["2"] ? row["2"].s1 : 0), + header: "گام اول", + id: "id_2.1", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["2"] ? row["2"].s2 : 0), + header: "گام دوم", + id: "id_2.2", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["2"] ? row["2"].s3 : 0), + header: "گام سوم", + id: "id_2.3", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + ], + }, + { + header: "اصلی", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + id: "id_3", + grow: false, + size: 50, + columns: [ + { + accessorFn: (row) => (row["3"] ? row["3"].s1 : 0), + header: "گام اول", + id: "id_3.1", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["3"] ? row["3"].s2 : 0), + header: "گام دوم", + id: "id_3.2", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["3"] ? row["3"].s3 : 0), + header: "گام سوم", + id: "id_3.3", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + ], + }, + { + header: "فرعی", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + id: "id_4", + grow: false, + size: 50, + columns: [ + { + accessorFn: (row) => (row["4"] ? row["4"].s1 : 0), + header: "گام اول", + id: "id_4.1", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["4"] ? row["4"].s2 : 0), + header: "گام دوم", + id: "id_4.2", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["4"] ? row["4"].s3 : 0), + header: "گام سوم", + id: "id_4.3", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + ], + }, + { + header: "روستایی", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + id: "id_5", + grow: false, + size: 50, + columns: [ + { + accessorFn: (row) => (row["5"] ? row["5"].s1 : 0), + header: "گام اول", + id: "id_5.1", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["5"] ? row["5"].s2 : 0), + header: "گام دوم", + id: "id_5.2", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["5"] ? row["5"].s3 : 0), + header: "گام سوم", + id: "id_5.3", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + ], + }, + ]; + }, []); + + return ( + + + + ); +}; + +export default ReportLists; diff --git a/src/components/dashboard/roadSafety/reports/constructionActivity/Toolbar.jsx b/src/components/dashboard/roadSafety/reports/constructionActivity/Toolbar.jsx new file mode 100644 index 0000000..7dd930f --- /dev/null +++ b/src/components/dashboard/roadSafety/reports/constructionActivity/Toolbar.jsx @@ -0,0 +1,11 @@ +import PrintExcel from "./ExcelPrint"; +import { Box } from "@mui/material"; + +const Toolbar = ({ table, filterData, mutate }) => { + return ( + + + + ); +}; +export default Toolbar; diff --git a/src/components/dashboard/roadSafety/reports/constructionActivity/index.jsx b/src/components/dashboard/roadSafety/reports/constructionActivity/index.jsx new file mode 100644 index 0000000..015aef1 --- /dev/null +++ b/src/components/dashboard/roadSafety/reports/constructionActivity/index.jsx @@ -0,0 +1,207 @@ +"use client"; +import CustomSelectByDependency from "@/core/components/FilterDrawer/fieldsType/CustomSelectByDependency"; +import PageTitle from "@/core/components/PageTitle"; +import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure"; +import groupByEdareAxisStep from "@/core/utils/groupByEdareAxisStep"; +import groupByProvinceAxisStep from "@/core/utils/groupByProvinceAxisStep"; +import isArrayEmpty from "@/core/utils/isArrayEmpty"; +import { + GET_ROAD_SAFETY_CITY_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORT, + GET_ROAD_SAFETY_PROVINCE_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORT, +} from "@/core/utils/routes"; +import { useAuth } from "@/lib/contexts/auth"; +import { usePermissions } from "@/lib/hooks/usePermissions"; +import useProvinces from "@/lib/hooks/useProvince"; +import useRequest from "@/lib/hooks/useRequest"; +import { LinearProgress, Stack } from "@mui/material"; +import { useEffect, useMemo, useState } from "react"; +import ReportLists from "./ReportLists"; + +const ReportConstructionActivityPage = () => { + const { data: userPermissions } = usePermissions(); + const hasProvincesPermission = userPermissions.includes("show-safety-and-privacy-operator-cartable"); + const { user } = useAuth(); + const requestServer = useRequest(); + const [data, setData] = useState(null); + const [isLoading, setLoading] = useState(true); + + const defaultValues = useMemo( + () => [ + { + header: "استان", + id: "province_id", + filterMode: "equals", + datatype: "numeric", + value: hasProvincesPermission ? "" : user.province_id, + enable: hasProvincesPermission, + SelectComponent: (props) => { + const { provinces, errorProvinces, loadingProvinces } = useProvinces(); + const getSelectOptions = useMemo(() => { + if (loadingProvinces) { + return [{ value: "loading", label: "در حال بارگذاری..." }]; + } + if (errorProvinces) { + return [{ value: "error", label: "خطا در بارگذاری" }]; + } + return [ + { value: "", label: "کل کشور" }, + ...provinces.map((province) => ({ + value: province.id, + label: province.name_fa, + })), + ]; + }, [provinces, errorProvinces, loadingProvinces]); + return ( + + ); + }, + }, + { + header: "مورد", + id: "info_id", + filterMode: "equals", + datatype: "numeric", + value: "89", + enable: false, + }, + { + header: "تاریخ ثبت", + id: "created_at", + filterMode: "between", + datatype: "date", + value: ["", ""], + enable: true, + }, + { + header: "تاریخ بازدید", + id: "activity_date_time", + filterMode: "between", + datatype: "date", + value: ["", ""], + enable: true, + }, + { + header: "تاریخ بارگذاری مستندات", + id: "judiciary_document_upload_date", + filterMode: "between", + datatype: "date", + value: ["", ""], + enable: true, + }, + { + header: "تاریخ اقدام", + id: "action_date", + filterMode: "between", + datatype: "date", + value: ["", ""], + enable: true, + }, + ], + [hasProvincesPermission, user.province_id] + ); + + const [filterData, setFilterData] = useState( + defaultValues.reduce((acc, item) => { + acc[item.id] = item; + return acc; + }, {}) + ); + + useEffect(() => { + const fetchData = async () => { + try { + setLoading(true); + const filters = DataTableFilterDataStructure(filterData, isArrayEmpty); + const params = new URLSearchParams(); + params.set("filters", JSON.stringify(filters || [])); + if (filterData.province_id.value === "") { + try { + const response = await requestServer( + `${GET_ROAD_SAFETY_PROVINCE_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORT}?${params.toString()}` + ); + + const result = response.data.data; + const grouped = groupByProvinceAxisStep(result.activities); + + const nationalReportForItem = grouped[-1]; + const nationalReport = { + edare_name: "کل کشور", + ...nationalReportForItem, + }; + + setData([ + nationalReport, + ...result.provinces.map((province) => { + const filteredReports = grouped[province.id]; + return { + ...filteredReports, + edare_name: province.name_fa, + }; + }), + ]); + } catch (e) { + console.log(e); + } + } else { + params.set("province_id", filterData.province_id.value); + try { + const response = await requestServer( + `${GET_ROAD_SAFETY_CITY_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORT}?${params.toString()}` + ); + const result = response.data.data; + const grouped = groupByEdareAxisStep(result.activities); + + const nationalReportForItem = grouped[-1]; + const nationalReport = { + ...nationalReportForItem, + edare_name: "کل استان", + }; + setData([ + nationalReport, + ...result.edarateShahri.map((edare) => { + const filteredReports = grouped[edare.id]; + return { + edare_name: edare.name_fa, + ...filteredReports, + }; + }), + ]); + } catch (e) { + console.log(e); + } + } + } catch (error) { + console.log(error); + } finally { + setLoading(false); + } + }; + + fetchData(); + }, [filterData]); + + console.log(data); + + return ( + + + {!data ? ( + + ) : ( + <> + + + )} + + ); +}; +export default ReportConstructionActivityPage; diff --git a/src/components/dashboard/roadSafety/reports/map/PointsOnMap/DialogInfoItem/ContentInfoItem.jsx b/src/components/dashboard/roadSafety/reports/map/PointsOnMap/DialogInfoItem/ContentInfoItem.jsx index 34ff489..8984c66 100644 --- a/src/components/dashboard/roadSafety/reports/map/PointsOnMap/DialogInfoItem/ContentInfoItem.jsx +++ b/src/components/dashboard/roadSafety/reports/map/PointsOnMap/DialogInfoItem/ContentInfoItem.jsx @@ -151,4 +151,4 @@ const ContentInfoItem = ({ data }) => { ); }; -export default ContentInfoItem; \ No newline at end of file +export default ContentInfoItem; diff --git a/src/components/dashboard/roadSafety/reports/reportPage/Search/FromDateController.jsx b/src/components/dashboard/roadSafety/reports/reportPage/Search/FromDateController.jsx deleted file mode 100644 index 7f3f0f4..0000000 --- a/src/components/dashboard/roadSafety/reports/reportPage/Search/FromDateController.jsx +++ /dev/null @@ -1,28 +0,0 @@ -import { Controller } from "react-hook-form"; -import MuiDatePicker from "@/core/components/MuiDatePicker"; -import React from "react"; -import moment from "jalali-moment"; - -const FromDateController = ({ control }) => { - return ( - ( - { - const formattedDate = moment(new Date(newValue)).locale("en").format("YYYY-MM-DD"); - onChange(formattedDate); // Update the field value in react-hook-form - }} - helperText={error ? error.message : null} - /> - )} - /> - ); -}; -export default FromDateController; diff --git a/src/components/dashboard/roadSafety/reports/reportPage/Search/SearchReportField.jsx b/src/components/dashboard/roadSafety/reports/reportPage/Search/SearchReportField.jsx deleted file mode 100644 index 2ec69aa..0000000 --- a/src/components/dashboard/roadSafety/reports/reportPage/Search/SearchReportField.jsx +++ /dev/null @@ -1,49 +0,0 @@ -import { Button, Grid, LinearProgress, Typography } from "@mui/material"; -import SearchIcon from "@mui/icons-material/Search"; -import React from "react"; -import FromDateController from "./FromDateController"; -import ToDateController from "./ToDateController"; -import SelectProvince from "./SelectProvince"; -import { Controller } from "react-hook-form"; -import SelectAxisType from "./SelectAxisType"; - -const SearchReportField = ({ control, hasProvincesPermission }) => { - return ( - - - - - - - - {hasProvincesPermission && ( - - - - )} - - - - - ( - - )} - /> - - - ); -}; - -export default SearchReportField; diff --git a/src/components/dashboard/roadSafety/reports/reportPage/Search/SelectAxisType.jsx b/src/components/dashboard/roadSafety/reports/reportPage/Search/SelectAxisType.jsx deleted file mode 100644 index 65b5062..0000000 --- a/src/components/dashboard/roadSafety/reports/reportPage/Search/SelectAxisType.jsx +++ /dev/null @@ -1,45 +0,0 @@ -import { FormControl, FormHelperText, InputLabel, MenuItem, Select } from "@mui/material"; -import { Controller } from "react-hook-form"; - -const axisOptions = [ - { value: 1, label: "آزادراه" }, - { value: 2, label: "بزرگراه" }, - { value: 3, label: "اصلی" }, - { value: 4, label: "فرعی" }, - { value: 5, label: "روستایی" }, -]; - -const SelectAxisType = ({ control }) => { - return ( - ( - - نوع محور - - {error && {error.message}} - - )} - /> - ); -}; -export default SelectAxisType; diff --git a/src/components/dashboard/roadSafety/reports/reportPage/Search/SelectProvince.jsx b/src/components/dashboard/roadSafety/reports/reportPage/Search/SelectProvince.jsx deleted file mode 100644 index 89395f0..0000000 --- a/src/components/dashboard/roadSafety/reports/reportPage/Search/SelectProvince.jsx +++ /dev/null @@ -1,45 +0,0 @@ -import useProvinces from "@/lib/hooks/useProvince"; -import { FormControl, FormHelperText, InputLabel, MenuItem, Select } from "@mui/material"; -import { Controller } from "react-hook-form"; - -const SelectProvince = ({ control }) => { - const { provinces, loadingProvinces, errorProvinces } = useProvinces(); - return ( - ( - - استان - - {error && {error.message}} - - )} - /> - ); -}; -export default SelectProvince; diff --git a/src/components/dashboard/roadSafety/reports/reportPage/Search/ToDateController.jsx b/src/components/dashboard/roadSafety/reports/reportPage/Search/ToDateController.jsx deleted file mode 100644 index e9c66e4..0000000 --- a/src/components/dashboard/roadSafety/reports/reportPage/Search/ToDateController.jsx +++ /dev/null @@ -1,30 +0,0 @@ -import { Controller, useWatch } from "react-hook-form"; -import MuiDatePicker from "@/core/components/MuiDatePicker"; -import React from "react"; -import moment from "jalali-moment"; - -const ToDateController = ({ control }) => { - const minDate = useWatch({ control, name: "from_date" }); - return ( - ( - { - const formattedDate = moment(new Date(newValue)).locale("en").format("YYYY-MM-DD"); - onChange(formattedDate); // Update the field value in react-hook-form - }} - helperText={error ? error.message : null} - /> - )} - /> - ); -}; -export default ToDateController; diff --git a/src/components/dashboard/roadSafety/reports/reportPage/Search/index.jsx b/src/components/dashboard/roadSafety/reports/reportPage/Search/index.jsx deleted file mode 100644 index 9d504f2..0000000 --- a/src/components/dashboard/roadSafety/reports/reportPage/Search/index.jsx +++ /dev/null @@ -1,13 +0,0 @@ -import StyledForm from "@/core/components/StyledForm"; -import SearchReportField from "./SearchReportField"; - -const SearchReportList = ({ handleSubmit, onSearchSubmit, control, hasProvincesPermission }) => { - return ( - <> - - - - - ); -}; -export default SearchReportList; diff --git a/src/components/dashboard/roadSafety/reports/utilityPassingActivity/ExcelPrint/index.jsx b/src/components/dashboard/roadSafety/reports/utilityPassingActivity/ExcelPrint/index.jsx new file mode 100644 index 0000000..7242a65 --- /dev/null +++ b/src/components/dashboard/roadSafety/reports/utilityPassingActivity/ExcelPrint/index.jsx @@ -0,0 +1,70 @@ +"use client"; +import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure"; +import isArrayEmpty from "@/core/utils/isArrayEmpty"; +import { + EXPORT_ROAD_SAFETY_CITY_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORT, + EXPORT_ROAD_SAFETY_PROVINCE_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORTT, +} from "@/core/utils/routes"; +import useRequest from "@/lib/hooks/useRequest"; +import { useTheme } from "@emotion/react"; +import DescriptionIcon from "@mui/icons-material/Description"; +import { Button, CircularProgress, IconButton, useMediaQuery } from "@mui/material"; +import FileSaver from "file-saver"; +import moment from "jalali-moment"; +import { useState } from "react"; + +const PrintExcel = ({ table, filterData }) => { + const theme = useTheme(); + const isMobile = useMediaQuery(theme.breakpoints.down("sm")); + const [loading, setLoading] = useState(false); + const requestServer = useRequest({ notificationSuccess: true }); + + const clickHandler = () => { + setLoading(true); + const filters = DataTableFilterDataStructure(filterData, isArrayEmpty); + const filterParams = new URLSearchParams(); + let requestUrl; + filterParams.set("filters", JSON.stringify(filters || [])); + if (filterData.province_id.value === "") { + requestUrl = EXPORT_ROAD_SAFETY_PROVINCE_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORTT; + } else { + filterParams.set("province_id", filterData.province_id.value); + requestUrl = EXPORT_ROAD_SAFETY_CITY_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORT; + } + + requestServer(`${requestUrl}?${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 ? ( + + + + ) : ( + + )} + + ); +}; +export default PrintExcel; diff --git a/src/components/dashboard/roadSafety/reports/utilityPassingActivity/ReportLists.jsx b/src/components/dashboard/roadSafety/reports/utilityPassingActivity/ReportLists.jsx new file mode 100644 index 0000000..7d46eaf --- /dev/null +++ b/src/components/dashboard/roadSafety/reports/utilityPassingActivity/ReportLists.jsx @@ -0,0 +1,463 @@ +"use client"; +import DataTableWithAuth from "@/core/components/DataTableWithAuth"; +import { Box } from "@mui/material"; +import { useMemo } from "react"; +import Toolbar from "./Toolbar"; + +const ReportLists = ({ data, filterData, setFilterData, isLoading }) => { + const columns = useMemo(() => { + return [ + { + accessorKey: "edare_name", + header: "اداره کل", + id: "edare_name", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + }, + { + accessorFn: (row) => (row["1"] ? row["1"].total_sum : 0), + header: "تعداد کل", + id: "sum", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + header: "آزادراه", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + id: "id_1", + grow: false, + size: 50, + columns: [ + { + accessorFn: (row) => (row["1"] ? row["1"].s1 : 0), + header: "گام اول", + id: "id_1.1", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["1"] ? row["1"].s2 : 0), + header: "گام دوم", + id: "id_1.2", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["1"] ? row["1"].s3 : 0), + header: "گام سوم", + id: "id_1.3", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + ], + }, + { + header: "بزرگراه", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + id: "id_2", + grow: false, + size: 50, + columns: [ + { + accessorFn: (row) => (row["2"] ? row["2"].s1 : 0), + header: "گام اول", + id: "id_2.1", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["2"] ? row["2"].s2 : 0), + header: "گام دوم", + id: "id_2.2", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["2"] ? row["2"].s3 : 0), + header: "گام سوم", + id: "id_2.3", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + ], + }, + { + header: "اصلی", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + id: "id_3", + grow: false, + size: 50, + columns: [ + { + accessorFn: (row) => (row["3"] ? row["3"].s1 : 0), + header: "گام اول", + id: "id_3.1", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["3"] ? row["3"].s2 : 0), + header: "گام دوم", + id: "id_3.2", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["3"] ? row["3"].s3 : 0), + header: "گام سوم", + id: "id_3.3", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + ], + }, + { + header: "فرعی", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + id: "id_4", + grow: false, + size: 50, + columns: [ + { + accessorFn: (row) => (row["4"] ? row["4"].s1 : 0), + header: "گام اول", + id: "id_4.1", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["4"] ? row["4"].s2 : 0), + header: "گام دوم", + id: "id_4.2", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["4"] ? row["4"].s3 : 0), + header: "گام سوم", + id: "id_4.3", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + ], + }, + { + header: "روستایی", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + id: "id_5", + grow: false, + size: 50, + columns: [ + { + accessorFn: (row) => (row["5"] ? row["5"].s1 : 0), + header: "گام اول", + id: "id_5.1", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["5"] ? row["5"].s2 : 0), + header: "گام دوم", + id: "id_5.2", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + { + accessorFn: (row) => (row["5"] ? row["5"].s3 : 0), + header: "گام سوم", + id: "id_5.3", + enableColumnFilter: false, + enableSorting: false, + datatype: "text", + grow: false, + size: 50, + muiTableBodyCellProps: { + sx: { + textAlign: "center", + borderLeft: "1px solid #e1e1e1", + py: 0, + "&:first-of-type": { + borderLeft: "unset", + }, + }, + }, + Cell: ({ renderedCellValue }) => { + return (renderedCellValue / 1).toLocaleString(); + }, + }, + ], + }, + ]; + }, []); + + return ( + + + + ); +}; + +export default ReportLists; diff --git a/src/components/dashboard/roadSafety/reports/utilityPassingActivity/Toolbar.jsx b/src/components/dashboard/roadSafety/reports/utilityPassingActivity/Toolbar.jsx new file mode 100644 index 0000000..7dd930f --- /dev/null +++ b/src/components/dashboard/roadSafety/reports/utilityPassingActivity/Toolbar.jsx @@ -0,0 +1,11 @@ +import PrintExcel from "./ExcelPrint"; +import { Box } from "@mui/material"; + +const Toolbar = ({ table, filterData, mutate }) => { + return ( + + + + ); +}; +export default Toolbar; diff --git a/src/components/dashboard/roadSafety/reports/utilityPassingActivity/index.jsx b/src/components/dashboard/roadSafety/reports/utilityPassingActivity/index.jsx new file mode 100644 index 0000000..97ba87e --- /dev/null +++ b/src/components/dashboard/roadSafety/reports/utilityPassingActivity/index.jsx @@ -0,0 +1,207 @@ +"use client"; +import CustomSelectByDependency from "@/core/components/FilterDrawer/fieldsType/CustomSelectByDependency"; +import PageTitle from "@/core/components/PageTitle"; +import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure"; +import groupByEdareAxisStep from "@/core/utils/groupByEdareAxisStep"; +import groupByProvinceAxisStep from "@/core/utils/groupByProvinceAxisStep"; +import isArrayEmpty from "@/core/utils/isArrayEmpty"; +import { + GET_ROAD_SAFETY_CITY_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORT, + GET_ROAD_SAFETY_PROVINCE_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORT, +} from "@/core/utils/routes"; +import { useAuth } from "@/lib/contexts/auth"; +import { usePermissions } from "@/lib/hooks/usePermissions"; +import useProvinces from "@/lib/hooks/useProvince"; +import useRequest from "@/lib/hooks/useRequest"; +import { LinearProgress, Stack } from "@mui/material"; +import { useEffect, useMemo, useState } from "react"; +import ReportLists from "./ReportLists"; + +const ReportUtilityPassingActivityPage = () => { + const { data: userPermissions } = usePermissions(); + const hasProvincesPermission = userPermissions.includes("show-safety-and-privacy-operator-cartable"); + const { user } = useAuth(); + const requestServer = useRequest(); + const [data, setData] = useState(null); + const [isLoading, setLoading] = useState(true); + + const defaultValues = useMemo( + () => [ + { + header: "استان", + id: "province_id", + filterMode: "equals", + datatype: "numeric", + value: hasProvincesPermission ? "" : user.province_id, + enable: hasProvincesPermission, + SelectComponent: (props) => { + const { provinces, errorProvinces, loadingProvinces } = useProvinces(); + const getSelectOptions = useMemo(() => { + if (loadingProvinces) { + return [{ value: "loading", label: "در حال بارگذاری..." }]; + } + if (errorProvinces) { + return [{ value: "error", label: "خطا در بارگذاری" }]; + } + return [ + { value: "", label: "کل کشور" }, + ...provinces.map((province) => ({ + value: province.id, + label: province.name_fa, + })), + ]; + }, [provinces, errorProvinces, loadingProvinces]); + return ( + + ); + }, + }, + { + header: "مورد", + id: "info_id", + filterMode: "equals", + datatype: "numeric", + value: "91", + enable: false, + }, + { + header: "تاریخ ثبت", + id: "created_at", + filterMode: "between", + datatype: "date", + value: ["", ""], + enable: true, + }, + { + header: "تاریخ بازدید", + id: "activity_date_time", + filterMode: "between", + datatype: "date", + value: ["", ""], + enable: true, + }, + { + header: "تاریخ بارگذاری مستندات", + id: "judiciary_document_upload_date", + filterMode: "between", + datatype: "date", + value: ["", ""], + enable: true, + }, + { + header: "تاریخ اقدام", + id: "action_date", + filterMode: "between", + datatype: "date", + value: ["", ""], + enable: true, + }, + ], + [hasProvincesPermission, user.province_id] + ); + + const [filterData, setFilterData] = useState( + defaultValues.reduce((acc, item) => { + acc[item.id] = item; + return acc; + }, {}) + ); + + useEffect(() => { + const fetchData = async () => { + try { + setLoading(true); + const filters = DataTableFilterDataStructure(filterData, isArrayEmpty); + const params = new URLSearchParams(); + params.set("filters", JSON.stringify(filters || [])); + if (filterData.province_id.value === "") { + try { + const response = await requestServer( + `${GET_ROAD_SAFETY_PROVINCE_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORT}?${params.toString()}` + ); + + const result = response.data.data; + const grouped = groupByProvinceAxisStep(result.activities); + + const nationalReportForItem = grouped[-1]; + const nationalReport = { + edare_name: "کل کشور", + ...nationalReportForItem, + }; + + setData([ + nationalReport, + ...result.provinces.map((province) => { + const filteredReports = grouped[province.id]; + return { + ...filteredReports, + edare_name: province.name_fa, + }; + }), + ]); + } catch (e) { + console.log(e); + } + } else { + params.set("province_id", filterData.province_id.value); + try { + const response = await requestServer( + `${GET_ROAD_SAFETY_CITY_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORT}?${params.toString()}` + ); + const result = response.data.data; + const grouped = groupByEdareAxisStep(result.activities); + + const nationalReportForItem = grouped[-1]; + const nationalReport = { + ...nationalReportForItem, + edare_name: "کل استان", + }; + setData([ + nationalReport, + ...result.edarateShahri.map((edare) => { + const filteredReports = grouped[edare.id]; + return { + edare_name: edare.name_fa, + ...filteredReports, + }; + }), + ]); + } catch (e) { + console.log(e); + } + } + } catch (error) { + console.log(error); + } finally { + setLoading(false); + } + }; + + fetchData(); + }, [filterData]); + + console.log(data); + + return ( + + + {!data ? ( + + ) : ( + <> + + + )} + + ); +}; +export default ReportUtilityPassingActivityPage; diff --git a/src/components/dashboard/roadSafety/supervisor/SupervisorList.jsx b/src/components/dashboard/roadSafety/supervisor/SupervisorList.jsx index 5ec3db0..17dcc40 100644 --- a/src/components/dashboard/roadSafety/supervisor/SupervisorList.jsx +++ b/src/components/dashboard/roadSafety/supervisor/SupervisorList.jsx @@ -155,8 +155,8 @@ const SupervisorList = () => { props.dependencyFieldValue?.value === "" ? "empty" : loadingEdaratList - ? "loading" - : props.filterParameters.value + ? "loading" + : props.filterParameters.value } columnSelectOption={getColumnSelectOptions} /> @@ -313,8 +313,8 @@ const SupervisorList = () => { {row.original.is_finished == 1 ? "خاتمه یافته" : row.original.is_finished == 0 - ? "در جریان" - : "-"} + ? "در جریان" + : "-"} ), }, @@ -476,7 +476,7 @@ const SupervisorList = () => { return ( {row.original.judiciary_document_upload_date !== "0000-00-00 00:00:00" && - row.original.judiciary_document_upload_date ? ( + row.original.judiciary_document_upload_date ? ( ) : ( <>- diff --git a/src/core/components/Toasts/error.jsx b/src/core/components/Toasts/error.jsx index 47882fb..ca503f6 100644 --- a/src/core/components/Toasts/error.jsx +++ b/src/core/components/Toasts/error.jsx @@ -16,7 +16,11 @@ export const errorServerToast = (toastContainer) => - {"The request failed due to an internal error."} + + { + "در پردازش درخواست مشکلی در سرور به‌وجود آمد. لطفاً بعداً دوباره تلاش کنید یا با پشتیبانی تماس بگیرید." + } + @@ -46,7 +50,7 @@ export const errorUnauthorizedToast = (toastContainer) => - {"The user is not authorized to make the request."} + {"شما مجوز لازم برای انجام این عملیات را ندارید."} @@ -75,7 +79,7 @@ export const errorAccessDeniedToast = (message, toastContainer) => - {message || "Access Denied"} + {message || "شما اجازه دسترسی به این بخش را ندارید."} @@ -106,8 +110,7 @@ export const errorLogicToast = (message, toastContainer) => - {message || - "The request was well-formed but was unable to be followed due to semantic errors."} + {message || "درخواست شما معتبر است اما به دلیل اشکال در داده‌ها امکان انجام آن وجود ندارد."} @@ -137,8 +140,7 @@ export const errorValidationToast = (message, toastContainer) => - {message || - "The request was well-formed but was unable to be followed due to semantic errors."} + {message || "اطلاعات وارد شده قابل پردازش نیست. لطفاً داده‌ها را بررسی و دوباره تلاش کنید."} @@ -168,7 +170,7 @@ export const errorTooManyToast = (toastContainer) => - {"Too many requests have been sent within a given time span."} + {"تعداد درخواست‌های شما بیش از حد مجاز است. لطفاً بعد از چند لحظه دوباره تلاش کنید."} @@ -198,9 +200,7 @@ export const errorClientToast = (toastContainer) => - { - "The API request is invalid or improperly formed. Consequently, the API server could not understand the request." - } + {"درخواست شما به‌درستی ارسال نشد. لطفاً داده‌های وارد شده را بررسی کنید."} diff --git a/src/core/utils/groupByEdareAxisStep.js b/src/core/utils/groupByEdareAxisStep.js new file mode 100644 index 0000000..90ffc73 --- /dev/null +++ b/src/core/utils/groupByEdareAxisStep.js @@ -0,0 +1,12 @@ +export default function groupByEdareAxisStep(data) { + return data.reduce((acc, item) => { + const { edare_id, axis_type_id } = item; + + if (!acc[edare_id]) acc[edare_id] = {}; + if (!acc[edare_id][axis_type_id]) acc[edare_id][axis_type_id] = {}; + + acc[edare_id][axis_type_id] = { ...item }; + + return acc; + }, {}); +} diff --git a/src/core/utils/groupByProvinceAxisStep.js b/src/core/utils/groupByProvinceAxisStep.js new file mode 100644 index 0000000..cd192f0 --- /dev/null +++ b/src/core/utils/groupByProvinceAxisStep.js @@ -0,0 +1,12 @@ +export default function groupByProvinceAxisStep(data) { + return data.reduce((acc, item) => { + const { province_id, axis_type_id } = item; + + if (!acc[province_id]) acc[province_id] = {}; + if (!acc[province_id][axis_type_id]) acc[province_id][axis_type_id] = {}; + + acc[province_id][axis_type_id] = { ...item }; + + return acc; + }, {}); +} diff --git a/src/core/utils/pageMenuDev.js b/src/core/utils/pageMenuDev.js index 5e0a639..118dacb 100644 --- a/src/core/utils/pageMenuDev.js +++ b/src/core/utils/pageMenuDev.js @@ -391,13 +391,43 @@ export const pageMenuDev = [ { id: "safetyAndPrivacyManagmentReport", label: "گزارش ها", - type: "page", - route: "/dashboard/road-safety/reports", + type: "menu", icon: , - permissions: [ - "show-safety-and-privacy-operator-cartable", - "show-safety-and-privacy-operator-cartable-province", - "show-safety-and-privacy-operator-cartable-edarate-shahri", + hasSubitems: true, + Subitems: [ + { + id: "safetyAndPrivacyManagmentReportConstructionActivity", + label: "بر اساس ساخت و ساز غیر مجاز", + type: "page", + route: "/dashboard/road-safety/reports/construction-activity", + permissions: [ + "show-safety-and-privacy-operator-cartable", + "show-safety-and-privacy-operator-cartable-province", + "show-safety-and-privacy-operator-cartable-edarate-shahri", + ], + }, + { + id: "safetyAndPrivacyManagmentReportAccessRoad", + label: "بر اساس راه دسترسی غیر مجاز", + type: "page", + route: "/dashboard/road-safety/reports/access-road", + permissions: [ + "show-safety-and-privacy-operator-cartable", + "show-safety-and-privacy-operator-cartable-province", + "show-safety-and-privacy-operator-cartable-edarate-shahri", + ], + }, + { + id: "safetyAndPrivacyManagmentReportUtilityPassingActivity", + label: "بر اساس عبور تاسیسات زیربنایی غیر مجاز", + type: "page", + route: "/dashboard/road-safety/reports/utility-passing-activity", + permissions: [ + "show-safety-and-privacy-operator-cartable", + "show-safety-and-privacy-operator-cartable-province", + "show-safety-and-privacy-operator-cartable-edarate-shahri", + ], + }, ], }, ], diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js index 3385ebc..da56c9e 100644 --- a/src/core/utils/routes.js +++ b/src/core/utils/routes.js @@ -161,10 +161,33 @@ export const GET_ROAD_SAFETY_CITY_ACTIVITY_REPORT = api + "/api/v3/safety_and_privacy_report/operator/province_activity"; export const GET_ROAD_SAFETY_REPORT_MAP = api + "/api/v3/safety_and_privacy/map"; export const GET_ROAD_SAFETY_DETAILS = api + "/api/v3/safety_and_privacy/operator"; -export const EXPORT_COUNTRY_ROAD_SAFETY_REPORT = - api + "/api/v3/safety_and_privacy_report/operator/country_excel_activity"; -export const EXPORT_PROVINCE_ROAD_SAFETY_REPORT = - api + "/api/v3/safety_and_privacy_report/operator/province_excel_activity"; + +export const GET_ROAD_SAFETY_PROVINCE_ACTIVITY_ACCESS_ROAD_REPORT = + api + "/api/v3/safety_and_privacy/access_road/country_activity"; +export const GET_ROAD_SAFETY_CITY_ACTIVITY_ACCESS_ROAD_REPORT = + api + "/api/v3/safety_and_privacy/access_road/province_activity"; +export const EXPORT_ROAD_SAFETY_PROVINCE_ACTIVITY_ACCESS_ROAD_REPORTT = + api + "/api/v3/safety_and_privacy/access_road/country_excel_activity"; +export const EXPORT_ROAD_SAFETY_CITY_ACTIVITY_ACCESS_ROAD_REPORT = + api + "/api/v3/safety_and_privacy/access_road/province_excel_activity"; + +export const GET_ROAD_SAFETY_PROVINCE_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORT = + api + "/api/v3/safety_and_privacy/construction_activity/country_activity"; +export const GET_ROAD_SAFETY_CITY_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORT = + api + "/api/v3/safety_and_privacy/construction_activity/province_activity"; +export const EXPORT_ROAD_SAFETY_PROVINCE_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORTT = + api + "/api/v3/safety_and_privacy/construction_activity/country_excel_activity"; +export const EXPORT_ROAD_SAFETY_CITY_ACTIVITY_CONSTRUCTION_ACTIVITY_REPORT = + api + "/api/v3/safety_and_privacy/construction_activity/province_excel_activity"; + +export const GET_ROAD_SAFETY_PROVINCE_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORT = + api + "/api/v3/safety_and_privacy/utility_passing_activity/country_activity"; +export const GET_ROAD_SAFETY_CITY_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORT = + api + "/api/v3/safety_and_privacy/utility_passing_activity/province_activity"; +export const EXPORT_ROAD_SAFETY_PROVINCE_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORTT = + api + "/api/v3/safety_and_privacy/utility_passing_activity/country_excel_activity"; +export const EXPORT_ROAD_SAFETY_CITY_ACTIVITY_UTILITY_PASSING_ACTIVITY_REPORT = + api + "/api/v3/safety_and_privacy/utility_passing_activity/province_excel_activity"; // permission table export const GET_PERMISSION_TABLE_LIST = api + "/api/v3/permissions"; From 752b10c92bde469408b18eca3b264d6820afcfe9 Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Wed, 27 Aug 2025 11:44:13 +0330 Subject: [PATCH 2/2] change version to 1.7.0 --- .env.example | 2 +- src/core/utils/pageMenu.js | 42 ++++++++++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/.env.example b/.env.example index 65582e0..37aa8cf 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ HOST="rms.witel.ir" -NEXT_PUBLIC_VERSION="1.6.1" +NEXT_PUBLIC_VERSION="1.7.0" NEXT_PUBLIC_API_URL="https://rms.witel.ir" NEXT_PUBLIC_MAPTILE_ENDPOINT="https://rmsmap.rmto.ir/141map" \ No newline at end of file diff --git a/src/core/utils/pageMenu.js b/src/core/utils/pageMenu.js index 9331de5..c3928fe 100644 --- a/src/core/utils/pageMenu.js +++ b/src/core/utils/pageMenu.js @@ -387,13 +387,43 @@ export const pageMenu = [ { id: "safetyAndPrivacyManagmentReport", label: "گزارش ها", - type: "page", - route: "/dashboard/road-safety/reports", + type: "menu", icon: , - permissions: [ - "show-safety-and-privacy-operator-cartable", - "show-safety-and-privacy-operator-cartable-province", - "show-safety-and-privacy-operator-cartable-edarate-shahri", + hasSubitems: true, + Subitems: [ + { + id: "safetyAndPrivacyManagmentReportConstructionActivity", + label: "بر اساس ساخت و ساز غیر مجاز", + type: "page", + route: "/dashboard/road-safety/reports/construction-activity", + permissions: [ + "show-safety-and-privacy-operator-cartable", + "show-safety-and-privacy-operator-cartable-province", + "show-safety-and-privacy-operator-cartable-edarate-shahri", + ], + }, + { + id: "safetyAndPrivacyManagmentReportAccessRoad", + label: "بر اساس راه دسترسی غیر مجاز", + type: "page", + route: "/dashboard/road-safety/reports/access-road", + permissions: [ + "show-safety-and-privacy-operator-cartable", + "show-safety-and-privacy-operator-cartable-province", + "show-safety-and-privacy-operator-cartable-edarate-shahri", + ], + }, + { + id: "safetyAndPrivacyManagmentReportUtilityPassingActivity", + label: "بر اساس عبور تاسیسات زیربنایی غیر مجاز", + type: "page", + route: "/dashboard/road-safety/reports/utility-passing-activity", + permissions: [ + "show-safety-and-privacy-operator-cartable", + "show-safety-and-privacy-operator-cartable-province", + "show-safety-and-privacy-operator-cartable-edarate-shahri", + ], + }, ], }, ],