diff --git a/src/app/(withAuth)/dashboard/damages/report/page.js b/src/app/(withAuth)/dashboard/damages/report/page.js
index 27d0308..a9d9507 100644
--- a/src/app/(withAuth)/dashboard/damages/report/page.js
+++ b/src/app/(withAuth)/dashboard/damages/report/page.js
@@ -1,6 +1,7 @@
import DamagesReportPage from "@/components/dashboard/damages/report"
+import WithPermission from "@/core/middlewares/withPermission"
const Page = () => {
- return
+ return
}
export default Page
\ No newline at end of file
diff --git a/src/app/(withAuth)/dashboard/receipt/report/page.js b/src/app/(withAuth)/dashboard/receipt/report/page.js
deleted file mode 100644
index acc26be..0000000
--- a/src/app/(withAuth)/dashboard/receipt/report/page.js
+++ /dev/null
@@ -1,6 +0,0 @@
-import ReceiptReportPage from "@/components/dashboard/receipt/report"
-
-const Page = () => {
- return
-}
-export default Page
\ No newline at end of file
diff --git a/src/components/dashboard/damages/report/ReportLists.jsx b/src/components/dashboard/damages/report/ReportLists.jsx
index b12a9b8..c4923c9 100644
--- a/src/components/dashboard/damages/report/ReportLists.jsx
+++ b/src/components/dashboard/damages/report/ReportLists.jsx
@@ -5,13 +5,11 @@ import { useMemo } from "react";
import Toolbar from "./Toolbar";
const ReportLists = ({ data, specialFilter }) => {
- console.log(data);
-
const columns = useMemo(() => {
return [
{
accessorKey: "edare_name",
- header: "اداره کل",
+ header: "اداره",
id: "edare_name",
enableColumnFilter: false,
enableSorting: false,
diff --git a/src/components/dashboard/damages/report/index.jsx b/src/components/dashboard/damages/report/index.jsx
index 4961eb5..2765bb1 100644
--- a/src/components/dashboard/damages/report/index.jsx
+++ b/src/components/dashboard/damages/report/index.jsx
@@ -1,6 +1,6 @@
'use client'
import PageTitle from "@/core/components/PageTitle";
-import { GET_CITY_RECEIPT_REPORT, GET_PROVINCE_RECEIPT_REPORT } from "@/core/utils/routes";
+import { GET_PROVINCE_RECEIPT_REPORT, GET_COUNTRY_RECEIPT_REPORT } from "@/core/utils/routes";
import { useAuth } from "@/lib/contexts/auth";
import { usePermissions } from "@/lib/hooks/usePermissions";
import useRequest from "@/lib/hooks/useRequest";
@@ -43,7 +43,7 @@ const DamagesReportPage = () => {
]);
if (data.province_id === "-1") {
try {
- const response = await requestServer(`${GET_PROVINCE_RECEIPT_REPORT}?${params}`);
+ const response = await requestServer(`${GET_COUNTRY_RECEIPT_REPORT}?${params}`);
const result = response.data.data;
const nationalReportForItem = result.activities.find((report) => report.province_id == -1);
const nationalReport = {
@@ -72,7 +72,7 @@ const DamagesReportPage = () => {
} else {
try {
params.set("province_id", `${data.province_id}`);
- const response = await requestServer(`${GET_CITY_RECEIPT_REPORT}?${params}`);
+ const response = await requestServer(`${GET_PROVINCE_RECEIPT_REPORT}?${params}`);
const result = response.data.data;
const nationalReportForItem = result.activities.find((report) => report.city_id == "-1");
const nationalReport = {
diff --git a/src/components/dashboard/receipt/report/ExcelPrint/index.jsx b/src/components/dashboard/receipt/report/ExcelPrint/index.jsx
deleted file mode 100644
index 79ea64f..0000000
--- a/src/components/dashboard/receipt/report/ExcelPrint/index.jsx
+++ /dev/null
@@ -1,72 +0,0 @@
-"use client";
-import { EXPORT_COUNTRY_RECEIPT_REPORT, EXPORT_PROVINCE_RECEIPT_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 { useMemo, 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 activeFilters = Object.entries(filterData).reduce((acc, [key, filter]) => {
- if (filter.value) {
- acc.push({ id: filter.id, value: filter.value });
- }
- return acc;
- }, []);
-
- const filterParams = useMemo(() => {
- const params = new URLSearchParams();
- activeFilters.length > 0 &&
- activeFilters.map((filter, index) => {
- params.set(`${filter.id}`, filter.value);
- });
- return params;
- }, [activeFilters]);
-
- const clickHandler = () => {
- setLoading(true);
- const CountryOrProvince = activeFilters.find((item) => item.id === "province_id");
- const requestUrl =
- CountryOrProvince.value === "-1" ? EXPORT_COUNTRY_RECEIPT_REPORT : EXPORT_PROVINCE_RECEIPT_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 ? (
-
-
-
- ) : (
- : }
- onClick={clickHandler}
- >
- خروجی اکسل
-
- )}
- >
- );
-};
-export default PrintExcel;
diff --git a/src/components/dashboard/receipt/report/ReportLists.jsx b/src/components/dashboard/receipt/report/ReportLists.jsx
deleted file mode 100644
index 4386ac6..0000000
--- a/src/components/dashboard/receipt/report/ReportLists.jsx
+++ /dev/null
@@ -1,242 +0,0 @@
-"use client";
-import DataTableWithAuth from "@/core/components/DataTableWithAuth";
-import { Box } from "@mui/material";
-import { useMemo } from "react";
-import Toolbar from "./Toolbar";
-
-const ReportLists = ({ data, specialFilter }) => {
- const columns = useMemo(() => {
- return [
- {
- accessorKey: "edare_name",
- header: "اداره کل",
- id: "edare_name",
- enableColumnFilter: false,
- enableSorting: false,
- datatype: "text",
- grow: false,
- size: 50,
- },
- {
- accessorKey: "tedade",
- header: "تعداد کل",
- id: "tedade",
- 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",
- grow: false,
- size: 50,
- columns: [
- {
- accessorKey: "policeCount",
- header: "گزارش پلیس راه",
- id: "policeCount",
- 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();
- },
- },
- {
- accessorKey: "gashtCount",
- header: "گزارش گشت راهداری",
- id: "gashtCount",
- 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();
- },
- },
- ]
- },
- {
- accessorKey: "kesartAll",
- header: "مبلغ کل خسارات ثبت شده (ریال)",
- id: "kesartAll",
- 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();
- },
- },
- {
- accessorKey: "vosolAll",
- header: "کل مبلغ وصول شده (ریال)",
- id: "vosolAll",
- 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",
- grow: false,
- size: 50,
- columns: [
- {
- accessorKey: "fish",
- header: "فیش",
- id: "fish",
- 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();
- },
- },
- {
- accessorKey: "bime",
- header: "بیمه",
- id: "bime",
- 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();
- },
- },
- {
- accessorKey: "daghi",
- header: "داغی",
- id: "daghi",
- 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/receipt/report/Search/FromDateController.jsx b/src/components/dashboard/receipt/report/Search/FromDateController.jsx
deleted file mode 100644
index b18b320..0000000
--- a/src/components/dashboard/receipt/report/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/receipt/report/Search/SearchReportField.jsx b/src/components/dashboard/receipt/report/Search/SearchReportField.jsx
deleted file mode 100644
index ab8442c..0000000
--- a/src/components/dashboard/receipt/report/Search/SearchReportField.jsx
+++ /dev/null
@@ -1,45 +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";
-
-const SearchReportField = ({ control, hasProvincesPermission }) => {
- return (
-
-
-
-
-
-
-
- {hasProvincesPermission && (
-
-
-
- )}
-
- (
- }
- fullWidth
- >
- {isSubmitting ? "درحال دریافت اطلاعات" : "جستجو"}
-
- )}
- />
-
-
- );
-};
-
-export default SearchReportField;
diff --git a/src/components/dashboard/receipt/report/Search/SelectProvince.jsx b/src/components/dashboard/receipt/report/Search/SelectProvince.jsx
deleted file mode 100644
index b1d8a39..0000000
--- a/src/components/dashboard/receipt/report/Search/SelectProvince.jsx
+++ /dev/null
@@ -1,47 +0,0 @@
-import { Controller } from "react-hook-form";
-import MuiDatePicker from "@/core/components/MuiDatePicker";
-import React from "react";
-import { FormControl, FormHelperText, InputLabel, LinearProgress, MenuItem, Select, Typography } from "@mui/material";
-import useProvinces from "@/lib/hooks/useProvince";
-
-const SelectProvince = ({ control }) => {
- const { provinces, loadingProvinces, errorProvinces } = useProvinces();
- return (
- (
-
- استان
-
- {error && {error.message}}
-
- )}
- />
- );
-};
-export default SelectProvince;
diff --git a/src/components/dashboard/receipt/report/Search/ToDateController.jsx b/src/components/dashboard/receipt/report/Search/ToDateController.jsx
deleted file mode 100644
index 6f8b0d8..0000000
--- a/src/components/dashboard/receipt/report/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/receipt/report/Search/index.jsx b/src/components/dashboard/receipt/report/Search/index.jsx
deleted file mode 100644
index f29d302..0000000
--- a/src/components/dashboard/receipt/report/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/receipt/report/Toolbar.jsx b/src/components/dashboard/receipt/report/Toolbar.jsx
deleted file mode 100644
index 7dd930f..0000000
--- a/src/components/dashboard/receipt/report/Toolbar.jsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import PrintExcel from "./ExcelPrint";
-import { Box } from "@mui/material";
-
-const Toolbar = ({ table, filterData, mutate }) => {
- return (
-
-
-
- );
-};
-export default Toolbar;
diff --git a/src/components/dashboard/receipt/report/index.jsx b/src/components/dashboard/receipt/report/index.jsx
deleted file mode 100644
index 3efedfe..0000000
--- a/src/components/dashboard/receipt/report/index.jsx
+++ /dev/null
@@ -1,135 +0,0 @@
-'use client'
-import PageTitle from "@/core/components/PageTitle";
-import { GET_CITY_RECEIPT_REPORT, GET_PROVINCE_RECEIPT_REPORT } from "@/core/utils/routes";
-import { useAuth } from "@/lib/contexts/auth";
-import { usePermissions } from "@/lib/hooks/usePermissions";
-import useRequest from "@/lib/hooks/useRequest";
-import { yupResolver } from "@hookform/resolvers/yup";
-import { LinearProgress, Stack } from "@mui/material";
-import moment from "jalali-moment";
-import { useEffect, useState } from "react";
-import { useForm } from "react-hook-form";
-import * as yup from "yup";
-import SearchReportList from "./Search";
-import ReportLists from "./ReportLists";
-
-const ReceiptReportPage = () => {
- const [data, setData] = useState([]);
- const { data: userPermissions } = usePermissions();
- const { user } = useAuth();
- const requestServer = useRequest();
- const hasProvincesPermission = userPermissions?.includes("show-receipt");
-
- const defaultValues = {
- from_date: moment(new Date()).format("YYYY-MM-DD"),
- date_to: moment(new Date()).format("YYYY-MM-DD"),
- province_id: hasProvincesPermission ? "-1" : user.province_id,
- };
- const defaultFilter = [
- { value: `${defaultValues.province_id}`, datatype: "numeric", id: "province_id", fn: "equals" },
- { value: `${defaultValues.from_date}`, datatype: "date", id: "from_date", fn: "between" },
- { value: `${defaultValues.date_to}`, datatype: "date", id: "date_to", fn: "between" },
- ];
- const [specialFilter, setSpecialFilter] = useState(defaultFilter);
-
- const onSearchSubmit = async (data) => {
- const params = new URLSearchParams();
- params.set("from_date", `${data.from_date}`);
- params.set("date_to", `${data.date_to}`);
- setSpecialFilter([
- { value: `${data.province_id}`, datatype: "numeric", id: "province_id", fn: "equals" },
- { value: `${data.from_date}`, datatype: "date", id: "from_date", fn: "between" },
- { value: `${data.date_to}`, datatype: "date", id: "date_to", fn: "between" },
- ]);
- if (data.province_id === "-1") {
- try {
- const response = await requestServer(`${GET_PROVINCE_RECEIPT_REPORT}?${params}`);
- const result = response.data.data;
- const nationalReportForItem = result.activities.find((report) => report.province_id === -1);
- const nationalReport = {
- edare_name: "کل کشور",
- ...nationalReportForItem,
- };
-
- setData({
- data: [
- nationalReport,
- ...result.provinces.map((province) => {
- const filteredReports = result.activities.find(
- (report) => report.province_id === province.id
- );
- return {
- ...filteredReports,
- edare_name: province.name_fa,
- };
- }),
- ],
- filters: data,
- });
- } catch (e) { }
- } else {
- try {
- params.set("province_id", `${data.province_id}`);
- const response = await requestServer(`${GET_CITY_RECEIPT_REPORT}?${params}`);
- const result = response.data.data;
- const nationalReportForItem = result.activities.find((report) => report.edare_id === "-1");
- const nationalReport = {
- ...nationalReportForItem,
- edare_name: "کل استان",
- };
- setData({
- data: [
- nationalReport,
- ...result.edarateShahri.map((edare) => {
- const filteredReports = result.activities.find((report) => report.edare_id == edare.id);
- return {
- edare_name: edare.name_fa,
- ...filteredReports,
- };
- }),
- ],
- filters: data,
- });
- } catch (e) { }
- }
- };
-
- useEffect(() => {
- if (!userPermissions) return
- onSearchSubmit(defaultValues);
- }, [userPermissions]);
-
- const validationSchema = yup.object().shape({
- from_date: yup
- .string()
- .required("تاریخ شروع الزامی است!")
- .matches(/^\d{4}-\d{2}-\d{2}$/, "تاریخ شروع الزامی است!")
- .test("is-valid-date", "تاریخ شروع معتبر نیست!", (value) => moment(value, "YYYY-MM-DD", true).isValid()),
- date_to: yup
- .string()
- .required("تاریخ پایان الزامی است!")
- .matches(/^\d{4}-\d{2}-\d{2}$/, "تاریخ پایان الزامی است!")
- .test("is-valid-date", "تاریخ پایان معتبر نیست!", (value) => moment(value, "YYYY-MM-DD", true).isValid()),
- province_id: yup.string().nullable(),
- });
-
- const { control, handleSubmit } = useForm({
- defaultValues,
- resolver: yupResolver(validationSchema),
- mode: "onBlur",
- });
-
- return (
-
-
-
- {!data ? : }
-
- );
-}
-export default ReceiptReportPage
\ No newline at end of file
diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js
index 58bcda3..6dc868c 100644
--- a/src/core/utils/routes.js
+++ b/src/core/utils/routes.js
@@ -79,12 +79,6 @@ export const GET_IMAGES_ROAD_ITEM = api + "/api/v3/road_items/files";
export const GET_CMMS_MACHINE_ROAD_ITEM = api + "/api/v3/road_items/machines";
export const GET_RAHDARAN_ROAD_ITEM = api + "/api/v3/road_items/rahdaran";
-// recept report
-export const GET_PROVINCE_RECEIPT_REPORT = api + "/api/v3/receipt_reports/country_activity";
-export const GET_CITY_RECEIPT_REPORT = api + "/api/v3/receipt_reports/province_activity";
-export const EXPORT_COUNTRY_RECEIPT_REPORT = api + "/api/v3/receipt_reports/country_activity_excel";
-export const EXPORT_PROVINCE_RECEIPT_REPORT = api + "/api/v3/receipt_reports/province_activity_excel";
-
// damage items
export const GET_RECEIPT_DAMAGE_ITEMS_LIST = api + "/api/v3/damages";
export const CREATE_RECEIPT_DAMAGE_ITEMS = api + "/api/v3/damages";
@@ -96,10 +90,10 @@ export const GET_TECHNICAL_DAMAGE_OPERATOR_LIST = api + "/api/v3/receipts";
export const GET_DAMAGE_ITEM_LIST = api + "/api/v3/damages/list";
// recept report
+export const GET_COUNTRY_RECEIPT_REPORT = api + "/api/v3/receipt_reports/country_report";
export const GET_PROVINCE_RECEIPT_REPORT = api + "/api/v3/receipt_reports/province_report";
-export const GET_CITY_RECEIPT_REPORT = api + "/api/v3/receipt_reports/city_report";
-export const EXPORT_COUNTRY_RECEIPT_REPORT = api + "/api/v3/receipt_reports/province_excel_report";
-export const EXPORT_PROVINCE_RECEIPT_REPORT = api + "/api/v3/receipt_reports/city_excel_report";
+export const EXPORT_COUNTRY_RECEIPT_REPORT = api + "/api/v3/receipt_reports/country_excel_report";
+export const EXPORT_PROVINCE_RECEIPT_REPORT = api + "/api/v3/receipt_reports/province_excel_report";
// activity code log
export const ACTIVITY_LOG = api + "/api/v3/profile/add_activity";