Merge branch 'release/v1.8.4'
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
HOST="rms.witel.ir"
|
||||
NEXT_PUBLIC_VERSION="1.8.3"
|
||||
HOST_RMTO="rms.rmto.ir"
|
||||
NEXT_PUBLIC_VERSION="1.8.4"
|
||||
NEXT_PUBLIC_API_URL="https://rms.witel.ir"
|
||||
NEXT_PUBLIC_MAPTILE_ENDPOINT="https://rmsmap.rmto.ir/141map"
|
||||
@@ -1,12 +1,27 @@
|
||||
// javascript for production
|
||||
{
|
||||
"compilerOptions": {
|
||||
"paths": {
|
||||
"@/*": [
|
||||
"./src/*"
|
||||
],
|
||||
"^/*": [
|
||||
"./public/*"
|
||||
]
|
||||
"compilerOptions": {
|
||||
"paths": {
|
||||
"@/*": ["./src/*"],
|
||||
"^/*": ["./public/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// typescript for local development
|
||||
// {
|
||||
// "compilerOptions": {
|
||||
// "jsx": "react-jsx",
|
||||
// "noUnusedLocals": true,
|
||||
// "noImplicitAny": false,
|
||||
// "checkJs": true,
|
||||
// "allowJs": true,
|
||||
// "strict": true,
|
||||
// "baseUrl": ".",
|
||||
// "paths": {
|
||||
// "@/*": ["./src/*"],
|
||||
// "^/*": ["./public/*"]
|
||||
// }
|
||||
// },
|
||||
// "exclude": ["node_modules"]
|
||||
// }
|
||||
|
||||
@@ -7,6 +7,10 @@ const nextConfig = {
|
||||
protocol: 'https',
|
||||
hostname: process.env.HOST,
|
||||
},
|
||||
{
|
||||
protocol: 'https',
|
||||
hostname: process.env.HOST_RMTO,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
"@mui/material-nextjs": "^5.16.6",
|
||||
"@mui/x-date-pickers": "^6.19.5",
|
||||
"@mui/x-tree-view": "^7.11.0",
|
||||
"@turf/turf": "^7.2.0",
|
||||
"axios": "^1.7.2",
|
||||
"date-fns": "^3.3.1",
|
||||
"date-fns-jalali": "^2.13.0-0",
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import AssistantZaminGovComponent from "@/components/dashboard/inquiryPrivacy/assistant/zaminGov";
|
||||
import WithPermission from "@/core/middlewares/withPermission";
|
||||
|
||||
const Page = () => {
|
||||
return (
|
||||
<WithPermission>
|
||||
<AssistantZaminGovComponent />
|
||||
</WithPermission>
|
||||
);
|
||||
};
|
||||
|
||||
export default Page;
|
||||
@@ -0,0 +1,14 @@
|
||||
import CityAdminPage from "@/components/dashboard/inquiryPrivacy/city-admin";
|
||||
import WithPermission from "@/core/middlewares/withPermission";
|
||||
export const metadata = {
|
||||
title: "کارتابل شهرستان",
|
||||
};
|
||||
const Page = () => {
|
||||
return (
|
||||
<WithPermission permission_name={["all"]}>
|
||||
<CityAdminPage />
|
||||
</WithPermission>
|
||||
);
|
||||
};
|
||||
|
||||
export default Page;
|
||||
@@ -1,12 +0,0 @@
|
||||
import CityAdminZaminGovComponent from "@/components/dashboard/inquiryPrivacy/cityAdmin/zaminGov";
|
||||
import WithPermission from "@/core/middlewares/withPermission";
|
||||
|
||||
const Page = () => {
|
||||
return (
|
||||
<WithPermission>
|
||||
<CityAdminZaminGovComponent />
|
||||
</WithPermission>
|
||||
);
|
||||
};
|
||||
|
||||
export default Page;
|
||||
@@ -0,0 +1,14 @@
|
||||
import WithPermission from "@/core/middlewares/withPermission";
|
||||
import GeneralManagerPage from "@/components/dashboard/inquiryPrivacy/general-manager";
|
||||
export const metadata = {
|
||||
title: "کارتابل مدیر",
|
||||
};
|
||||
const Page = () => {
|
||||
return (
|
||||
<WithPermission permission_name={["all"]}>
|
||||
<GeneralManagerPage />
|
||||
</WithPermission>
|
||||
);
|
||||
};
|
||||
|
||||
export default Page;
|
||||
@@ -1,12 +0,0 @@
|
||||
import GeneralManagerZaminGovComponent from "@/components/dashboard/inquiryPrivacy/generalManager/zaminGov";
|
||||
import WithPermission from "@/core/middlewares/withPermission";
|
||||
|
||||
const Page = () => {
|
||||
return (
|
||||
<WithPermission>
|
||||
<GeneralManagerZaminGovComponent />
|
||||
</WithPermission>
|
||||
);
|
||||
};
|
||||
|
||||
export default Page;
|
||||
@@ -0,0 +1,14 @@
|
||||
import PrivacyOfficePage from "@/components/dashboard/inquiryPrivacy/privacy-office";
|
||||
import WithPermission from "@/core/middlewares/withPermission";
|
||||
export const metadata = {
|
||||
title: "کارتابل اداره حریم",
|
||||
};
|
||||
const Page = () => {
|
||||
return (
|
||||
<WithPermission permission_name={["all"]}>
|
||||
<PrivacyOfficePage />
|
||||
</WithPermission>
|
||||
);
|
||||
};
|
||||
|
||||
export default Page;
|
||||
@@ -1,12 +0,0 @@
|
||||
import ProvinceAdminZaminGovComponent from "@/components/dashboard/inquiryPrivacy/provinceAdmin/zaminGov";
|
||||
import WithPermission from "@/core/middlewares/withPermission";
|
||||
|
||||
const Page = () => {
|
||||
return (
|
||||
<WithPermission>
|
||||
<ProvinceAdminZaminGovComponent />
|
||||
</WithPermission>
|
||||
);
|
||||
};
|
||||
|
||||
export default Page;
|
||||
@@ -0,0 +1,14 @@
|
||||
import TechnicalDeputy from "@/components/dashboard/inquiryPrivacy/technical-deputy";
|
||||
import WithPermission from "@/core/middlewares/withPermission";
|
||||
export const metadata = {
|
||||
title: "کارتابل معاون",
|
||||
};
|
||||
const Page = () => {
|
||||
return (
|
||||
<WithPermission permission_name={["all"]}>
|
||||
<TechnicalDeputy />
|
||||
</WithPermission>
|
||||
);
|
||||
};
|
||||
|
||||
export default Page;
|
||||
@@ -1,12 +1,12 @@
|
||||
import RahdaranTablePage from "@/components/dashboard/rahdaran";
|
||||
import WithPermission from "@/core/middlewares/withPermission";
|
||||
|
||||
export default function page() {
|
||||
return (
|
||||
<WithPermission
|
||||
permission_name={["manage-rahdaran-country", "manage-rahdaran-province", "manage-rahdaran-edareh"]}
|
||||
>
|
||||
<RahdaranTablePage />
|
||||
</WithPermission>
|
||||
);
|
||||
}
|
||||
import RahdaranTablePage from "@/components/dashboard/rahdaran";
|
||||
import WithPermission from "@/core/middlewares/withPermission";
|
||||
|
||||
export default function page() {
|
||||
return (
|
||||
<WithPermission
|
||||
permission_name={["manage-rahdaran-country", "manage-rahdaran-province", "manage-rahdaran-edareh"]}
|
||||
>
|
||||
<RahdaranTablePage />
|
||||
</WithPermission>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,14 @@ export const metadata = {
|
||||
const Page = () => {
|
||||
return (
|
||||
<>
|
||||
<WithPermission permission_name={["manage-control-unit"]}>
|
||||
<WithPermission
|
||||
permission_name={[
|
||||
"manage-control-unit",
|
||||
"manage-control-unit-city",
|
||||
"manage-control-unit-country",
|
||||
"manage-control-unit-station",
|
||||
]}
|
||||
>
|
||||
<ControlPage />
|
||||
{/* <ActivityCodeLog activity_code={1152} /> */}
|
||||
</WithPermission>
|
||||
|
||||
@@ -12,6 +12,7 @@ const Page = () => {
|
||||
"manage-request-portal-country",
|
||||
"manage-request-portal-province",
|
||||
"manage-request-portal-city",
|
||||
"manage-request-portal-station",
|
||||
]}
|
||||
>
|
||||
<OperatorPage />
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import WithPermission from "@/core/middlewares/withPermission";
|
||||
import ReportPage from "@/components/dashboard/roadMissions/reports";
|
||||
export const metadata = {
|
||||
title: "کارتابل گزارش ماموریت",
|
||||
};
|
||||
const Page = () => {
|
||||
return (
|
||||
<WithPermission
|
||||
permission_name={[
|
||||
"all", // TODO : change permission
|
||||
]}
|
||||
>
|
||||
<ReportPage />
|
||||
</WithPermission>
|
||||
);
|
||||
};
|
||||
|
||||
export default Page;
|
||||
@@ -7,7 +7,14 @@ export const metadata = {
|
||||
const Page = () => {
|
||||
return (
|
||||
<>
|
||||
<WithPermission permission_name={["manage-transportation-unit"]}>
|
||||
<WithPermission
|
||||
permission_name={[
|
||||
"manage-transportation-unit-country",
|
||||
"manage-transportation-unit-city",
|
||||
"manage-transportation-unit-country",
|
||||
"manage-transportation-unit-station",
|
||||
]}
|
||||
>
|
||||
<TransportationPage />
|
||||
{/* <ActivityCodeLog activity_code={1152} /> */}
|
||||
</WithPermission>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import ViolationsPage from "@/components/dashboard/roadMissions/violations";
|
||||
import WithPermission from "@/core/middlewares/withPermission";
|
||||
export const metadata = {
|
||||
title: "کارتابل تخلفات",
|
||||
};
|
||||
const Page = () => {
|
||||
return (
|
||||
<>
|
||||
<WithPermission permission_name={["all"]}>
|
||||
<ViolationsPage />
|
||||
{/* <ActivityCodeLog activity_code={1152} /> */}
|
||||
</WithPermission>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Page;
|
||||
@@ -1,19 +1,19 @@
|
||||
import ReportAccessRoadPage from "@/components/dashboard/roadSafety/reports/accessRoad";
|
||||
import WithPermission from "@/core/middlewares/withPermission";
|
||||
export const metadata = {
|
||||
title: "گزارش بر اساس راه دسترسی غیر مجاز",
|
||||
};
|
||||
const Page = () => {
|
||||
return (
|
||||
<WithPermission
|
||||
permission_name={[
|
||||
"show-safety-and-privacy-operator-cartable",
|
||||
"show-safety-and-privacy-operator-cartable-province",
|
||||
"show-safety-and-privacy-operator-cartable-edarate-shahri",
|
||||
]}
|
||||
>
|
||||
<ReportAccessRoadPage />
|
||||
</WithPermission>
|
||||
);
|
||||
};
|
||||
export default Page;
|
||||
import ReportAccessRoadPage from "@/components/dashboard/roadSafety/reports/accessRoad";
|
||||
import WithPermission from "@/core/middlewares/withPermission";
|
||||
export const metadata = {
|
||||
title: "گزارش بر اساس راه دسترسی غیر مجاز",
|
||||
};
|
||||
const Page = () => {
|
||||
return (
|
||||
<WithPermission
|
||||
permission_name={[
|
||||
"show-safety-and-privacy-operator-cartable",
|
||||
"show-safety-and-privacy-operator-cartable-province",
|
||||
"show-safety-and-privacy-operator-cartable-edarate-shahri",
|
||||
]}
|
||||
>
|
||||
<ReportAccessRoadPage />
|
||||
</WithPermission>
|
||||
);
|
||||
};
|
||||
export default Page;
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import ReportConstructionActivityPage from "@/components/dashboard/roadSafety/reports/constructionActivity";
|
||||
import WithPermission from "@/core/middlewares/withPermission";
|
||||
export const metadata = {
|
||||
title: "گزارش بر اساس ساخت و ساز غیر مجاز",
|
||||
};
|
||||
const Page = () => {
|
||||
return (
|
||||
<WithPermission
|
||||
permission_name={[
|
||||
"show-safety-and-privacy-operator-cartable",
|
||||
"show-safety-and-privacy-operator-cartable-province",
|
||||
"show-safety-and-privacy-operator-cartable-edarate-shahri",
|
||||
]}
|
||||
>
|
||||
<ReportConstructionActivityPage />
|
||||
</WithPermission>
|
||||
);
|
||||
};
|
||||
export default Page;
|
||||
import ReportConstructionActivityPage from "@/components/dashboard/roadSafety/reports/constructionActivity";
|
||||
import WithPermission from "@/core/middlewares/withPermission";
|
||||
export const metadata = {
|
||||
title: "گزارش بر اساس ساخت و ساز غیر مجاز",
|
||||
};
|
||||
const Page = () => {
|
||||
return (
|
||||
<WithPermission
|
||||
permission_name={[
|
||||
"show-safety-and-privacy-operator-cartable",
|
||||
"show-safety-and-privacy-operator-cartable-province",
|
||||
"show-safety-and-privacy-operator-cartable-edarate-shahri",
|
||||
]}
|
||||
>
|
||||
<ReportConstructionActivityPage />
|
||||
</WithPermission>
|
||||
);
|
||||
};
|
||||
export default Page;
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import ReportUtilityPassingActivityPage from "@/components/dashboard/roadSafety/reports/utilityPassingActivity";
|
||||
import WithPermission from "@/core/middlewares/withPermission";
|
||||
export const metadata = {
|
||||
title: "گزارش بر اساس عبور تاسیسات زیربنایی غیر مجاز",
|
||||
};
|
||||
const Page = () => {
|
||||
return (
|
||||
<WithPermission
|
||||
permission_name={[
|
||||
"show-safety-and-privacy-operator-cartable",
|
||||
"show-safety-and-privacy-operator-cartable-province",
|
||||
"show-safety-and-privacy-operator-cartable-edarate-shahri",
|
||||
]}
|
||||
>
|
||||
<ReportUtilityPassingActivityPage />
|
||||
</WithPermission>
|
||||
);
|
||||
};
|
||||
export default Page;
|
||||
import ReportUtilityPassingActivityPage from "@/components/dashboard/roadSafety/reports/utilityPassingActivity";
|
||||
import WithPermission from "@/core/middlewares/withPermission";
|
||||
export const metadata = {
|
||||
title: "گزارش بر اساس عبور تاسیسات زیربنایی غیر مجاز",
|
||||
};
|
||||
const Page = () => {
|
||||
return (
|
||||
<WithPermission
|
||||
permission_name={[
|
||||
"show-safety-and-privacy-operator-cartable",
|
||||
"show-safety-and-privacy-operator-cartable-province",
|
||||
"show-safety-and-privacy-operator-cartable-edarate-shahri",
|
||||
]}
|
||||
>
|
||||
<ReportUtilityPassingActivityPage />
|
||||
</WithPermission>
|
||||
);
|
||||
};
|
||||
export default Page;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
"use client";
|
||||
import PageLoading from "@/core/components/PageLoading";
|
||||
|
||||
const Loading = () => {
|
||||
return <PageLoading />;
|
||||
};
|
||||
export default Loading;
|
||||
@@ -0,0 +1,16 @@
|
||||
import WithPermission from "@/core/middlewares/withPermission";
|
||||
import TollHouseMapPage from "@/components/infrastructure/tollHouseMap";
|
||||
|
||||
export const metadata = {
|
||||
title: "پراکندگی بر روی نقشه راهدارخانه ها",
|
||||
};
|
||||
|
||||
const Page = () => {
|
||||
return (
|
||||
<WithPermission permission_name={["show-tollhouse", "show-tollhouse-province"]}>
|
||||
<TollHouseMapPage />
|
||||
</WithPermission>
|
||||
);
|
||||
};
|
||||
|
||||
export default Page;
|
||||
@@ -1,75 +1,75 @@
|
||||
"use client";
|
||||
import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure";
|
||||
import isArrayEmpty from "@/core/utils/isArrayEmpty";
|
||||
import { EXPORT_DAMAGES_ITEMS } 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 && (!Array.isArray(filter.value) || filter.value.some((item) => item.trim() !== ""))) {
|
||||
acc.push({ id: key, value: filter.value });
|
||||
}
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
const filterParams = useMemo(() => {
|
||||
const params = new URLSearchParams();
|
||||
if (activeFilters.length > 0) {
|
||||
activeFilters.map((filter, index) => {
|
||||
const filteredFilterData = DataTableFilterDataStructure(filterData, isArrayEmpty);
|
||||
params.set("filters", JSON.stringify(filteredFilterData.length === 0 ? [] : filteredFilterData));
|
||||
});
|
||||
} else {
|
||||
params.set("filters", JSON.stringify([]));
|
||||
}
|
||||
return params;
|
||||
}, [activeFilters]);
|
||||
|
||||
const clickHandler = () => {
|
||||
setLoading(true);
|
||||
requestServer(`${EXPORT_DAMAGES_ITEMS}?${filterParams}`, "get", {
|
||||
requestOptions: { responseType: "blob" },
|
||||
})
|
||||
.then((response) => {
|
||||
const filename = `خروجی لیست آیتم های خسارات وارده بر ابنیه فنی تاریخ_${moment().format("jYYYY_jMM_jDD")}.xlsx`;
|
||||
FileSaver.saveAs(response.data, filename);
|
||||
})
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{isMobile ? (
|
||||
<IconButton aria-label="خروجی اکسل" color="success" onClick={clickHandler}>
|
||||
<DescriptionIcon sx={{ fontSize: "25px" }} />
|
||||
</IconButton>
|
||||
) : (
|
||||
<Button
|
||||
color="success"
|
||||
variant="contained"
|
||||
size="small"
|
||||
disabled={loading}
|
||||
sx={{ textTransform: "unset", alignSelf: "center" }}
|
||||
startIcon={loading ? <CircularProgress size={18} color="inherit" /> : <DescriptionIcon />}
|
||||
onClick={clickHandler}
|
||||
>
|
||||
خروجی اکسل
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default PrintExcel;
|
||||
"use client";
|
||||
import DataTableFilterDataStructure from "@/core/utils/DataTableFilterDataStructure";
|
||||
import isArrayEmpty from "@/core/utils/isArrayEmpty";
|
||||
import { EXPORT_DAMAGES_ITEMS } 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 && (!Array.isArray(filter.value) || filter.value.some((item) => item.trim() !== ""))) {
|
||||
acc.push({ id: key, value: filter.value });
|
||||
}
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
const filterParams = useMemo(() => {
|
||||
const params = new URLSearchParams();
|
||||
if (activeFilters.length > 0) {
|
||||
activeFilters.map((filter, index) => {
|
||||
const filteredFilterData = DataTableFilterDataStructure(filterData, isArrayEmpty);
|
||||
params.set("filters", JSON.stringify(filteredFilterData.length === 0 ? [] : filteredFilterData));
|
||||
});
|
||||
} else {
|
||||
params.set("filters", JSON.stringify([]));
|
||||
}
|
||||
return params;
|
||||
}, [activeFilters]);
|
||||
|
||||
const clickHandler = () => {
|
||||
setLoading(true);
|
||||
requestServer(`${EXPORT_DAMAGES_ITEMS}?${filterParams}`, "get", {
|
||||
requestOptions: { responseType: "blob" },
|
||||
})
|
||||
.then((response) => {
|
||||
const filename = `خروجی لیست آیتم های خسارات وارده بر ابنیه فنی تاریخ_${moment().format("jYYYY_jMM_jDD")}.xlsx`;
|
||||
FileSaver.saveAs(response.data, filename);
|
||||
})
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{isMobile ? (
|
||||
<IconButton aria-label="خروجی اکسل" color="success" onClick={clickHandler}>
|
||||
<DescriptionIcon sx={{ fontSize: "25px" }} />
|
||||
</IconButton>
|
||||
) : (
|
||||
<Button
|
||||
color="success"
|
||||
variant="contained"
|
||||
size="small"
|
||||
disabled={loading}
|
||||
sx={{ textTransform: "unset", alignSelf: "center" }}
|
||||
startIcon={loading ? <CircularProgress size={18} color="inherit" /> : <DescriptionIcon />}
|
||||
onClick={clickHandler}
|
||||
>
|
||||
خروجی اکسل
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default PrintExcel;
|
||||
|
||||
@@ -1,57 +1,57 @@
|
||||
import LtrTextField from "@/core/components/LtrTextField";
|
||||
import { useState } from "react";
|
||||
import { useWatch } from "react-hook-form";
|
||||
|
||||
const LocationInputs = ({ control, setValue, errors }) => {
|
||||
const StartPoint = useWatch({ control, name: "start_point" });
|
||||
const [coords, setCoords] = useState(StartPoint ? `${StartPoint.lat},${StartPoint.lng}` : "");
|
||||
const [error, setError] = useState(false);
|
||||
|
||||
return (
|
||||
<LtrTextField
|
||||
autoComplete="off"
|
||||
size="small"
|
||||
label="عرض و طول جغرافیایی (Latitude, Longitude)"
|
||||
placeholder="مثال: 35.7219, 51.3347"
|
||||
fullWidth
|
||||
helperText={
|
||||
error
|
||||
? "فرمت یا محدوده مقادیر معتبر نیست (ابتدا عرض جغرافیایی + , + انتها طول جغرافیایی)"
|
||||
: errors.start_point
|
||||
? errors.start_point.message
|
||||
: "ابتدا عرض جغرافیایی + , + انتها طول جغرافیایی"
|
||||
}
|
||||
error={error || errors.start_point}
|
||||
value={coords}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value.trim();
|
||||
setCoords(value);
|
||||
|
||||
if (value === "") {
|
||||
setValue("start_point", null);
|
||||
setError(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const parts = value.split(",").map((p) => p.trim());
|
||||
if (parts.length !== 2) {
|
||||
setError(true);
|
||||
return;
|
||||
}
|
||||
|
||||
const lat = Number(parts[0]);
|
||||
const lng = Number(parts[1]);
|
||||
|
||||
if (!isNaN(lat) && !isNaN(lng) && lat >= 25 && lat <= 40 && lng >= 44 && lng <= 64) {
|
||||
setValue("start_point", { lat: lat, lng: lng });
|
||||
setError(false);
|
||||
} else {
|
||||
setValue("start_point", null);
|
||||
setError(true);
|
||||
}
|
||||
}}
|
||||
InputLabelProps={{ shrink: true }}
|
||||
/>
|
||||
);
|
||||
};
|
||||
export default LocationInputs;
|
||||
import LtrTextField from "@/core/components/LtrTextField";
|
||||
import { useState } from "react";
|
||||
import { useWatch } from "react-hook-form";
|
||||
|
||||
const LocationInputs = ({ control, setValue, errors }) => {
|
||||
const StartPoint = useWatch({ control, name: "start_point" });
|
||||
const [coords, setCoords] = useState(StartPoint ? `${StartPoint.lat},${StartPoint.lng}` : "");
|
||||
const [error, setError] = useState(false);
|
||||
|
||||
return (
|
||||
<LtrTextField
|
||||
autoComplete="off"
|
||||
size="small"
|
||||
label="عرض و طول جغرافیایی (Latitude, Longitude)"
|
||||
placeholder="مثال: 35.7219, 51.3347"
|
||||
fullWidth
|
||||
helperText={
|
||||
error
|
||||
? "فرمت یا محدوده مقادیر معتبر نیست (ابتدا عرض جغرافیایی + , + انتها طول جغرافیایی)"
|
||||
: errors.start_point
|
||||
? errors.start_point.message
|
||||
: "ابتدا عرض جغرافیایی + , + انتها طول جغرافیایی"
|
||||
}
|
||||
error={error || errors.start_point}
|
||||
value={coords}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value.trim();
|
||||
setCoords(value);
|
||||
|
||||
if (value === "") {
|
||||
setValue("start_point", null);
|
||||
setError(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const parts = value.split(",").map((p) => p.trim());
|
||||
if (parts.length !== 2) {
|
||||
setError(true);
|
||||
return;
|
||||
}
|
||||
|
||||
const lat = Number(parts[0]);
|
||||
const lng = Number(parts[1]);
|
||||
|
||||
if (!isNaN(lat) && !isNaN(lng) && lat >= 25 && lat <= 40 && lng >= 44 && lng <= 64) {
|
||||
setValue("start_point", { lat: lat, lng: lng });
|
||||
setError(false);
|
||||
} else {
|
||||
setValue("start_point", null);
|
||||
setError(true);
|
||||
}
|
||||
}}
|
||||
InputLabelProps={{ shrink: true }}
|
||||
/>
|
||||
);
|
||||
};
|
||||
export default LocationInputs;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { Download } from "@mui/icons-material";
|
||||
import { IconButton, Tooltip } from "@mui/material";
|
||||
|
||||
const ButtonDownload = ({ url, title }) => {
|
||||
return (
|
||||
<Tooltip title={title}>
|
||||
<IconButton href={url} target="_blank" color="primary" rel="noopener noreferrer">
|
||||
<Download />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
);
|
||||
};
|
||||
export default ButtonDownload;
|
||||
import { Download } from "@mui/icons-material";
|
||||
import { IconButton, Tooltip } from "@mui/material";
|
||||
|
||||
const ButtonDownload = ({ url, title }) => {
|
||||
return (
|
||||
<Tooltip title={title}>
|
||||
<IconButton href={url} target="_blank" color="primary" rel="noopener noreferrer">
|
||||
<Download />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
);
|
||||
};
|
||||
export default ButtonDownload;
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
import { Close } from "@mui/icons-material";
|
||||
import { Dialog, DialogTitle, IconButton } from "@mui/material";
|
||||
import ChangeStatusForm from "./Form";
|
||||
|
||||
const ChangeStatusDialog = ({ open, setOpen, mutate, row }) => {
|
||||
return (
|
||||
<Dialog open={open} fullWidth maxWidth="xs">
|
||||
<IconButton
|
||||
aria-label="close"
|
||||
onClick={() => setOpen(false)}
|
||||
sx={(theme) => ({
|
||||
position: "absolute",
|
||||
right: 8,
|
||||
top: 8,
|
||||
zIndex: 50,
|
||||
color: theme.palette.grey[500],
|
||||
})}
|
||||
>
|
||||
<Close />
|
||||
</IconButton>
|
||||
<DialogTitle>تغییر وضعیت</DialogTitle>
|
||||
{open && <ChangeStatusForm setOpen={setOpen} mutate={mutate} row={row} />}
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
export default ChangeStatusDialog;
|
||||
import { Close } from "@mui/icons-material";
|
||||
import { Dialog, DialogTitle, IconButton } from "@mui/material";
|
||||
import ChangeStatusForm from "./Form";
|
||||
|
||||
const ChangeStatusDialog = ({ open, setOpen, mutate, row }) => {
|
||||
return (
|
||||
<Dialog open={open} fullWidth maxWidth="xs">
|
||||
<IconButton
|
||||
aria-label="close"
|
||||
onClick={() => setOpen(false)}
|
||||
sx={(theme) => ({
|
||||
position: "absolute",
|
||||
right: 8,
|
||||
top: 8,
|
||||
zIndex: 50,
|
||||
color: theme.palette.grey[500],
|
||||
})}
|
||||
>
|
||||
<Close />
|
||||
</IconButton>
|
||||
<DialogTitle>تغییر وضعیت</DialogTitle>
|
||||
{open && <ChangeStatusForm setOpen={setOpen} mutate={mutate} row={row} />}
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
export default ChangeStatusDialog;
|
||||
|
||||
@@ -1,96 +1,96 @@
|
||||
import SelectBox from "@/core/components/SelectBox";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import { CHANGE_STATUS_RECEIPT } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { Beenhere, ExitToApp } from "@mui/icons-material";
|
||||
import { Button, DialogActions, DialogContent, Grid, Stack } from "@mui/material";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { object, string } from "yup";
|
||||
|
||||
const validationSchema = object({
|
||||
status: string().required("وضعیت را مشخص کنید!"),
|
||||
});
|
||||
|
||||
const ChangeStatusForm = ({ setOpen, mutate, row }) => {
|
||||
const requestServer = useRequest({ notificationSuccess: true });
|
||||
const defaultValues = {
|
||||
status: row.original.status || "",
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
setOpen(false);
|
||||
};
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
formState: { isSubmitting },
|
||||
} = useForm({
|
||||
defaultValues,
|
||||
resolver: yupResolver(validationSchema),
|
||||
mode: "all",
|
||||
});
|
||||
const onSubmitBase = async (data) => {
|
||||
const formData = new FormData();
|
||||
formData.append("status_id", data.status);
|
||||
await requestServer(`${CHANGE_STATUS_RECEIPT}/${row.original.id}`, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then((response) => {
|
||||
mutate();
|
||||
setOpen(false);
|
||||
})
|
||||
.catch((error) => {});
|
||||
};
|
||||
|
||||
return (
|
||||
<StyledForm onSubmit={handleSubmit(onSubmitBase)}>
|
||||
<DialogContent dividers sx={{ overflowY: "auto", maxHeight: "70vh" }}>
|
||||
<Stack>
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={12} sm={12} sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Controller
|
||||
control={control}
|
||||
name={"status"}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<SelectBox
|
||||
value={field.value}
|
||||
label="وضعیت"
|
||||
selectors={[
|
||||
{ id: 0, name_fa: "بدون اقدام" },
|
||||
{ id: 1, name_fa: "صدور نامه بیمه و کارشناسی داغی" },
|
||||
{ id: 2, name_fa: "فیش ها ثبت شده است" },
|
||||
{ id: 3, name_fa: "فاکتور صادر شده است" },
|
||||
{ id: 4, name_fa: "فاکتور پرداخت شده است" },
|
||||
{ id: 5, name_fa: "نامه پلیس راه صادر شده است" },
|
||||
]}
|
||||
schema={{ name: "name_fa", value: "id" }}
|
||||
error={error}
|
||||
onChange={field.onChange}
|
||||
helperText={error?.message}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
<DialogActions sx={{ alignItems: "center", justifyContent: "center" }}>
|
||||
<Button
|
||||
onClick={handleClose}
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
size="large"
|
||||
startIcon={<ExitToApp />}
|
||||
>
|
||||
بستن
|
||||
</Button>
|
||||
<Button variant="contained" size="large" disabled={isSubmitting} type={"submit"} endIcon={<Beenhere />}>
|
||||
{isSubmitting ? "در حال ثبت" : "ثبت"}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</StyledForm>
|
||||
);
|
||||
};
|
||||
export default ChangeStatusForm;
|
||||
import SelectBox from "@/core/components/SelectBox";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import { CHANGE_STATUS_RECEIPT } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { Beenhere, ExitToApp } from "@mui/icons-material";
|
||||
import { Button, DialogActions, DialogContent, Grid, Stack } from "@mui/material";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { object, string } from "yup";
|
||||
|
||||
const validationSchema = object({
|
||||
status: string().required("وضعیت را مشخص کنید!"),
|
||||
});
|
||||
|
||||
const ChangeStatusForm = ({ setOpen, mutate, row }) => {
|
||||
const requestServer = useRequest({ notificationSuccess: true });
|
||||
const defaultValues = {
|
||||
status: row.original.status || "",
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
setOpen(false);
|
||||
};
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
formState: { isSubmitting },
|
||||
} = useForm({
|
||||
defaultValues,
|
||||
resolver: yupResolver(validationSchema),
|
||||
mode: "all",
|
||||
});
|
||||
const onSubmitBase = async (data) => {
|
||||
const formData = new FormData();
|
||||
formData.append("status_id", data.status);
|
||||
await requestServer(`${CHANGE_STATUS_RECEIPT}/${row.original.id}`, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then((response) => {
|
||||
mutate();
|
||||
setOpen(false);
|
||||
})
|
||||
.catch((error) => {});
|
||||
};
|
||||
|
||||
return (
|
||||
<StyledForm onSubmit={handleSubmit(onSubmitBase)}>
|
||||
<DialogContent dividers sx={{ overflowY: "auto", maxHeight: "70vh" }}>
|
||||
<Stack>
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={12} sm={12} sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Controller
|
||||
control={control}
|
||||
name={"status"}
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<SelectBox
|
||||
value={field.value}
|
||||
label="وضعیت"
|
||||
selectors={[
|
||||
{ id: 0, name_fa: "بدون اقدام" },
|
||||
{ id: 1, name_fa: "صدور نامه بیمه و کارشناسی داغی" },
|
||||
{ id: 2, name_fa: "فیش ها ثبت شده است" },
|
||||
{ id: 3, name_fa: "فاکتور صادر شده است" },
|
||||
{ id: 4, name_fa: "فاکتور پرداخت شده است" },
|
||||
{ id: 5, name_fa: "نامه پلیس راه صادر شده است" },
|
||||
]}
|
||||
schema={{ name: "name_fa", value: "id" }}
|
||||
error={error}
|
||||
onChange={field.onChange}
|
||||
helperText={error?.message}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
<DialogActions sx={{ alignItems: "center", justifyContent: "center" }}>
|
||||
<Button
|
||||
onClick={handleClose}
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
size="large"
|
||||
startIcon={<ExitToApp />}
|
||||
>
|
||||
بستن
|
||||
</Button>
|
||||
<Button variant="contained" size="large" disabled={isSubmitting} type={"submit"} endIcon={<Beenhere />}>
|
||||
{isSubmitting ? "در حال ثبت" : "ثبت"}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</StyledForm>
|
||||
);
|
||||
};
|
||||
export default ChangeStatusForm;
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import { Reply } from "@mui/icons-material";
|
||||
import { IconButton, Tooltip } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import ChangeStatusDialog from "./Dialog";
|
||||
|
||||
const ChangeStatus = ({ row, mutate }) => {
|
||||
const [open, setOpen] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="تغییر وضعیت">
|
||||
<IconButton color="primary" onClick={() => setOpen(true)}>
|
||||
<Reply />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<ChangeStatusDialog open={open} setOpen={setOpen} mutate={mutate} row={row} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default ChangeStatus;
|
||||
import { Reply } from "@mui/icons-material";
|
||||
import { IconButton, Tooltip } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import ChangeStatusDialog from "./Dialog";
|
||||
|
||||
const ChangeStatus = ({ row, mutate }) => {
|
||||
const [open, setOpen] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="تغییر وضعیت">
|
||||
<IconButton color="primary" onClick={() => setOpen(true)}>
|
||||
<Reply />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<ChangeStatusDialog open={open} setOpen={setOpen} mutate={mutate} row={row} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default ChangeStatus;
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import { FormControl, FormHelperText, InputLabel, OutlinedInput, Stack } from "@mui/material";
|
||||
|
||||
const DescriptionForm = ({ errors, register }) => {
|
||||
return (
|
||||
<Stack>
|
||||
<FormControl error={!!errors.description} size="small" fullWidth variant="outlined">
|
||||
<InputLabel sx={{ pt: 1 }} htmlFor="description">
|
||||
توضیحات
|
||||
</InputLabel>
|
||||
<OutlinedInput
|
||||
id="description"
|
||||
label={"توضیحات"}
|
||||
multiline
|
||||
rows={6}
|
||||
{...register("description")}
|
||||
autoComplete="off"
|
||||
size="small"
|
||||
fullWidth
|
||||
sx={{ mt: 1 }}
|
||||
type="text"
|
||||
/>
|
||||
<FormHelperText id="description">
|
||||
{errors.description ? errors.description.message : null}
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default DescriptionForm;
|
||||
@@ -1,15 +0,0 @@
|
||||
import { Button } from "@mui/material";
|
||||
|
||||
const ManagerOrAssistantSubmit = ({ isSubmitting }) => {
|
||||
return (
|
||||
<>
|
||||
<Button fullWidth variant="outlined" color="secondary" disabled={isSubmitting} type={"submit"}>
|
||||
{isSubmitting ? "در حال ارسال..." : "مخالفت"}
|
||||
</Button>
|
||||
<Button fullWidth variant="contained" color="primary" type={"submit"} disabled={isSubmitting}>
|
||||
{isSubmitting ? "در حال ارسال..." : "موافقت"}
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default ManagerOrAssistantSubmit;
|
||||
@@ -1,25 +0,0 @@
|
||||
import { Card, CardContent, CardHeader, CircularProgress, Divider, Stack, Typography } from "@mui/material";
|
||||
|
||||
const PrevCartableOpinion = ({ message, loadingMessage, errorMessage }) => {
|
||||
return (
|
||||
<Stack>
|
||||
<Card variant="outlined">
|
||||
<CardHeader sx={{ pb: 0 }} title="نظر معاون راهداری استان :" />
|
||||
<CardContent>
|
||||
{errorMessage ? (
|
||||
<Typography color={"red"}>خطا در دریافت اطلاعات !!!</Typography>
|
||||
) : loadingMessage ? (
|
||||
<Typography sx={{ display: "flex", alignItems: "center", gap: 2 }}>
|
||||
<CircularProgress size={20} />
|
||||
درحال دریافت اطلاعات
|
||||
</Typography>
|
||||
) : (
|
||||
<Typography>{message}</Typography>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Divider sx={{ mt: 2 }} />
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default PrevCartableOpinion;
|
||||
@@ -1,33 +0,0 @@
|
||||
import { Card, CardContent, FormControl, FormLabel, Stack, Typography } from "@mui/material";
|
||||
|
||||
const QuestionSafetyForm = () => {
|
||||
return (
|
||||
<Stack sx={{ py: 2 }}>
|
||||
<Card
|
||||
sx={{ display: "flex", justifyContent: "center", alignItems: "center", borderColor: "primary.main" }}
|
||||
variant="outlined"
|
||||
>
|
||||
<CardContent>
|
||||
<FormControl>
|
||||
<FormLabel>
|
||||
<Typography color={"primary"} variant={"h5"} fontWeight={"bolder"}>
|
||||
آیا ایمنی راه این طرح مورد تایید است ؟
|
||||
</Typography>
|
||||
</FormLabel>
|
||||
<Stack
|
||||
sx={{ pt: 2, display: "flex", justifyContent: "center", alignItems: "center" }}
|
||||
spacing={1}
|
||||
direction={"row"}
|
||||
>
|
||||
<Typography variant={"subtitle1"}>دفتر حریم راه : </Typography>
|
||||
<Typography variant={"h5"} fontWeight={"bolder"}>
|
||||
بله
|
||||
</Typography>
|
||||
</Stack>
|
||||
</FormControl>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default QuestionSafetyForm;
|
||||
@@ -1,82 +0,0 @@
|
||||
import { DialogActions, DialogContent, Stack } from "@mui/material";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { object, string } from "yup";
|
||||
import { SUBMIT_ROAD_SAFETY_FORM } from "@/core/utils/routes";
|
||||
import usePrevStateOpinion from "@/lib/hooks/usePrevStateopinion";
|
||||
import QuestionSafetyForm from "./QuestionSafetyForm";
|
||||
import PrevCartableOpinion from "./PrevCartableOpinion";
|
||||
import DescriptionForm from "./DescriptionForm";
|
||||
import ManagerOrAssistantSubmit from "./ManagerOrAssistantSubmit";
|
||||
import ApplicantRequestDetail from "@/core/components/ApplicantRequestDetail";
|
||||
const fakeData = {
|
||||
id: 1,
|
||||
shomareh_darkhast: "2124",
|
||||
ostan: "ostan",
|
||||
shahr: "shahr",
|
||||
shahrestan: "shahrestan",
|
||||
bakhsh: "bakhsh",
|
||||
roosta: "roosta",
|
||||
tarikh_darkhast: "tarikh_darkhast",
|
||||
sazman: "sazman",
|
||||
masahat_zamin: "masahat_zamin",
|
||||
masahat_tarh: "masahat_tarh",
|
||||
gorooh_tarh: "gorooh_tarh",
|
||||
onvane_tarh: "onvane_tarh",
|
||||
address: "کرج - فلان جا - جنب پاساژ - نزدیک اونجا - اونور خیابون - زیر رو گذر - روی زیر گذر",
|
||||
file_mosavab: "file",
|
||||
polygon: [
|
||||
[51.515, -0.09],
|
||||
[51.52, -0.1],
|
||||
[51.52, -0.12],
|
||||
],
|
||||
};
|
||||
const validationSchema = object({
|
||||
description: string().required("وارد کردن توضیحات الزامیست!"),
|
||||
});
|
||||
const RoadSafetyFormContext = ({ rowId, mutate, setOpenRoadSafetyForm }) => {
|
||||
const defaultValues = {
|
||||
description: "",
|
||||
};
|
||||
const requestServer = useRequest({ notificationSuccess: true });
|
||||
const { message, loadingMessage, errorMessage } = usePrevStateOpinion();
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { isSubmitting, errors },
|
||||
} = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" });
|
||||
const onSubmit = async (data) => {
|
||||
const formData = new FormData();
|
||||
formData.append("description", data.description);
|
||||
requestServer(`${SUBMIT_ROAD_SAFETY_FORM}/${rowId}`, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then(() => {
|
||||
setOpenRoadSafetyForm(false);
|
||||
mutate();
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
return (
|
||||
<StyledForm onSubmit={handleSubmit(onSubmit)}>
|
||||
<DialogContent>
|
||||
<ApplicantRequestDetail data={fakeData} />
|
||||
<Stack spacing={2}>
|
||||
<QuestionSafetyForm />
|
||||
<PrevCartableOpinion
|
||||
message={message}
|
||||
loadingMessage={loadingMessage}
|
||||
errorMessage={errorMessage}
|
||||
/>
|
||||
<DescriptionForm register={register} errors={errors} />
|
||||
<DialogActions>
|
||||
<ManagerOrAssistantSubmit isSubmitting={isSubmitting} />
|
||||
</DialogActions>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
</StyledForm>
|
||||
);
|
||||
};
|
||||
export default RoadSafetyFormContext;
|
||||
@@ -1,52 +0,0 @@
|
||||
import { Dialog, IconButton, Stack, Tooltip } from "@mui/material";
|
||||
import EngineeringIcon from "@mui/icons-material/Engineering";
|
||||
import DialogTransition from "@/core/components/DialogTransition";
|
||||
import { useState } from "react";
|
||||
import { Close } from "@mui/icons-material";
|
||||
import RoadSafetyFormContext from "./RoadSafetyFormContext";
|
||||
|
||||
const RoadSafetyForm = ({ rowId, mutate }) => {
|
||||
const [openRoadSafetyForm, setOpenRoadSafetyForm] = useState(false);
|
||||
return (
|
||||
<Stack>
|
||||
<Tooltip title="فرم ایمنی راه" arrow placement="right">
|
||||
<IconButton
|
||||
color="primary"
|
||||
sx={{ textTransform: "unset", alignSelf: "center" }}
|
||||
onClick={() => {
|
||||
setOpenRoadSafetyForm(true);
|
||||
}}
|
||||
>
|
||||
<EngineeringIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
PaperProps={{
|
||||
sx: {
|
||||
transition: "all .3s",
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
},
|
||||
}}
|
||||
open={openRoadSafetyForm}
|
||||
maxWidth={"lg"}
|
||||
TransitionComponent={DialogTransition}
|
||||
>
|
||||
<IconButton
|
||||
aria-label="close"
|
||||
onClick={() => setOpenRoadSafetyForm(false)}
|
||||
sx={{
|
||||
position: "absolute",
|
||||
right: 8,
|
||||
top: 8,
|
||||
zIndex: 10,
|
||||
color: (theme) => theme.palette.grey[500],
|
||||
}}
|
||||
>
|
||||
<Close />
|
||||
</IconButton>
|
||||
<RoadSafetyFormContext rowId={rowId} mutate={mutate} setOpenRoadSafetyForm={setOpenRoadSafetyForm} />
|
||||
</Dialog>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default RoadSafetyForm;
|
||||
@@ -1,75 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Dialog, DialogContent } from "@mui/material";
|
||||
import { object, string } from "yup";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import ApplicantRequestDetail from "@/core/components/ApplicantRequestDetail";
|
||||
|
||||
const fakeData = {
|
||||
id: 1,
|
||||
shomareh_darkhast: "2124",
|
||||
ostan: "ostan",
|
||||
shahr: "shahr",
|
||||
shahrestan: "shahrestan",
|
||||
bakhsh: "bakhsh",
|
||||
roosta: "roosta",
|
||||
tarikh_darkhast: "tarikh_darkhast",
|
||||
sazman: "sazman",
|
||||
masahat_zamin: "masahat_zamin",
|
||||
masahat_tarh: "masahat_tarh",
|
||||
gorooh_tarh: "gorooh_tarh",
|
||||
onvane_tarh: "onvane_tarh",
|
||||
address: "کرج - فلان جا - جنب پاساژ - نزدیک اونجا - اونور خیابون - زیر رو گذر - روی زیر گذر",
|
||||
file_mosavab: "file",
|
||||
polygon: [
|
||||
[51.515, -0.09],
|
||||
[51.52, -0.1],
|
||||
[51.52, -0.12],
|
||||
],
|
||||
};
|
||||
|
||||
const validationSchema = object({
|
||||
description: string().required("وارد کردن توضیحات الزامیست!"),
|
||||
});
|
||||
|
||||
const DetailDialog = ({ taskModal, setTaskModal, rowId, mutate }) => {
|
||||
const requestServer = useRequest({ auth: true });
|
||||
const defaultValues = {
|
||||
description: "",
|
||||
};
|
||||
const handleClose = () => {
|
||||
setTaskModal(false);
|
||||
};
|
||||
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { isSubmitting, errors, touchedFields },
|
||||
} = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" });
|
||||
|
||||
const onSubmit = async (data) => {
|
||||
const formData = new FormData();
|
||||
formData.append("description", data.description);
|
||||
requestServer(`api-for-send-to-harim/${rowId}`, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then(() => {
|
||||
handleClose();
|
||||
mutate();
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
return (
|
||||
<StyledForm onSubmit={handleSubmit(onSubmit)}>
|
||||
<Dialog open={taskModal} onClose={handleClose} maxWidth="lg" fullWidth>
|
||||
<DialogContent dividers>
|
||||
<ApplicantRequestDetail data={fakeData} />
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</StyledForm>
|
||||
);
|
||||
};
|
||||
export default DetailDialog;
|
||||
@@ -1,26 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { IconButton, Tooltip } from "@mui/material";
|
||||
import AssignmentIcon from "@mui/icons-material/Assignment";
|
||||
import DetailDialog from "./DetailDialog";
|
||||
import { useState } from "react";
|
||||
|
||||
const TaskDetail = ({ rowId, mutate }) => {
|
||||
const [taskModal, setTaskModal] = useState(false);
|
||||
|
||||
const openDetailDialog = () => {
|
||||
setTaskModal(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="جزئیات طرح متقاضی" arrow placement="right">
|
||||
<IconButton color="primary" onClick={openDetailDialog}>
|
||||
<AssignmentIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<DetailDialog taskModal={taskModal} setTaskModal={setTaskModal} rowId={rowId} mutate={mutate} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default TaskDetail;
|
||||
@@ -1,13 +0,0 @@
|
||||
import TaskDetail from "./TaskDetail";
|
||||
import { Box } from "@mui/material";
|
||||
import RoadSafetyForm from "./RoadSafetyForm";
|
||||
|
||||
const RowActions = ({ row, mutate }) => {
|
||||
return (
|
||||
<Box sx={{ display: "flex", gap: 1 }}>
|
||||
<TaskDetail mutate={mutate} rowId={row.getValue("id")} />
|
||||
<RoadSafetyForm mutate={mutate} rowId={row.getValue("id")} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
export default RowActions;
|
||||
@@ -1,145 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useMemo } from "react";
|
||||
import { Box } from "@mui/material";
|
||||
import DataTableWithAuth from "@/core/components/DataTableWithAuth";
|
||||
import RowActions from "./RowActions";
|
||||
|
||||
const TaskList = () => {
|
||||
const columns = useMemo(
|
||||
() => [
|
||||
{
|
||||
accessorKey: "id",
|
||||
header: "کد یکتا",
|
||||
id: "id",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "notEquals",
|
||||
},
|
||||
{
|
||||
accessorKey: "aplication_number",
|
||||
header: "شماره درخواست",
|
||||
id: "aplication_number",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "notEquals",
|
||||
},
|
||||
{
|
||||
accessorKey: "application_date",
|
||||
header: "تاریخ درخواست",
|
||||
id: "application_date",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "province",
|
||||
header: "استان",
|
||||
id: "province",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "township",
|
||||
header: "شهرستان",
|
||||
id: "township",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "city",
|
||||
header: "شهر",
|
||||
id: "city",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "county",
|
||||
header: "بخش",
|
||||
id: "county",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "village",
|
||||
header: "روستا",
|
||||
id: "village",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "land_area",
|
||||
header: "مساحت زمین",
|
||||
id: "land_area",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "design_area",
|
||||
header: "مساحت طرح",
|
||||
id: "design_area",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "organization",
|
||||
header: "سازمان",
|
||||
id: "organization",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "design_group",
|
||||
header: "گروه طرح",
|
||||
id: "design_group",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "design_title",
|
||||
header: "عنوان طرح",
|
||||
id: "design_title",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "state",
|
||||
header: "وضعیت درخواست",
|
||||
id: "state",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
],
|
||||
[]
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box sx={{ p: 1, border: 1, borderColor: "divider", borderRadius: 1 }}>
|
||||
<DataTableWithAuth
|
||||
table_title={"لیست استعلام ها"}
|
||||
need_filter={false}
|
||||
columns={columns}
|
||||
table_url={"/v3/api/fake-data"}
|
||||
page_name={"assistantZaminGov"}
|
||||
table_name={"assistantZaminGovList"}
|
||||
enableRowActions
|
||||
positionActionsColumn={"last"}
|
||||
RowActions={RowActions}
|
||||
/>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default TaskList;
|
||||
@@ -1,15 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import PageTitle from "@/core/components/PageTitle";
|
||||
import { Stack } from "@mui/material";
|
||||
import TaskList from "./TaskList";
|
||||
|
||||
const AssistantZaminGovComponent = () => {
|
||||
return (
|
||||
<Stack spacing={1}>
|
||||
<PageTitle title={"استعلام حرائم پنجره واحد"} />
|
||||
<TaskList />
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default AssistantZaminGovComponent;
|
||||
@@ -0,0 +1,243 @@
|
||||
import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency";
|
||||
import DataTableWithAuth from "@/core/components/DataTableWithAuth";
|
||||
import { GET_CITY_ADMIN_LIST } from "@/core/utils/routes";
|
||||
import useInquiryPrivacyState from "@/lib/hooks/useInquiryPrivacyState";
|
||||
import { Box, Stack } from "@mui/material";
|
||||
import moment from "jalali-moment";
|
||||
import { useMemo } from "react";
|
||||
import MapsHomeWorkIcon from "@mui/icons-material/MapsHomeWork";
|
||||
import SecurityIcon from "@mui/icons-material/Security";
|
||||
import ManageAccountsIcon from "@mui/icons-material/ManageAccounts";
|
||||
import PsychologyAltIcon from "@mui/icons-material/PsychologyAlt";
|
||||
import ReceiptLongIcon from "@mui/icons-material/ReceiptLong";
|
||||
import WindowIcon from "@mui/icons-material/Window";
|
||||
import DangerousIcon from "@mui/icons-material/Dangerous";
|
||||
import AutorenewIcon from "@mui/icons-material/Autorenew";
|
||||
import RowActions from "./RowActions";
|
||||
import ShowPrimaryArea from "./ShowPrimaryArea";
|
||||
|
||||
const CityAdminList = () => {
|
||||
const stateIcon = (state_id) => {
|
||||
if (state_id === 1) return <MapsHomeWorkIcon sx={{ color: "#A0B9C6" }} />;
|
||||
if (state_id === 2 || state_id === 5 || state_id === 13) return <SecurityIcon sx={{ color: "#995FA3" }} />;
|
||||
if (state_id === 3 || state_id === 6 || state_id === 14)
|
||||
return <ManageAccountsIcon sx={{ color: "#9A98B5" }} />;
|
||||
if (state_id === 4 || state_id === 7 || state_id === 15) return <PsychologyAltIcon sx={{ color: "#1B9AAA" }} />;
|
||||
if (state_id === 8) return <ReceiptLongIcon sx={{ color: "#9A98B5" }} />;
|
||||
if (state_id === 9 || state_id === 11) return <WindowIcon sx={{ color: "#DDDBCB" }} />;
|
||||
if (state_id === 10) return <DangerousIcon sx={{ color: "error.main" }} />;
|
||||
if (state_id === 12) return <AutorenewIcon sx={{ color: "#899878" }} />;
|
||||
};
|
||||
const columns = useMemo(() => {
|
||||
return [
|
||||
{
|
||||
accessorKey: "panjare_vahed_id",
|
||||
header: "کدرهگیری درخواست",
|
||||
id: "panjare_vahed_id",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.panjare_vahed_id}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "national_id",
|
||||
header: "کد ملی",
|
||||
id: "national_id",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.national_id}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "state_id",
|
||||
header: "وضعیت",
|
||||
id: "state_id",
|
||||
enableColumnFilter: true,
|
||||
datatype: "numeric",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
grow: false,
|
||||
size: 100,
|
||||
ColumnSelectComponent: (props) => {
|
||||
const { itemsList, loadingItemsList, errorItemsList } = useInquiryPrivacyState();
|
||||
|
||||
const getColumnSelectOptions = 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 (
|
||||
<CustomSelectByDependency
|
||||
{...props}
|
||||
value={loadingItemsList ? "loading" : props.filterParameters.value}
|
||||
columnSelectOption={getColumnSelectOptions}
|
||||
/>
|
||||
);
|
||||
},
|
||||
Cell: ({ row }) => (
|
||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||
{stateIcon(row.original.state_id)}
|
||||
<Box component="span" ml={1}>
|
||||
{row.original.state_name}
|
||||
</Box>
|
||||
</Box>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "plan_title",
|
||||
header: "عنوان طرح",
|
||||
id: "plan_title",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.plan_title}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "plan_group",
|
||||
header: "گروه طرح",
|
||||
id: "plan_group",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.plan_group}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "requested_organization",
|
||||
header: "دستگاه صادر کننده",
|
||||
id: "requested_organization",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.requested_organization}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "worksheet_id",
|
||||
header: "شناسه کاربرگ",
|
||||
id: "worksheet_id",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.worksheet_id}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "primary_area",
|
||||
header: "نمایش محدوده طرح",
|
||||
id: "primary_area",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) =>
|
||||
row.original.primary_area ? (
|
||||
<Stack alignItems={"center"} justifyContent={"center"}>
|
||||
<ShowPrimaryArea primaryArea={row.original.primary_area} />
|
||||
</Stack>
|
||||
) : (
|
||||
"-"
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "province_id",
|
||||
header: "استان",
|
||||
id: "province_id",
|
||||
enableColumnFilter: false,
|
||||
datatype: "numeric",
|
||||
sortDescFirst: false,
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.province_name}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "city_id",
|
||||
header: "شهر",
|
||||
id: "city_id",
|
||||
enableColumnFilter: false,
|
||||
datatype: "numeric",
|
||||
sortDescFirst: false,
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.city_name}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "isic",
|
||||
header: "کد آیسیک",
|
||||
id: "isic",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.isic}</>,
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => moment(row.request_date).locale("fa").format("YYYY/MM/DD"),
|
||||
header: "تاریخ درخواست",
|
||||
id: "request_date",
|
||||
enableColumnFilter: true,
|
||||
datatype: "date",
|
||||
filterMode: "between",
|
||||
grow: false,
|
||||
size: 100,
|
||||
},
|
||||
];
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box sx={{ p: 1, border: 1, borderColor: "divider", borderRadius: 1 }}>
|
||||
<DataTableWithAuth
|
||||
need_filter={true}
|
||||
columns={columns}
|
||||
table_url={GET_CITY_ADMIN_LIST}
|
||||
page_name={"cityAdmin"}
|
||||
table_name={"cityAdminList"}
|
||||
enableRowActions
|
||||
positionActionsColumn={"first"}
|
||||
RowActions={RowActions}
|
||||
/>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default CityAdminList;
|
||||
@@ -0,0 +1,149 @@
|
||||
import React, { useCallback, useEffect, useRef, useState } from "react";
|
||||
import L from "leaflet";
|
||||
import { FeatureGroup, useMap } from "react-leaflet";
|
||||
import "leaflet-draw";
|
||||
import { calculatePolygonMetrics } from "@/core/utils/geoCalculations";
|
||||
|
||||
const DrawPolygon = ({ control, controlDispach, drawBound, setDrawBound }) => {
|
||||
const map = useMap();
|
||||
const featureRef = useRef(null);
|
||||
const drawControlRef = useRef(null);
|
||||
|
||||
const [area, setArea] = useState(0);
|
||||
const [sideLengths, setSideLengths] = useState([]);
|
||||
|
||||
const calculatePolygonMetricsForLayer = useCallback(
|
||||
(layer) => {
|
||||
if (!layer) return;
|
||||
|
||||
const latlngs = layer.getLatLngs()[0];
|
||||
if (!latlngs || latlngs.length < 3) return;
|
||||
|
||||
const coordinates = latlngs.map((p) => [p.lat, p.lng]);
|
||||
|
||||
const metrics = calculatePolygonMetrics(coordinates, true);
|
||||
|
||||
setArea(metrics.area);
|
||||
setSideLengths(metrics.sides);
|
||||
|
||||
setDrawBound({
|
||||
layer,
|
||||
metrics,
|
||||
});
|
||||
},
|
||||
[setDrawBound]
|
||||
);
|
||||
|
||||
const safeFitBounds = (layer) => {
|
||||
if (!layer || !map) return;
|
||||
try {
|
||||
const latLngs = layer.getLatLngs();
|
||||
map.fitBounds(latLngs, {
|
||||
paddingTopLeft: [20, 35],
|
||||
paddingBottomRight: [20, 55],
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn("fitBounds failed:", e);
|
||||
}
|
||||
};
|
||||
|
||||
const bindEditEvent = useCallback(
|
||||
(layer) => {
|
||||
if (!layer) return;
|
||||
layer.on("edit", function (e) {
|
||||
const editedLayer = e.target;
|
||||
calculatePolygonMetricsForLayer(editedLayer);
|
||||
});
|
||||
},
|
||||
[calculatePolygonMetricsForLayer]
|
||||
);
|
||||
|
||||
const handlerCreatedBound = useCallback(
|
||||
(event) => {
|
||||
const { layer } = event;
|
||||
layer.editing.enable();
|
||||
featureRef.current.addLayer(layer);
|
||||
|
||||
calculatePolygonMetricsForLayer(layer);
|
||||
bindEditEvent(layer);
|
||||
|
||||
controlDispach({ type: "SET_STATUS", status: 2 });
|
||||
},
|
||||
[calculatePolygonMetricsForLayer, bindEditEvent, controlDispach]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
control.status === 1 &&
|
||||
drawControlRef.current &&
|
||||
drawControlRef.current._toolbars?.draw?._modes?.polygon?.handler
|
||||
) {
|
||||
drawControlRef.current._toolbars.draw._modes.polygon.handler.enable();
|
||||
}
|
||||
}, [control.status]);
|
||||
|
||||
useEffect(() => {
|
||||
if (control.status === 0 && featureRef.current) {
|
||||
featureRef.current.clearLayers();
|
||||
setArea(0);
|
||||
setSideLengths([]);
|
||||
setDrawBound(null);
|
||||
}
|
||||
}, [control.status, setDrawBound]);
|
||||
|
||||
useEffect(() => {
|
||||
if (control.status === 2 && drawBound && featureRef.current) {
|
||||
const { layer, metrics } = drawBound;
|
||||
featureRef.current.addLayer(layer);
|
||||
layer.editing.enable();
|
||||
safeFitBounds(layer);
|
||||
bindEditEvent(layer);
|
||||
|
||||
setArea(metrics?.area || 0);
|
||||
setSideLengths(metrics?.sides || []);
|
||||
}
|
||||
}, [control.status, drawBound, bindEditEvent]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!featureRef.current) return;
|
||||
|
||||
L.drawLocal.draw.handlers.polygon.tooltip.start = "برای شروع ترسیم محدوده، روی نقشه کلیک کنید";
|
||||
L.drawLocal.draw.handlers.polygon.tooltip.cont = "برای ادامه ترسیم، نقاط بعدی را کلیک کنید";
|
||||
L.drawLocal.draw.handlers.polygon.tooltip.end = "برای بستن محدوده، روی نقطهی شروع کلیک کنید";
|
||||
|
||||
const drawControl = new L.Control.Draw({
|
||||
draw: {
|
||||
polygon: {
|
||||
shapeOptions: {
|
||||
color: "red",
|
||||
weight: 3,
|
||||
clickable: true,
|
||||
},
|
||||
},
|
||||
polyline: false,
|
||||
rectangle: false,
|
||||
circle: false,
|
||||
marker: false,
|
||||
circlemarker: false,
|
||||
},
|
||||
edit: {
|
||||
featureGroup: featureRef.current,
|
||||
edit: true,
|
||||
remove: true,
|
||||
},
|
||||
});
|
||||
|
||||
drawControlRef.current = drawControl;
|
||||
map.addControl(drawControl);
|
||||
map.on(L.Draw.Event.CREATED, handlerCreatedBound);
|
||||
|
||||
return () => {
|
||||
map.off(L.Draw.Event.CREATED, handlerCreatedBound);
|
||||
map.removeControl(drawControl);
|
||||
};
|
||||
}, [map, handlerCreatedBound]);
|
||||
|
||||
return <FeatureGroup ref={featureRef} />;
|
||||
};
|
||||
|
||||
export default DrawPolygon;
|
||||
@@ -0,0 +1,121 @@
|
||||
import { Delete, Route } from "@mui/icons-material";
|
||||
import { Box, Button, Stack, Typography } from "@mui/material";
|
||||
import { useReducer } from "react";
|
||||
import DrawPolygon from "./DrawBound";
|
||||
|
||||
const statusType = [
|
||||
{
|
||||
id: 0,
|
||||
message: "برای آغاز ترسیم محدوده، کلیک کنید!",
|
||||
buttons: [
|
||||
{
|
||||
label: "شروع ترسیم محدوده",
|
||||
key: "start",
|
||||
color: "warning",
|
||||
icon: <Route />,
|
||||
onclick: (controlDispach) => {
|
||||
controlDispach({ type: "SET_STATUS", status: 1 });
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
message: "محدودهی موردنظر را با کلیک روی نقشه مشخص کنید. برای اتمام، روی نقطهی ابتدایی کلیک کنید!",
|
||||
buttons: [],
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
message: "برای اصلاح محدوده، گوشهها را بکشید. برای ترسیم دوباره، آن را حذف کنید",
|
||||
buttons: [
|
||||
{
|
||||
label: "حذف",
|
||||
key: "end",
|
||||
color: "error",
|
||||
icon: <Delete />,
|
||||
onclick: (controlDispach) => {
|
||||
controlDispach({ type: "SET_STATUS", status: 0 });
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const createInitialState = (drawBound) => {
|
||||
if (drawBound) {
|
||||
return { status: 2 };
|
||||
}
|
||||
return { status: 0 };
|
||||
};
|
||||
|
||||
const reducer = (state, action) => {
|
||||
switch (action.type) {
|
||||
case "SET_STATUS":
|
||||
return { ...state, status: action.status };
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const MapDrawPolygon = ({ drawBound, setDrawBound }) => {
|
||||
const [control, controlDispach] = useReducer(reducer, drawBound, createInitialState);
|
||||
|
||||
return (
|
||||
<>
|
||||
<DrawPolygon
|
||||
drawBound={drawBound}
|
||||
setDrawBound={setDrawBound}
|
||||
control={control}
|
||||
controlDispach={controlDispach}
|
||||
/>
|
||||
<Box
|
||||
direction={"row"}
|
||||
justifyContent={"center"}
|
||||
sx={{ display: "flex", position: "absolute", left: 0, top: 0, zIndex: 2000, width: "100%" }}
|
||||
>
|
||||
<Box
|
||||
sx={{
|
||||
background: (theme) => theme.palette.secondary.main,
|
||||
borderBottomLeftRadius: 8,
|
||||
borderBottomRightRadius: 8,
|
||||
py: 0.5,
|
||||
px: 2,
|
||||
}}
|
||||
>
|
||||
<Typography align="center" component={"div"} variant="caption" color={"#fff"}>
|
||||
{statusType.find((st) => st.id == control.status).message}
|
||||
</Typography>
|
||||
</Box>
|
||||
</Box>
|
||||
<Box
|
||||
sx={{
|
||||
position: "absolute",
|
||||
left: 0,
|
||||
bottom: 0,
|
||||
zIndex: 2000,
|
||||
width: "100%",
|
||||
py: 1,
|
||||
background: "linear-gradient(to top, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0))",
|
||||
}}
|
||||
>
|
||||
<Box direction={"row"} justifyContent={"center"} spacing={2} sx={{ display: "flex" }}>
|
||||
{statusType
|
||||
.find((st) => st.id == control.status)
|
||||
.buttons.map((button) => (
|
||||
<Button
|
||||
size="medium"
|
||||
key={button.key}
|
||||
variant="contained"
|
||||
onClick={() => button.onclick(controlDispach)}
|
||||
color={button.color}
|
||||
startIcon={button.icon}
|
||||
>
|
||||
{button.label}
|
||||
</Button>
|
||||
))}
|
||||
</Box>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default MapDrawPolygon;
|
||||
@@ -0,0 +1,156 @@
|
||||
import MapLayer from "@/core/components/MapLayer";
|
||||
import { CITY_ADMIN_FEEDBACK } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
import ForumIcon from "@mui/icons-material/Forum";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
IconButton,
|
||||
TextField,
|
||||
Tooltip,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { useMemo, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { object, string } from "yup";
|
||||
import ShowBound from "../../ShowPrimaryArea/ShowBound";
|
||||
import MapDrawPolygon from "./MapDrawPolygon";
|
||||
|
||||
const validationSchema = object({
|
||||
expert_description: string().required("توضیحات ناظر اجباری است!"),
|
||||
});
|
||||
|
||||
const FeedbackAction = ({ rowId, mutate, rowPrimaryArea }) => {
|
||||
const requestServer = useRequest({ notificationSuccess: true });
|
||||
const [openFeedbackDialog, setOpenFeedbackDialog] = useState(false);
|
||||
const [drawBound, setDrawBound] = useState(null);
|
||||
const bound = useMemo(() => {
|
||||
const latLngCoords = rowPrimaryArea.coordinates.map((coord) => [coord[1], coord[0]]);
|
||||
return rowPrimaryArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords);
|
||||
}, [rowPrimaryArea]);
|
||||
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { isSubmitting, errors },
|
||||
} = useForm({
|
||||
defaultValues: { expert_description: "", forbidden_area: "", forbidden_area_space: "" },
|
||||
resolver: yupResolver(validationSchema),
|
||||
mode: "all",
|
||||
});
|
||||
|
||||
const onSubmit = async (data) => {
|
||||
try {
|
||||
const payload = {
|
||||
expert_description: data.expert_description,
|
||||
};
|
||||
|
||||
if (drawBound && drawBound.metrics) {
|
||||
const { metrics } = drawBound;
|
||||
payload.forbidden_area = {
|
||||
type: "polygon",
|
||||
coordinates: metrics.coordinates,
|
||||
};
|
||||
payload.forbidden_area_space = metrics.area.toFixed(2);
|
||||
}
|
||||
await requestServer(`${CITY_ADMIN_FEEDBACK}/${rowId}`, "post", {
|
||||
data: payload,
|
||||
});
|
||||
|
||||
mutate();
|
||||
setOpenFeedbackDialog(false);
|
||||
} catch (error) {
|
||||
console.error("❌ Error submitting feedback:", error);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box>
|
||||
<Tooltip title="ارسال بازخورد">
|
||||
<IconButton color="success" onClick={() => setOpenFeedbackDialog(true)}>
|
||||
<ForumIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
open={openFeedbackDialog}
|
||||
onClose={() => setOpenFeedbackDialog(false)}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
transition: "all .3s",
|
||||
boxShadow:
|
||||
"rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
borderRadius: 2,
|
||||
},
|
||||
}}
|
||||
maxWidth="sm"
|
||||
fullWidth
|
||||
dir="rtl"
|
||||
>
|
||||
<DialogTitle sx={{ display: "flex", justifyContent: "space-between" }}>
|
||||
<Typography variant="body1" sx={{ fontWeight: "bold", fontSize: "large" }}>
|
||||
توضیحات ناظر
|
||||
</Typography>
|
||||
<IconButton onClick={() => setOpenFeedbackDialog(false)} size="small">
|
||||
<CloseIcon />
|
||||
</IconButton>
|
||||
</DialogTitle>
|
||||
<DialogContent sx={{ display: "flex", flexDirection: "column" }}>
|
||||
<Typography variant="h6">
|
||||
منطقه ممنوعه{" "}
|
||||
<Typography variant="caption" sx={{ color: "error.main" }}>
|
||||
(در صورت وجود انتخاب کنید)
|
||||
</Typography>
|
||||
</Typography>
|
||||
<Box sx={{ width: "100%", height: "400px", mb: 2 }}>
|
||||
<MapLayer style={{ borderRadius: "4px", border: "1px solid #eeeeee" }}>
|
||||
<ShowBound bound={bound} />
|
||||
<MapDrawPolygon drawBound={drawBound} setDrawBound={setDrawBound} />
|
||||
</MapLayer>
|
||||
</Box>
|
||||
<TextField
|
||||
{...register("expert_description")}
|
||||
multiline
|
||||
rows={3}
|
||||
label="توضیحات ناظر"
|
||||
placeholder="توضیحات ناظر"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
sx={{ mt: 1 }}
|
||||
InputLabelProps={{ shrink: true }}
|
||||
error={!!errors.expert_description}
|
||||
helperText={errors.expert_description?.message}
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button
|
||||
onClick={() => setOpenFeedbackDialog(false)}
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
disabled={isSubmitting}
|
||||
autoFocus
|
||||
>
|
||||
بستن
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleSubmit(onSubmit)}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
{isSubmitting ? "درحال ثبت تایید..." : "ثبت توضیحات"}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default FeedbackAction;
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Button, DialogActions, DialogContent } from "@mui/material";
|
||||
import TableContent from "./TableContent";
|
||||
const HistoryContent = ({ setOpenReferReasonDialog, rowId }) => {
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<TableContent rowId={rowId} />
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={() => setOpenReferReasonDialog(false)} variant="outlined" color="secondary" autoFocus>
|
||||
بستن
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default HistoryContent;
|
||||
@@ -0,0 +1,66 @@
|
||||
import {
|
||||
Box,
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableContainer,
|
||||
TableHead,
|
||||
TableRow,
|
||||
CircularProgress,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import "moment/locale/fa";
|
||||
import { useHistory } from "@/lib/hooks/useHistory";
|
||||
|
||||
const TableContent = ({ rowId }) => {
|
||||
const { historyData, loading, error } = useHistory(rowId);
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<Box display="flex" justifyContent="center" alignItems="center" height={200}>
|
||||
<CircularProgress />
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<Box display="flex" justifyContent="center" alignItems="center" height={200}>
|
||||
<Typography color="error">{error}</Typography>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
if (!historyData.length) {
|
||||
return (
|
||||
<Box display="flex" justifyContent="center" alignItems="center" height={200}>
|
||||
<Typography>اطلاعاتی وجود ندارد</Typography>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<TableContainer sx={{ maxHeight: 600 }}>
|
||||
<Table stickyHeader sx={{ minWidth: 800 }}>
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell>وضعیت</TableCell>
|
||||
<TableCell>توضیحات کارشناس</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{historyData.map((row) => (
|
||||
<TableRow key={row.id} sx={{ "&:last-child td, &:last-child th": { border: 0 } }}>
|
||||
<TableCell>{row.previous_state_name}</TableCell>
|
||||
<TableCell>{row.expert_description}</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</TableContainer>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default TableContent;
|
||||
@@ -0,0 +1,33 @@
|
||||
import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material";
|
||||
import { RestorePage } from "@mui/icons-material";
|
||||
import HistoryContent from "./HistoryContent";
|
||||
import { useState } from "react";
|
||||
|
||||
const History = ({ rowId }) => {
|
||||
const [openReferReasonDialog, setOpenReferReasonDialog] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="تاریخچه">
|
||||
<IconButton color="warning" onClick={() => setOpenReferReasonDialog(true)}>
|
||||
<RestorePage />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
fullWidth
|
||||
maxWidth={"md"}
|
||||
open={openReferReasonDialog}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<DialogTitle>تاریخچه</DialogTitle>
|
||||
<HistoryContent rowId={rowId} setOpenReferReasonDialog={setOpenReferReasonDialog} />
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default History;
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Box } from "@mui/material";
|
||||
import FeedbackAction from "./FeedbackAction";
|
||||
import History from "./History";
|
||||
|
||||
const RowActions = ({ row, mutate }) => {
|
||||
return (
|
||||
<Box sx={{ display: "flex", gap: 1, justifyContent: "Center" }}>
|
||||
{row.original.state_id === 1 ? (
|
||||
<FeedbackAction mutate={mutate} rowId={row.original.id} rowPrimaryArea={row.original.primary_area} />
|
||||
) : (
|
||||
"-"
|
||||
)}
|
||||
<History rowId={row.original.id} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
export default RowActions;
|
||||
@@ -0,0 +1,29 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { FeatureGroup, useMap } from "react-leaflet";
|
||||
|
||||
const ShowBound = ({ bound }) => {
|
||||
const map = useMap();
|
||||
const featureRef = useRef(null);
|
||||
|
||||
const safeFitBounds = (layer) => {
|
||||
if (!layer || !map) return;
|
||||
try {
|
||||
const latLngs = layer.getLatLngs();
|
||||
map.fitBounds(latLngs, {
|
||||
paddingTopLeft: [20, 20],
|
||||
paddingBottomRight: [20, 20],
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn("fitBounds failed:", e);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
bound?.editing?.disable();
|
||||
featureRef.current.addLayer(bound);
|
||||
safeFitBounds(bound);
|
||||
}, []);
|
||||
|
||||
return <FeatureGroup ref={featureRef} />;
|
||||
};
|
||||
export default ShowBound;
|
||||
@@ -0,0 +1,59 @@
|
||||
const { IconButton, Tooltip, Box, Dialog, DialogTitle, Typography, DialogContent } = require("@mui/material");
|
||||
import MapLayer from "@/core/components/MapLayer";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
import LayersIcon from "@mui/icons-material/Layers";
|
||||
import { useMemo, useState } from "react";
|
||||
import ShowBound from "./ShowBound";
|
||||
|
||||
const ShowPrimaryArea = ({ primaryArea }) => {
|
||||
const [openShowAreaDialog, setOpenShowAreaDialog] = useState(false);
|
||||
const bound = useMemo(() => {
|
||||
const latLngCoords = primaryArea.coordinates.map((coord) => [coord[1], coord[0]]);
|
||||
return primaryArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords);
|
||||
}, [primaryArea]);
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<Tooltip title="نمایش پلیگان" placement="right" arrow>
|
||||
<IconButton size="small" color="primary" onClick={() => setOpenShowAreaDialog(true)}>
|
||||
<LayersIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
open={openShowAreaDialog}
|
||||
onClose={() => setOpenShowAreaDialog(false)}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
transition: "all .3s",
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
borderRadius: 2,
|
||||
padding: 1,
|
||||
},
|
||||
}}
|
||||
maxWidth="sm"
|
||||
fullWidth
|
||||
dir="rtl"
|
||||
>
|
||||
<DialogTitle sx={{ display: "flex", justifyContent: "space-between", padding: "16px 24px" }}>
|
||||
<Typography variant="body1" sx={{ fontWeight: "bold", fontSize: "large" }}>
|
||||
محدوده طرح
|
||||
</Typography>
|
||||
<IconButton onClick={() => setOpenShowAreaDialog(false)} size="small">
|
||||
<CloseIcon />
|
||||
</IconButton>
|
||||
</DialogTitle>
|
||||
<DialogContent>
|
||||
<Box sx={{ flex: 1 }}>
|
||||
<Box sx={{ width: "100%", height: "400px" }}>
|
||||
<MapLayer style={{ borderRadius: "4px" }}>
|
||||
<ShowBound bound={bound} />
|
||||
</MapLayer>
|
||||
</Box>
|
||||
</Box>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default ShowPrimaryArea;
|
||||
14
src/components/dashboard/inquiryPrivacy/city-admin/index.jsx
Normal file
14
src/components/dashboard/inquiryPrivacy/city-admin/index.jsx
Normal file
@@ -0,0 +1,14 @@
|
||||
"use client";
|
||||
import PageTitle from "@/core/components/PageTitle";
|
||||
import { Stack } from "@mui/material";
|
||||
import CityAdminList from "./CityAdminList";
|
||||
|
||||
const CityAdminPage = () => {
|
||||
return (
|
||||
<Stack spacing={1}>
|
||||
<PageTitle title={"کارتابل شهرستان استعلام حریم"} />
|
||||
<CityAdminList />
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default CityAdminPage;
|
||||
@@ -1,138 +0,0 @@
|
||||
import {
|
||||
Autocomplete,
|
||||
Button,
|
||||
CircularProgress,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
FormControl,
|
||||
FormHelperText,
|
||||
InputLabel,
|
||||
OutlinedInput,
|
||||
Stack,
|
||||
TextField,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { object, string } from "yup";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import useCities from "@/lib/hooks/useCities";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { REFER_ADMIN_CITY } from "@/core/utils/routes";
|
||||
|
||||
const validationSchema = object({
|
||||
description: string().required("وارد کردن توضیحات الزامیست!"),
|
||||
city: string().required("وارد کردن شهرستان الزامیست!"),
|
||||
});
|
||||
|
||||
const ReferFormContext = ({ setOpenReferDialog, rowId, mutate }) => {
|
||||
const defaultValues = {
|
||||
description: "",
|
||||
city: "",
|
||||
};
|
||||
const { cities, loadingCities, errorCities } = useCities();
|
||||
const requestServer = useRequest({ notificationSuccess: true });
|
||||
const {
|
||||
control,
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { isSubmitting, errors, touchedFields },
|
||||
} = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" });
|
||||
|
||||
const onSubmit = async (data) => {
|
||||
const formData = new FormData();
|
||||
formData.append("description", data.description);
|
||||
formData.append("cityId", data.city);
|
||||
requestServer(`${REFER_ADMIN_CITY}/${rowId}`, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then(() => {
|
||||
setOpenReferDialog(false);
|
||||
mutate();
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
return (
|
||||
<StyledForm onSubmit={handleSubmit(onSubmit)}>
|
||||
<DialogContent>
|
||||
<Stack spacing={2}>
|
||||
<Stack>
|
||||
<FormControl error={!!errors.description} size="small" fullWidth variant="outlined">
|
||||
<InputLabel sx={{ pt: 1 }} htmlFor="description">
|
||||
توضیحات
|
||||
</InputLabel>
|
||||
<OutlinedInput
|
||||
id="description"
|
||||
label={"توضیحات"}
|
||||
multiline
|
||||
rows={8}
|
||||
autoComplete="off"
|
||||
{...register("description")}
|
||||
size="small"
|
||||
fullWidth
|
||||
sx={{ mt: 1 }}
|
||||
type="text"
|
||||
/>
|
||||
<FormHelperText id="description">
|
||||
{errors.description ? errors.description.message : null}
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</Stack>
|
||||
<Stack>
|
||||
<Controller
|
||||
name="city"
|
||||
control={control}
|
||||
render={({ field: { onChange, value }, fieldState: { error } }) => (
|
||||
<FormControl error={!!error} size="small" fullWidth variant="outlined">
|
||||
<InputLabel htmlFor="city" />
|
||||
{errorCities ? (
|
||||
<Typography color={"red"}>خطایی در دریافت شهرستان ها رخ داده است!</Typography>
|
||||
) : loadingCities ? (
|
||||
<Typography sx={{ display: "flex", alignItems: "center", gap: 2 }}>
|
||||
<CircularProgress size={20} />
|
||||
درحال دریافت لیست شهرستان ها
|
||||
</Typography>
|
||||
) : (
|
||||
<Autocomplete
|
||||
id="city"
|
||||
size="small"
|
||||
value={cities.find((city) => city.id === value) || null}
|
||||
disablePortal
|
||||
options={cities}
|
||||
getOptionLabel={(city) => city.name}
|
||||
isOptionEqualToValue={(option, value) => option.id === value.id}
|
||||
onChange={(event, newValue) => {
|
||||
onChange(newValue ? newValue.id : "");
|
||||
}}
|
||||
renderInput={(params) => (
|
||||
<TextField
|
||||
{...params}
|
||||
autoComplete="off"
|
||||
error={!!errors.city}
|
||||
fullWidth
|
||||
label="شهرستان"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
<FormHelperText id="city">
|
||||
{errors.city ? errors.city.message : null}
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
)}
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={() => setOpenReferDialog(false)} variant="outlined" color="secondary" autoFocus>
|
||||
{"انصراف"}
|
||||
</Button>
|
||||
<Button variant="contained" color="primary" type={"submit"} disabled={isSubmitting}>
|
||||
{isSubmitting ? "در حال اسال" : "ارجاع"}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</StyledForm>
|
||||
);
|
||||
};
|
||||
export default ReferFormContext;
|
||||
@@ -1,41 +0,0 @@
|
||||
import { Dialog, DialogTitle, IconButton, Stack, Tooltip } from "@mui/material";
|
||||
import ReplyIcon from "@mui/icons-material/Reply";
|
||||
import DialogTransition from "@/core/components/DialogTransition";
|
||||
import ReferFormContext from "./ReferFormContext";
|
||||
import { useState } from "react";
|
||||
|
||||
const ReferForm = ({ rowId, mutate }) => {
|
||||
const [openReferDialog, setOpenReferDialog] = useState(false);
|
||||
return (
|
||||
<Stack>
|
||||
<Tooltip title="ارجاع به شهرستان دیگر" arrow placement="right">
|
||||
<IconButton
|
||||
color="primary"
|
||||
sx={{ textTransform: "unset", alignSelf: "center" }}
|
||||
onClick={() => {
|
||||
setOpenReferDialog(true);
|
||||
}}
|
||||
>
|
||||
<ReplyIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
PaperProps={{
|
||||
sx: {
|
||||
transition: "all .3s",
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
},
|
||||
}}
|
||||
open={openReferDialog}
|
||||
fullWidth
|
||||
TransitionComponent={DialogTransition}
|
||||
>
|
||||
<DialogTitle sx={{ m: 0, p: 2, borderBottom: 1, borderColor: "divider" }} id="create-dialog">
|
||||
ارجاع به شهرستان دیگر
|
||||
</DialogTitle>
|
||||
<ReferFormContext rowId={rowId} mutate={mutate} setOpenReferDialog={setOpenReferDialog} />
|
||||
</Dialog>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default ReferForm;
|
||||
@@ -1,109 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
FormControl,
|
||||
FormHelperText,
|
||||
InputLabel,
|
||||
OutlinedInput,
|
||||
} from "@mui/material";
|
||||
import { object, string } from "yup";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import ApplicantRequestDetail from "@/core/components/ApplicantRequestDetail";
|
||||
|
||||
const fakeData = {
|
||||
id: 1,
|
||||
shomareh_darkhast: "2124",
|
||||
ostan: "ostan",
|
||||
shahr: "shahr",
|
||||
shahrestan: "shahrestan",
|
||||
bakhsh: "bakhsh",
|
||||
roosta: "roosta",
|
||||
tarikh_darkhast: "tarikh_darkhast",
|
||||
sazman: "sazman",
|
||||
masahat_zamin: "masahat_zamin",
|
||||
masahat_tarh: "masahat_tarh",
|
||||
gorooh_tarh: "gorooh_tarh",
|
||||
onvane_tarh: "onvane_tarh",
|
||||
address: "کرج - فلان جا - جنب پاساژ - نزدیک اونجا - اونور خیابون - زیر رو گذر - روی زیر گذر",
|
||||
file_mosavab: "file",
|
||||
polygon: [
|
||||
[51.515, -0.09],
|
||||
[51.52, -0.1],
|
||||
[51.52, -0.12],
|
||||
],
|
||||
};
|
||||
|
||||
const validationSchema = object({
|
||||
description: string().required("وارد کردن توضیحات الزامیست!"),
|
||||
});
|
||||
|
||||
const DetailDialog = ({ taskModal, setTaskModal, rowId, mutate }) => {
|
||||
const requestServer = useRequest({ auth: true });
|
||||
const defaultValues = {
|
||||
description: "",
|
||||
};
|
||||
const handleClose = () => {
|
||||
setTaskModal(false);
|
||||
};
|
||||
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { isSubmitting, errors, touchedFields },
|
||||
} = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" });
|
||||
|
||||
const onSubmit = async (data) => {
|
||||
const formData = new FormData();
|
||||
formData.append("description", data.description);
|
||||
requestServer(`api-for-send-to-harim/${rowId}`, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then(() => {
|
||||
handleClose();
|
||||
mutate();
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
return (
|
||||
<StyledForm onSubmit={handleSubmit(onSubmit)}>
|
||||
<Dialog open={taskModal} onClose={handleClose} maxWidth="lg" fullWidth>
|
||||
<DialogContent dividers>
|
||||
<ApplicantRequestDetail data={fakeData} />
|
||||
<FormControl error={!!errors.description} size="small" fullWidth variant="outlined">
|
||||
<InputLabel sx={{ pt: 1 }} htmlFor="description">
|
||||
توضیحات
|
||||
</InputLabel>
|
||||
<OutlinedInput
|
||||
id="description"
|
||||
label={"توضیحات"}
|
||||
multiline
|
||||
rows={8}
|
||||
autoComplete="off"
|
||||
{...register("description")}
|
||||
size="small"
|
||||
fullWidth
|
||||
sx={{ mt: 1 }}
|
||||
type="text"
|
||||
/>
|
||||
<FormHelperText id="description">
|
||||
{errors.description ? errors.description.message : null}
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</DialogContent>
|
||||
<DialogActions sx={{ justifyContent: "center", py: 2 }}>
|
||||
<Button size="large" variant="contained">
|
||||
ارسال به دفتر حریم
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</StyledForm>
|
||||
);
|
||||
};
|
||||
export default DetailDialog;
|
||||
@@ -1,26 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { IconButton, Tooltip } from "@mui/material";
|
||||
import AssignmentIcon from "@mui/icons-material/Assignment";
|
||||
import DetailDialog from "./DetailDialog";
|
||||
import { useState } from "react";
|
||||
|
||||
const TaskDetail = ({ rowId, mutate }) => {
|
||||
const [taskModal, setTaskModal] = useState(false);
|
||||
|
||||
const openDetailDialog = () => {
|
||||
setTaskModal(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="جزئیات طرح متقاضی" arrow placement="right">
|
||||
<IconButton color="primary" onClick={openDetailDialog}>
|
||||
<AssignmentIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<DetailDialog taskModal={taskModal} setTaskModal={setTaskModal} rowId={rowId} mutate={mutate} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default TaskDetail;
|
||||
@@ -1,15 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import ReferForm from "./Refer";
|
||||
import TaskDetail from "./TaskDetail";
|
||||
import { Box } from "@mui/material";
|
||||
|
||||
const RowActions = ({ row, mutate }) => {
|
||||
return (
|
||||
<Box sx={{ display: "flex", gap: 1 }}>
|
||||
<ReferForm mutate={mutate} rowId={row.getValue("id")} />
|
||||
<TaskDetail mutate={mutate} rowId={row.getValue("id")} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
export default RowActions;
|
||||
@@ -1,145 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useMemo } from "react";
|
||||
import { Box } from "@mui/material";
|
||||
import DataTableWithAuth from "@/core/components/DataTableWithAuth";
|
||||
import RowActions from "./RowActions";
|
||||
|
||||
const TaskList = () => {
|
||||
const columns = useMemo(
|
||||
() => [
|
||||
{
|
||||
accessorKey: "id",
|
||||
header: "کد یکتا",
|
||||
id: "id",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "notEquals",
|
||||
},
|
||||
{
|
||||
accessorKey: "aplication_number",
|
||||
header: "شماره درخواست",
|
||||
id: "aplication_number",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "notEquals",
|
||||
},
|
||||
{
|
||||
accessorKey: "application_date",
|
||||
header: "تاریخ درخواست",
|
||||
id: "application_date",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "province",
|
||||
header: "استان",
|
||||
id: "province",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "township",
|
||||
header: "شهرستان",
|
||||
id: "township",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "city",
|
||||
header: "شهر",
|
||||
id: "city",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "county",
|
||||
header: "بخش",
|
||||
id: "county",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "village",
|
||||
header: "روستا",
|
||||
id: "village",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "land_area",
|
||||
header: "مساحت زمین",
|
||||
id: "land_area",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "design_area",
|
||||
header: "مساحت طرح",
|
||||
id: "design_area",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "organization",
|
||||
header: "سازمان",
|
||||
id: "organization",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "design_group",
|
||||
header: "گروه طرح",
|
||||
id: "design_group",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "design_title",
|
||||
header: "عنوان طرح",
|
||||
id: "design_title",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "state",
|
||||
header: "وضعیت درخواست",
|
||||
id: "state",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
],
|
||||
[]
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box sx={{ p: 1, border: 1, borderColor: "divider", borderRadius: 1 }}>
|
||||
<DataTableWithAuth
|
||||
table_title={"لیست استعلام ها"}
|
||||
need_filter={false}
|
||||
columns={columns}
|
||||
table_url={"/v3/api/fake-data"}
|
||||
page_name={"cityAdminZaminGov"}
|
||||
table_name={"cityAdminZaminGovList"}
|
||||
enableRowActions
|
||||
positionActionsColumn={"last"}
|
||||
RowActions={RowActions}
|
||||
/>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default TaskList;
|
||||
@@ -1,14 +0,0 @@
|
||||
"use client";
|
||||
import PageTitle from "@/core/components/PageTitle";
|
||||
import { Stack } from "@mui/material";
|
||||
import TaskList from "./TaskList";
|
||||
|
||||
const CityAdminZaminGovComponent = () => {
|
||||
return (
|
||||
<Stack spacing={1}>
|
||||
<PageTitle title={"استعلام حرائم پنجره واحد"} />
|
||||
<TaskList />
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default CityAdminZaminGovComponent;
|
||||
@@ -0,0 +1,243 @@
|
||||
import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency";
|
||||
import DataTableWithAuth from "@/core/components/DataTableWithAuth";
|
||||
import useInquiryPrivacyState from "@/lib/hooks/useInquiryPrivacyState";
|
||||
import AutorenewIcon from "@mui/icons-material/Autorenew";
|
||||
import DangerousIcon from "@mui/icons-material/Dangerous";
|
||||
import ManageAccountsIcon from "@mui/icons-material/ManageAccounts";
|
||||
import MapsHomeWorkIcon from "@mui/icons-material/MapsHomeWork";
|
||||
import PsychologyAltIcon from "@mui/icons-material/PsychologyAlt";
|
||||
import ReceiptLongIcon from "@mui/icons-material/ReceiptLong";
|
||||
import SecurityIcon from "@mui/icons-material/Security";
|
||||
import WindowIcon from "@mui/icons-material/Window";
|
||||
import { Box, Stack } from "@mui/material";
|
||||
import moment from "jalali-moment";
|
||||
import { useMemo } from "react";
|
||||
import RowActions from "./RowActions";
|
||||
import { GET_GENERAL_MANAGER_LIST } from "@/core/utils/routes";
|
||||
import ShowPrimaryArea from "./ShowPrimaryArea";
|
||||
|
||||
const GeneralManagerList = () => {
|
||||
const stateIcon = (state_id) => {
|
||||
if (state_id === 1) return <MapsHomeWorkIcon sx={{ color: "#A0B9C6" }} />;
|
||||
if (state_id === 2 || state_id === 5 || state_id === 13) return <SecurityIcon sx={{ color: "#995FA3" }} />;
|
||||
if (state_id === 3 || state_id === 6 || state_id === 14)
|
||||
return <ManageAccountsIcon sx={{ color: "#9A98B5" }} />;
|
||||
if (state_id === 4 || state_id === 7 || state_id === 15) return <PsychologyAltIcon sx={{ color: "#1B9AAA" }} />;
|
||||
if (state_id === 8) return <ReceiptLongIcon sx={{ color: "#9A98B5" }} />;
|
||||
if (state_id === 9 || state_id === 11) return <WindowIcon sx={{ color: "#DDDBCB" }} />;
|
||||
if (state_id === 10) return <DangerousIcon sx={{ color: "error.main" }} />;
|
||||
if (state_id === 12) return <AutorenewIcon sx={{ color: "#899878" }} />;
|
||||
};
|
||||
const columns = useMemo(() => {
|
||||
return [
|
||||
{
|
||||
accessorKey: "panjare_vahed_id",
|
||||
header: "کدرهگیری درخواست",
|
||||
id: "panjare_vahed_id",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.panjare_vahed_id}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "national_id",
|
||||
header: "کد ملی",
|
||||
id: "national_id",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.national_id}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "state_id",
|
||||
header: "وضعیت",
|
||||
id: "state_id",
|
||||
enableColumnFilter: true,
|
||||
datatype: "numeric",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
grow: false,
|
||||
size: 100,
|
||||
ColumnSelectComponent: (props) => {
|
||||
const { itemsList, loadingItemsList, errorItemsList } = useInquiryPrivacyState();
|
||||
|
||||
const getColumnSelectOptions = 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 (
|
||||
<CustomSelectByDependency
|
||||
{...props}
|
||||
value={loadingItemsList ? "loading" : props.filterParameters.value}
|
||||
columnSelectOption={getColumnSelectOptions}
|
||||
/>
|
||||
);
|
||||
},
|
||||
Cell: ({ row }) => (
|
||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||
{stateIcon(row.original.state_id)}
|
||||
<Box component="span" ml={1}>
|
||||
{row.original.state_name}
|
||||
</Box>
|
||||
</Box>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "plan_title",
|
||||
header: "عنوان طرح",
|
||||
id: "plan_title",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.plan_title}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "plan_group",
|
||||
header: "گروه طرح",
|
||||
id: "plan_group",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.plan_group}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "requested_organization",
|
||||
header: "دستگاه صادر کننده",
|
||||
id: "requested_organization",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.requested_organization}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "worksheet_id",
|
||||
header: "شناسه کاربرگ",
|
||||
id: "worksheet_id",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.worksheet_id}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "primary_area",
|
||||
header: "نمایش محدوده طرح",
|
||||
id: "primary_area",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) =>
|
||||
row.original.primary_area ? (
|
||||
<Stack alignItems={"center"} justifyContent={"center"}>
|
||||
<ShowPrimaryArea primaryArea={row.original.primary_area} />
|
||||
</Stack>
|
||||
) : (
|
||||
"-"
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "province_id",
|
||||
header: "استان",
|
||||
id: "province_id",
|
||||
enableColumnFilter: false,
|
||||
datatype: "numeric",
|
||||
sortDescFirst: false,
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.province_name}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "city_id",
|
||||
header: "شهر",
|
||||
id: "city_id",
|
||||
enableColumnFilter: false,
|
||||
datatype: "numeric",
|
||||
sortDescFirst: false,
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.city_name}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "isic",
|
||||
header: "کد آیسیک",
|
||||
id: "isic",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.isic}</>,
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => moment(row.request_date).locale("fa").format("YYYY/MM/DD"),
|
||||
header: "تاریخ درخواست",
|
||||
id: "request_date",
|
||||
enableColumnFilter: true,
|
||||
datatype: "date",
|
||||
filterMode: "between",
|
||||
grow: false,
|
||||
size: 100,
|
||||
},
|
||||
];
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box sx={{ p: 1, border: 1, borderColor: "divider", borderRadius: 1 }}>
|
||||
<DataTableWithAuth
|
||||
need_filter={true}
|
||||
columns={columns}
|
||||
table_url={GET_GENERAL_MANAGER_LIST}
|
||||
page_name={"PrivacyOffice"}
|
||||
table_name={"GeneralManagerList"}
|
||||
enableRowActions
|
||||
positionActionsColumn={"first"}
|
||||
RowActions={RowActions}
|
||||
/>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default GeneralManagerList;
|
||||
@@ -0,0 +1,17 @@
|
||||
import ThumbUpIcon from "@mui/icons-material/ThumbUp";
|
||||
import { IconButton, Tooltip } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
|
||||
const ConfirmAction = ({ rowId, mutate }) => {
|
||||
const [openConfirmDialog, setOpenConfirmDialog] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="تایید اقدام">
|
||||
<IconButton color="success" onClick={() => setOpenConfirmDialog(true)}>
|
||||
<ThumbUpIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default ConfirmAction;
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Button, DialogActions, DialogContent } from "@mui/material";
|
||||
import TableContent from "./TableContent";
|
||||
const HistoryContent = ({ setOpenReferReasonDialog, rowId }) => {
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<TableContent rowId={rowId} />
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={() => setOpenReferReasonDialog(false)} variant="outlined" color="secondary" autoFocus>
|
||||
بستن
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default HistoryContent;
|
||||
@@ -0,0 +1,66 @@
|
||||
import {
|
||||
Box,
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableContainer,
|
||||
TableHead,
|
||||
TableRow,
|
||||
CircularProgress,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import "moment/locale/fa";
|
||||
import { useHistory } from "@/lib/hooks/useHistory";
|
||||
|
||||
const TableContent = ({ rowId }) => {
|
||||
const { historyData, loading, error } = useHistory(rowId);
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<Box display="flex" justifyContent="center" alignItems="center" height={200}>
|
||||
<CircularProgress />
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<Box display="flex" justifyContent="center" alignItems="center" height={200}>
|
||||
<Typography color="error">{error}</Typography>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
if (!historyData.length) {
|
||||
return (
|
||||
<Box display="flex" justifyContent="center" alignItems="center" height={200}>
|
||||
<Typography>اطلاعاتی وجود ندارد</Typography>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<TableContainer sx={{ maxHeight: 600 }}>
|
||||
<Table stickyHeader sx={{ minWidth: 800 }}>
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell>وضعیت</TableCell>
|
||||
<TableCell>توضیحات کارشناس</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{historyData.map((row) => (
|
||||
<TableRow key={row.id} sx={{ "&:last-child td, &:last-child th": { border: 0 } }}>
|
||||
<TableCell>{row.previous_state_name}</TableCell>
|
||||
<TableCell>{row.expert_description}</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</TableContainer>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default TableContent;
|
||||
@@ -0,0 +1,33 @@
|
||||
import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material";
|
||||
import { RestorePage } from "@mui/icons-material";
|
||||
import HistoryContent from "./HistoryContent";
|
||||
import { useState } from "react";
|
||||
|
||||
const History = ({ rowId }) => {
|
||||
const [openReferReasonDialog, setOpenReferReasonDialog] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="تاریخچه">
|
||||
<IconButton color="warning" onClick={() => setOpenReferReasonDialog(true)}>
|
||||
<RestorePage />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
fullWidth
|
||||
maxWidth={"md"}
|
||||
open={openReferReasonDialog}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<DialogTitle>تاریخچه</DialogTitle>
|
||||
<HistoryContent rowId={rowId} setOpenReferReasonDialog={setOpenReferReasonDialog} />
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default History;
|
||||
@@ -0,0 +1,17 @@
|
||||
import ThumbDownIcon from "@mui/icons-material/ThumbDown";
|
||||
import { IconButton, Tooltip } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
|
||||
const RejectAction = ({ rowId, mutate }) => {
|
||||
const [openRejectDialog, setOpenRejectDialog] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="عدم تایید اقدام">
|
||||
<IconButton color="error" onClick={() => setOpenRejectDialog(true)}>
|
||||
<ThumbDownIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default RejectAction;
|
||||
@@ -0,0 +1,22 @@
|
||||
import { Box } from "@mui/material";
|
||||
import ConfirmAction from "./ConfirmAction";
|
||||
import RejectAction from "./RejectAction";
|
||||
import History from "./History";
|
||||
|
||||
const RowActions = ({ row, mutate }) => {
|
||||
// const stateId = row.original.state_id;
|
||||
//
|
||||
// const disabled = {
|
||||
// referral: stateId !== 2,
|
||||
// reject: stateId !== 2 && stateId !== 5,
|
||||
// confirm: stateId !== 2 && stateId !== 5 && stateId !== 13,
|
||||
// };
|
||||
return (
|
||||
<Box sx={{ display: "flex", gap: 1, justifyContent: "Center" }}>
|
||||
<RejectAction />
|
||||
<ConfirmAction />
|
||||
<History rowId={row.original.id} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
export default RowActions;
|
||||
@@ -0,0 +1,29 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { FeatureGroup, useMap } from "react-leaflet";
|
||||
|
||||
const ShowBound = ({ bound }) => {
|
||||
const map = useMap();
|
||||
const featureRef = useRef(null);
|
||||
|
||||
const safeFitBounds = (layer) => {
|
||||
if (!layer || !map) return;
|
||||
try {
|
||||
const latLngs = layer.getLatLngs();
|
||||
map.fitBounds(latLngs, {
|
||||
paddingTopLeft: [20, 20],
|
||||
paddingBottomRight: [20, 20],
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn("fitBounds failed:", e);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
bound?.editing?.disable();
|
||||
featureRef.current.addLayer(bound);
|
||||
safeFitBounds(bound);
|
||||
}, []);
|
||||
|
||||
return <FeatureGroup ref={featureRef} />;
|
||||
};
|
||||
export default ShowBound;
|
||||
@@ -0,0 +1,69 @@
|
||||
const {
|
||||
Button,
|
||||
IconButton,
|
||||
Tooltip,
|
||||
Box,
|
||||
Dialog,
|
||||
DialogTitle,
|
||||
Typography,
|
||||
DialogContent,
|
||||
DialogActions,
|
||||
} = require("@mui/material");
|
||||
import LayersIcon from "@mui/icons-material/Layers";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
import { useMemo, useState } from "react";
|
||||
import MapLayer from "@/core/components/MapLayer";
|
||||
import ShowBound from "./ShowBound";
|
||||
|
||||
const ShowPrimaryArea = ({ primaryArea }) => {
|
||||
const [openShowAreaDialog, setOpenShowAreaDialog] = useState(false);
|
||||
const bound = useMemo(() => {
|
||||
const latLngCoords = primaryArea.coordinates.map((coord) => [coord[1], coord[0]]);
|
||||
return primaryArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords);
|
||||
}, [primaryArea]);
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<Tooltip title="نمایش پلیگان" placement="right" arrow>
|
||||
<IconButton size="small" color="primary" onClick={() => setOpenShowAreaDialog(true)}>
|
||||
<LayersIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
open={openShowAreaDialog}
|
||||
onClose={() => setOpenShowAreaDialog(false)}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
transition: "all .3s",
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
borderRadius: 2,
|
||||
padding: 1,
|
||||
},
|
||||
}}
|
||||
maxWidth="sm"
|
||||
fullWidth
|
||||
dir="rtl"
|
||||
>
|
||||
<DialogTitle sx={{ display: "flex", justifyContent: "space-between", padding: "16px 24px" }}>
|
||||
<Typography variant="body1" sx={{ fontWeight: "bold", fontSize: "large" }}>
|
||||
محدوده طرح
|
||||
</Typography>
|
||||
<IconButton onClick={() => setOpenShowAreaDialog(false)} size="small">
|
||||
<CloseIcon />
|
||||
</IconButton>
|
||||
</DialogTitle>
|
||||
<DialogContent>
|
||||
<Box sx={{ flex: 1 }}>
|
||||
<Box sx={{ width: "100%", height: "400px" }}>
|
||||
<MapLayer style={{ borderRadius: "4px" }}>
|
||||
<ShowBound bound={bound} />
|
||||
</MapLayer>
|
||||
</Box>
|
||||
</Box>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default ShowPrimaryArea;
|
||||
@@ -0,0 +1,14 @@
|
||||
"use client";
|
||||
import PageTitle from "@/core/components/PageTitle";
|
||||
import { Stack } from "@mui/material";
|
||||
import GeneralManagerList from "./GeneralManagerList";
|
||||
|
||||
const GeneralManagerPage = () => {
|
||||
return (
|
||||
<Stack spacing={1}>
|
||||
<PageTitle title={"کارتابل اداره حریم استعلام حریم"} />
|
||||
<GeneralManagerList />
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default GeneralManagerPage;
|
||||
@@ -1,29 +0,0 @@
|
||||
import { FormControl, FormHelperText, InputLabel, OutlinedInput, Stack } from "@mui/material";
|
||||
|
||||
const DescriptionForm = ({ errors, register }) => {
|
||||
return (
|
||||
<Stack>
|
||||
<FormControl error={!!errors.description} size="small" fullWidth variant="outlined">
|
||||
<InputLabel sx={{ pt: 1 }} htmlFor="description">
|
||||
توضیحات
|
||||
</InputLabel>
|
||||
<OutlinedInput
|
||||
id="description"
|
||||
label={"توضیحات"}
|
||||
multiline
|
||||
rows={6}
|
||||
{...register("description")}
|
||||
autoComplete="off"
|
||||
size="small"
|
||||
fullWidth
|
||||
sx={{ mt: 1 }}
|
||||
type="text"
|
||||
/>
|
||||
<FormHelperText id="description">
|
||||
{errors.description ? errors.description.message : null}
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default DescriptionForm;
|
||||
@@ -1,15 +0,0 @@
|
||||
import { Button } from "@mui/material";
|
||||
|
||||
const ManagerOrAssistantSubmit = ({ isSubmitting }) => {
|
||||
return (
|
||||
<>
|
||||
<Button fullWidth variant="outlined" color="secondary" disabled={isSubmitting} type={"submit"}>
|
||||
{isSubmitting ? "در حال ارسال..." : "مخالفت"}
|
||||
</Button>
|
||||
<Button fullWidth variant="contained" color="primary" type={"submit"} disabled={isSubmitting}>
|
||||
{isSubmitting ? "در حال ارسال..." : "موافقت"}
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default ManagerOrAssistantSubmit;
|
||||
@@ -1,26 +0,0 @@
|
||||
import { Card, CardContent, CardHeader, CircularProgress, Divider, Stack, Typography } from "@mui/material";
|
||||
import usePrevStateOpinion from "@/lib/hooks/usePrevStateopinion";
|
||||
|
||||
const PrevCartableOpinion = ({ message, loadingMessage, errorMessage }) => {
|
||||
return (
|
||||
<Stack>
|
||||
<Card variant="outlined">
|
||||
<CardHeader sx={{ pb: 0 }} title="نظر معاون راهداری استان :" />
|
||||
<CardContent>
|
||||
{errorMessage ? (
|
||||
<Typography color={"red"}>خطا در دریافت اطلاعات !!!</Typography>
|
||||
) : loadingMessage ? (
|
||||
<Typography sx={{ display: "flex", alignItems: "center", gap: 2 }}>
|
||||
<CircularProgress size={20} />
|
||||
درحال دریافت اطلاعات
|
||||
</Typography>
|
||||
) : (
|
||||
<Typography>{message}</Typography>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Divider sx={{ mt: 2 }} />
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default PrevCartableOpinion;
|
||||
@@ -1,33 +0,0 @@
|
||||
import { Card, CardContent, FormControl, FormLabel, Stack, Typography } from "@mui/material";
|
||||
|
||||
const QuestionSafetyForm = () => {
|
||||
return (
|
||||
<Stack sx={{ py: 2 }}>
|
||||
<Card
|
||||
sx={{ display: "flex", justifyContent: "center", alignItems: "center", borderColor: "primary.main" }}
|
||||
variant="outlined"
|
||||
>
|
||||
<CardContent>
|
||||
<FormControl>
|
||||
<FormLabel>
|
||||
<Typography color={"primary"} variant={"h5"} fontWeight={"bolder"}>
|
||||
آیا ایمنی راه این طرح مورد تایید است ؟
|
||||
</Typography>
|
||||
</FormLabel>
|
||||
<Stack
|
||||
sx={{ pt: 2, display: "flex", justifyContent: "center", alignItems: "center" }}
|
||||
spacing={1}
|
||||
direction={"row"}
|
||||
>
|
||||
<Typography variant={"subtitle1"}>دفتر حریم راه : </Typography>
|
||||
<Typography variant={"h5"} fontWeight={"bolder"}>
|
||||
بله
|
||||
</Typography>
|
||||
</Stack>
|
||||
</FormControl>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default QuestionSafetyForm;
|
||||
@@ -1,82 +0,0 @@
|
||||
import { DialogActions, DialogContent, Stack } from "@mui/material";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { object, string } from "yup";
|
||||
import { SUBMIT_ROAD_SAFETY_FORM } from "@/core/utils/routes";
|
||||
import QuestionSafetyForm from "./QuestionSafetyForm";
|
||||
import PrevCartableOpinion from "./PrevCartableOpinion";
|
||||
import DescriptionForm from "./DescriptionForm";
|
||||
import ManagerOrAssistantSubmit from "./ManagerOrAssistantSubmit";
|
||||
import usePrevStateOpinion from "@/lib/hooks/usePrevStateopinion";
|
||||
import ApplicantRequestDetail from "@/core/components/ApplicantRequestDetail";
|
||||
const fakeData = {
|
||||
id: 1,
|
||||
shomareh_darkhast: "2124",
|
||||
ostan: "ostan",
|
||||
shahr: "shahr",
|
||||
shahrestan: "shahrestan",
|
||||
bakhsh: "bakhsh",
|
||||
roosta: "roosta",
|
||||
tarikh_darkhast: "tarikh_darkhast",
|
||||
sazman: "sazman",
|
||||
masahat_zamin: "masahat_zamin",
|
||||
masahat_tarh: "masahat_tarh",
|
||||
gorooh_tarh: "gorooh_tarh",
|
||||
onvane_tarh: "onvane_tarh",
|
||||
address: "کرج - فلان جا - جنب پاساژ - نزدیک اونجا - اونور خیابون - زیر رو گذر - روی زیر گذر",
|
||||
file_mosavab: "file",
|
||||
polygon: [
|
||||
[51.515, -0.09],
|
||||
[51.52, -0.1],
|
||||
[51.52, -0.12],
|
||||
],
|
||||
};
|
||||
const validationSchema = object({
|
||||
description: string().required("وارد کردن توضیحات الزامیست!"),
|
||||
});
|
||||
const RoadSafetyFormContext = ({ rowId, mutate, setOpenRoadSafetyForm }) => {
|
||||
const defaultValues = {
|
||||
description: "",
|
||||
};
|
||||
const requestServer = useRequest({ notificationSuccess: true });
|
||||
const { message, loadingMessage, errorMessage } = usePrevStateOpinion();
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { isSubmitting, errors },
|
||||
} = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" });
|
||||
const onSubmit = async (data) => {
|
||||
const formData = new FormData();
|
||||
formData.append("description", data.description);
|
||||
requestServer(`${SUBMIT_ROAD_SAFETY_FORM}/${rowId}`, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then(() => {
|
||||
setOpenRoadSafetyForm(false);
|
||||
mutate();
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
return (
|
||||
<StyledForm onSubmit={handleSubmit(onSubmit)}>
|
||||
<DialogContent>
|
||||
<ApplicantRequestDetail data={fakeData} />
|
||||
<Stack spacing={2}>
|
||||
<QuestionSafetyForm />
|
||||
<PrevCartableOpinion
|
||||
message={message}
|
||||
loadingMessage={loadingMessage}
|
||||
errorMessage={errorMessage}
|
||||
/>
|
||||
<DescriptionForm register={register} errors={errors} />
|
||||
<DialogActions>
|
||||
<ManagerOrAssistantSubmit isSubmitting={isSubmitting} />
|
||||
</DialogActions>
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
</StyledForm>
|
||||
);
|
||||
};
|
||||
export default RoadSafetyFormContext;
|
||||
@@ -1,52 +0,0 @@
|
||||
import { Dialog, IconButton, Stack, Tooltip } from "@mui/material";
|
||||
import EngineeringIcon from "@mui/icons-material/Engineering";
|
||||
import DialogTransition from "@/core/components/DialogTransition";
|
||||
import { useState } from "react";
|
||||
import { Close } from "@mui/icons-material";
|
||||
import RoadSafetyFormContext from "./RoadSafetyFormContext";
|
||||
|
||||
const RoadSafetyForm = ({ rowId, mutate }) => {
|
||||
const [openRoadSafetyForm, setOpenRoadSafetyForm] = useState(false);
|
||||
return (
|
||||
<Stack>
|
||||
<Tooltip title="فرم ایمنی راه" arrow placement="right">
|
||||
<IconButton
|
||||
color="primary"
|
||||
sx={{ textTransform: "unset", alignSelf: "center" }}
|
||||
onClick={() => {
|
||||
setOpenRoadSafetyForm(true);
|
||||
}}
|
||||
>
|
||||
<EngineeringIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
PaperProps={{
|
||||
sx: {
|
||||
transition: "all .3s",
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
},
|
||||
}}
|
||||
open={openRoadSafetyForm}
|
||||
maxWidth={"lg"}
|
||||
TransitionComponent={DialogTransition}
|
||||
>
|
||||
<IconButton
|
||||
aria-label="close"
|
||||
onClick={() => setOpenRoadSafetyForm(false)}
|
||||
sx={{
|
||||
position: "absolute",
|
||||
right: 8,
|
||||
top: 8,
|
||||
zIndex: 10,
|
||||
color: (theme) => theme.palette.grey[500],
|
||||
}}
|
||||
>
|
||||
<Close />
|
||||
</IconButton>
|
||||
<RoadSafetyFormContext rowId={rowId} mutate={mutate} setOpenRoadSafetyForm={setOpenRoadSafetyForm} />
|
||||
</Dialog>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default RoadSafetyForm;
|
||||
@@ -1,75 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Dialog, DialogContent } from "@mui/material";
|
||||
import { object, string } from "yup";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import ApplicantRequestDetail from "@/core/components/ApplicantRequestDetail";
|
||||
|
||||
const fakeData = {
|
||||
id: 1,
|
||||
shomareh_darkhast: "2124",
|
||||
ostan: "ostan",
|
||||
shahr: "shahr",
|
||||
shahrestan: "shahrestan",
|
||||
bakhsh: "bakhsh",
|
||||
roosta: "roosta",
|
||||
tarikh_darkhast: "tarikh_darkhast",
|
||||
sazman: "sazman",
|
||||
masahat_zamin: "masahat_zamin",
|
||||
masahat_tarh: "masahat_tarh",
|
||||
gorooh_tarh: "gorooh_tarh",
|
||||
onvane_tarh: "onvane_tarh",
|
||||
address: "کرج - فلان جا - جنب پاساژ - نزدیک اونجا - اونور خیابون - زیر رو گذر - روی زیر گذر",
|
||||
file_mosavab: "file",
|
||||
polygon: [
|
||||
[51.515, -0.09],
|
||||
[51.52, -0.1],
|
||||
[51.52, -0.12],
|
||||
],
|
||||
};
|
||||
|
||||
const validationSchema = object({
|
||||
description: string().required("وارد کردن توضیحات الزامیست!"),
|
||||
});
|
||||
|
||||
const DetailDialog = ({ taskModal, setTaskModal, rowId, mutate }) => {
|
||||
const requestServer = useRequest({ auth: true });
|
||||
const defaultValues = {
|
||||
description: "",
|
||||
};
|
||||
const handleClose = () => {
|
||||
setTaskModal(false);
|
||||
};
|
||||
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { isSubmitting, errors, touchedFields },
|
||||
} = useForm({ defaultValues, resolver: yupResolver(validationSchema), mode: "all" });
|
||||
|
||||
const onSubmit = async (data) => {
|
||||
const formData = new FormData();
|
||||
formData.append("description", data.description);
|
||||
requestServer(`api-for-send-to-harim/${rowId}`, "post", {
|
||||
data: formData,
|
||||
})
|
||||
.then(() => {
|
||||
handleClose();
|
||||
mutate();
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
return (
|
||||
<StyledForm onSubmit={handleSubmit(onSubmit)}>
|
||||
<Dialog open={taskModal} onClose={handleClose} maxWidth="lg" fullWidth>
|
||||
<DialogContent dividers>
|
||||
<ApplicantRequestDetail data={fakeData} />
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</StyledForm>
|
||||
);
|
||||
};
|
||||
export default DetailDialog;
|
||||
@@ -1,26 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { IconButton, Tooltip } from "@mui/material";
|
||||
import AssignmentIcon from "@mui/icons-material/Assignment";
|
||||
import DetailDialog from "./DetailDialog";
|
||||
import { useState } from "react";
|
||||
|
||||
const TaskDetail = ({ rowId, mutate }) => {
|
||||
const [taskModal, setTaskModal] = useState(false);
|
||||
|
||||
const openDetailDialog = () => {
|
||||
setTaskModal(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="جزئیات طرح متقاضی" arrow placement="right">
|
||||
<IconButton color="primary" onClick={openDetailDialog}>
|
||||
<AssignmentIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<DetailDialog taskModal={taskModal} setTaskModal={setTaskModal} rowId={rowId} mutate={mutate} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default TaskDetail;
|
||||
@@ -1,13 +0,0 @@
|
||||
import TaskDetail from "./TaskDetail";
|
||||
import { Box } from "@mui/material";
|
||||
import RoadSafetyForm from "./RoadSafetyForm";
|
||||
|
||||
const RowActions = ({ row, mutate }) => {
|
||||
return (
|
||||
<Box sx={{ display: "flex", gap: 1 }}>
|
||||
<TaskDetail mutate={mutate} rowId={row.getValue("id")} />
|
||||
<RoadSafetyForm mutate={mutate} rowId={row.getValue("id")} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
export default RowActions;
|
||||
@@ -1,145 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useMemo } from "react";
|
||||
import { Box } from "@mui/material";
|
||||
import DataTableWithAuth from "@/core/components/DataTableWithAuth";
|
||||
import RowActions from "./RowActions";
|
||||
|
||||
const TaskList = () => {
|
||||
const columns = useMemo(
|
||||
() => [
|
||||
{
|
||||
accessorKey: "id",
|
||||
header: "کد یکتا",
|
||||
id: "id",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "notEquals",
|
||||
},
|
||||
{
|
||||
accessorKey: "aplication_number",
|
||||
header: "شماره درخواست",
|
||||
id: "aplication_number",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "notEquals",
|
||||
},
|
||||
{
|
||||
accessorKey: "application_date",
|
||||
header: "تاریخ درخواست",
|
||||
id: "application_date",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "province",
|
||||
header: "استان",
|
||||
id: "province",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "township",
|
||||
header: "شهرستان",
|
||||
id: "township",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "city",
|
||||
header: "شهر",
|
||||
id: "city",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "county",
|
||||
header: "بخش",
|
||||
id: "county",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "village",
|
||||
header: "روستا",
|
||||
id: "village",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "land_area",
|
||||
header: "مساحت زمین",
|
||||
id: "land_area",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "design_area",
|
||||
header: "مساحت طرح",
|
||||
id: "design_area",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "organization",
|
||||
header: "سازمان",
|
||||
id: "organization",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "design_group",
|
||||
header: "گروه طرح",
|
||||
id: "design_group",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "design_title",
|
||||
header: "عنوان طرح",
|
||||
id: "design_title",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
{
|
||||
accessorKey: "state",
|
||||
header: "وضعیت درخواست",
|
||||
id: "state",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
},
|
||||
],
|
||||
[]
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box sx={{ p: 1, border: 1, borderColor: "divider", borderRadius: 1 }}>
|
||||
<DataTableWithAuth
|
||||
table_title={"لیست استعلام ها"}
|
||||
need_filter={false}
|
||||
columns={columns}
|
||||
table_url={"/v3/api/fake-data"}
|
||||
page_name={"generalManagerZaminGov"}
|
||||
table_name={"generalManagerZaminGovList"}
|
||||
enableRowActions
|
||||
positionActionsColumn={"last"}
|
||||
RowActions={RowActions}
|
||||
/>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default TaskList;
|
||||
@@ -1,15 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import PageTitle from "@/core/components/PageTitle";
|
||||
import { Stack } from "@mui/material";
|
||||
import TaskList from "./TaskList";
|
||||
|
||||
const GeneralManagerZaminGovComponent = () => {
|
||||
return (
|
||||
<Stack spacing={1}>
|
||||
<PageTitle title={"استعلام حرائم پنجره واحد"} />
|
||||
<TaskList />
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default GeneralManagerZaminGovComponent;
|
||||
@@ -0,0 +1,248 @@
|
||||
import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency";
|
||||
import DataTableWithAuth from "@/core/components/DataTableWithAuth";
|
||||
import { GET_PRIVACY_ADMIN_LIST } from "@/core/utils/routes";
|
||||
import useInquiryPrivacyState from "@/lib/hooks/useInquiryPrivacyState";
|
||||
import AutorenewIcon from "@mui/icons-material/Autorenew";
|
||||
import DangerousIcon from "@mui/icons-material/Dangerous";
|
||||
import ManageAccountsIcon from "@mui/icons-material/ManageAccounts";
|
||||
import MapsHomeWorkIcon from "@mui/icons-material/MapsHomeWork";
|
||||
import PsychologyAltIcon from "@mui/icons-material/PsychologyAlt";
|
||||
import ReceiptLongIcon from "@mui/icons-material/ReceiptLong";
|
||||
import SecurityIcon from "@mui/icons-material/Security";
|
||||
import WindowIcon from "@mui/icons-material/Window";
|
||||
import { Box, Stack } from "@mui/material";
|
||||
import moment from "jalali-moment";
|
||||
import { useMemo } from "react";
|
||||
import RowActions from "./RowActions";
|
||||
|
||||
import ShowPrimaryArea from "./ShowPrimaryArea";
|
||||
|
||||
const PrivacyOfficeList = () => {
|
||||
const stateIcon = (state_id) => {
|
||||
if (state_id === 1) return <MapsHomeWorkIcon sx={{ color: "#A0B9C6" }} />;
|
||||
if (state_id === 2 || state_id === 5 || state_id === 13) return <SecurityIcon sx={{ color: "#995FA3" }} />;
|
||||
if (state_id === 3 || state_id === 6 || state_id === 14)
|
||||
return <ManageAccountsIcon sx={{ color: "#9A98B5" }} />;
|
||||
if (state_id === 4 || state_id === 7 || state_id === 15) return <PsychologyAltIcon sx={{ color: "#1B9AAA" }} />;
|
||||
if (state_id === 8) return <ReceiptLongIcon sx={{ color: "#9A98B5" }} />;
|
||||
if (state_id === 9 || state_id === 11) return <WindowIcon sx={{ color: "#DDDBCB" }} />;
|
||||
if (state_id === 10) return <DangerousIcon sx={{ color: "error.main" }} />;
|
||||
if (state_id === 12) return <AutorenewIcon sx={{ color: "#899878" }} />;
|
||||
};
|
||||
|
||||
const columns = useMemo(() => {
|
||||
return [
|
||||
{
|
||||
accessorKey: "panjare_vahed_id",
|
||||
header: "کدرهگیری درخواست",
|
||||
id: "panjare_vahed_id",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.panjare_vahed_id}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "national_id",
|
||||
header: "کد ملی",
|
||||
id: "national_id",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.national_id}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "state_id",
|
||||
header: "وضعیت",
|
||||
id: "state_id",
|
||||
enableColumnFilter: true,
|
||||
datatype: "numeric",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
grow: false,
|
||||
size: 100,
|
||||
ColumnSelectComponent: (props) => {
|
||||
const { itemsList, loadingItemsList, errorItemsList } = useInquiryPrivacyState();
|
||||
|
||||
const getColumnSelectOptions = 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 (
|
||||
<CustomSelectByDependency
|
||||
{...props}
|
||||
value={loadingItemsList ? "loading" : props.filterParameters.value}
|
||||
columnSelectOption={getColumnSelectOptions}
|
||||
/>
|
||||
);
|
||||
},
|
||||
Cell: ({ row }) => (
|
||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||
{stateIcon(row.original.state_id)}
|
||||
<Box component="span" ml={1}>
|
||||
{row.original.state_name}
|
||||
</Box>
|
||||
</Box>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "plan_title",
|
||||
header: "عنوان طرح",
|
||||
id: "plan_title",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.plan_title}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "plan_group",
|
||||
header: "گروه طرح",
|
||||
id: "plan_group",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.plan_group}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "requested_organization",
|
||||
header: "دستگاه صادر کننده",
|
||||
id: "requested_organization",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.requested_organization}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "worksheet_id",
|
||||
header: "شناسه کاربرگ",
|
||||
id: "worksheet_id",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.worksheet_id}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "primary_area",
|
||||
header: "نمایش محدوده طرح",
|
||||
id: "primary_area",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) =>
|
||||
row.original.primary_area && row.original.forbidden_area ? (
|
||||
<Stack alignItems={"center"} justifyContent={"center"}>
|
||||
<ShowPrimaryArea
|
||||
primaryArea={row.original.primary_area}
|
||||
forbiddenArea={row.original.forbidden_area}
|
||||
/>
|
||||
</Stack>
|
||||
) : (
|
||||
"-"
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "province_id",
|
||||
header: "استان",
|
||||
id: "province_id",
|
||||
enableColumnFilter: false,
|
||||
datatype: "numeric",
|
||||
sortDescFirst: false,
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.province_name}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "city_id",
|
||||
header: "شهر",
|
||||
id: "city_id",
|
||||
enableColumnFilter: false,
|
||||
datatype: "numeric",
|
||||
sortDescFirst: false,
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.city_name}</>,
|
||||
},
|
||||
{
|
||||
accessorKey: "isic",
|
||||
header: "کد آیسیک",
|
||||
id: "isic",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
filterMode: "equals",
|
||||
sortDescFirst: false,
|
||||
columnFilterModeOptions: ["equals", "contains"],
|
||||
grow: false,
|
||||
size: 100,
|
||||
Cell: ({ row }) => <>{row.original.isic}</>,
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => moment(row.request_date).locale("fa").format("YYYY/MM/DD"),
|
||||
header: "تاریخ درخواست",
|
||||
id: "request_date",
|
||||
enableColumnFilter: true,
|
||||
datatype: "date",
|
||||
filterMode: "between",
|
||||
grow: false,
|
||||
size: 100,
|
||||
},
|
||||
];
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box sx={{ p: 1, border: 1, borderColor: "divider", borderRadius: 1 }}>
|
||||
<DataTableWithAuth
|
||||
need_filter={true}
|
||||
columns={columns}
|
||||
table_url={GET_PRIVACY_ADMIN_LIST}
|
||||
page_name={"PrivacyOffice"}
|
||||
table_name={"PrivacyOfficeList"}
|
||||
enableRowActions
|
||||
positionActionsColumn={"first"}
|
||||
RowActions={RowActions}
|
||||
/>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default PrivacyOfficeList;
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Dialog, DialogTitle } from "@mui/material";
|
||||
import RenderActionForm from "./RenderActionForm";
|
||||
|
||||
const ActionDialog = ({ open, type, rowData, onClose, mutate }) => {
|
||||
const actionLabel = {
|
||||
reject_request: "رد درخواست",
|
||||
confirm_request: "تایید درخواست",
|
||||
refer_request: "ارجاع درخواست",
|
||||
}[type];
|
||||
|
||||
return (
|
||||
<Dialog open={open} fullWidth maxWidth="xs" onClose={onClose}>
|
||||
<DialogTitle>{actionLabel}</DialogTitle>
|
||||
|
||||
<RenderActionForm type={type} rowData={rowData} mutate={mutate} onClose={onClose} />
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
export default ActionDialog;
|
||||
@@ -0,0 +1,18 @@
|
||||
import ThumbUpIcon from "@mui/icons-material/ThumbUp";
|
||||
import { IconButton, Tooltip } from "@mui/material";
|
||||
|
||||
const ConfirmAction = ({ onClick, disabled }) => {
|
||||
if (disabled) return;
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="تایید اقدام">
|
||||
<span>
|
||||
<IconButton color="success" onClick={onClick} disabled={disabled}>
|
||||
<ThumbUpIcon />
|
||||
</IconButton>
|
||||
</span>
|
||||
</Tooltip>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default ConfirmAction;
|
||||
@@ -0,0 +1,228 @@
|
||||
import { calculatePolygonMetrics } from "@/core/utils/geoCalculations";
|
||||
import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes";
|
||||
import { safeParsePolygon } from "@/core/utils/utils";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
DialogActions,
|
||||
FormControl,
|
||||
FormHelperText,
|
||||
InputLabel,
|
||||
MenuItem,
|
||||
Select,
|
||||
TextField,
|
||||
} from "@mui/material";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Controller, useForm, useWatch } from "react-hook-form";
|
||||
|
||||
const formatNumber = (num) => {
|
||||
if (!num) return "";
|
||||
return Number(num).toLocaleString("en-US");
|
||||
};
|
||||
|
||||
const price_fee = 1; // TODO: Replace with real price_fee
|
||||
export default function ComputePaymentForm({ mutate, onClose, rowData }) {
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const request = useRequest({ notificationSuccess: true, notificationFailed: true });
|
||||
|
||||
const coordsArea = safeParsePolygon(rowData.final_area);
|
||||
const coordsPlan = safeParsePolygon(rowData.final_plan);
|
||||
|
||||
const areaMetrics = coordsArea ? calculatePolygonMetrics(coordsArea) : { area: 0 };
|
||||
const planMetrics = coordsPlan ? calculatePolygonMetrics(coordsPlan) : { area: 0 };
|
||||
|
||||
const calculatedArea = Number(areaMetrics.area.toFixed(2) || 0);
|
||||
const calculatedPlan = Number(planMetrics.area.toFixed(2) || 0);
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
setValue,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
defaultValues: {
|
||||
expert_description: "",
|
||||
traffic: "",
|
||||
road_type: "",
|
||||
position: "",
|
||||
final_area_space: calculatedArea, // عرصه
|
||||
final_plan_space: calculatedPlan, // عیان
|
||||
payment_amount: "",
|
||||
},
|
||||
});
|
||||
|
||||
const { traffic, road_type, position } = useWatch({
|
||||
control,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const hasGeometry = calculatedArea > 0 || calculatedPlan > 0;
|
||||
|
||||
const t = parseFloat(traffic || "");
|
||||
const r = parseFloat(road_type || "");
|
||||
const p = parseFloat(position || "");
|
||||
|
||||
const inputsValid = hasGeometry && !isNaN(t) && t > 0 && !isNaN(r) && r > 0 && !isNaN(p) && p > 0;
|
||||
|
||||
if (inputsValid) {
|
||||
const resultArea = t * r * p * calculatedArea * price_fee;
|
||||
const resultPlan = t * r * p * calculatedPlan * price_fee;
|
||||
|
||||
setValue("payment_amount", Math.floor(resultArea + resultPlan).toString());
|
||||
} else {
|
||||
setValue("payment_amount", "");
|
||||
}
|
||||
}, [traffic, road_type, position, setValue, calculatedArea, calculatedPlan]);
|
||||
|
||||
const onSubmit = (data) => {
|
||||
setIsSubmitting(true);
|
||||
|
||||
try {
|
||||
request(`${PRIVACY_ADMIN_ACTION_API}/computing_payment/${rowData.id}`, "post", {
|
||||
data,
|
||||
}).then(() => {
|
||||
onClose();
|
||||
mutate();
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error submitting payment:", error);
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Box sx={{ display: "flex", flexDirection: "column", gap: 3, mt: 1 }}>
|
||||
<Box sx={{ display: "flex", gap: 1 }}>
|
||||
<Controller
|
||||
name="traffic"
|
||||
control={control}
|
||||
rules={{ required: "ترافیک الزامی است" }}
|
||||
render={({ field }) => (
|
||||
<FormControl fullWidth>
|
||||
<InputLabel>ترافیک</InputLabel>
|
||||
<Select {...field} error={!!errors.traffic} label="ترافیک">
|
||||
<MenuItem value={1}>سبک</MenuItem>
|
||||
<MenuItem value={1.5}>متوسط</MenuItem>
|
||||
<MenuItem value={2}>سنگین</MenuItem>
|
||||
</Select>
|
||||
{errors.traffic && (
|
||||
<FormHelperText sx={{ color: "darkred" }}>{errors.traffic.message}</FormHelperText>
|
||||
)}
|
||||
</FormControl>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="road_type"
|
||||
control={control}
|
||||
rules={{ required: "نوع راه الزامی است" }}
|
||||
render={({ field }) => (
|
||||
<FormControl fullWidth>
|
||||
<InputLabel>نوع راه</InputLabel>
|
||||
<Select {...field} error={!!errors.road_type} label="نوع راه">
|
||||
<MenuItem value={1}>فرعی و راهآهن</MenuItem>
|
||||
<MenuItem value={1.5}>اصلی و بزرگراه</MenuItem>
|
||||
<MenuItem value={2}>آزادراه</MenuItem>
|
||||
</Select>
|
||||
{errors.road_type && (
|
||||
<FormHelperText sx={{ color: "darkred" }}>{errors.road_type.message}</FormHelperText>
|
||||
)}
|
||||
</FormControl>
|
||||
)}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
<Controller
|
||||
name="position"
|
||||
control={control}
|
||||
rules={{ required: "موقعیت اقتصادی الزامی است" }}
|
||||
render={({ field }) => (
|
||||
<FormControl fullWidth>
|
||||
<InputLabel>موقعیت اقتصادی</InputLabel>
|
||||
<Select {...field} error={!!errors.position} label="موقعیت اقتصادی">
|
||||
<MenuItem value={2}>در شعاع ۱۰ کیلومتری از مراکز استان</MenuItem>
|
||||
<MenuItem value={1.5}>در شعاع ۵ کیلومتری از سایر شهرها</MenuItem>
|
||||
</Select>
|
||||
{errors.position && (
|
||||
<FormHelperText sx={{ color: "darkred" }}>{errors.position.message}</FormHelperText>
|
||||
)}
|
||||
</FormControl>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Box sx={{ display: "flex", gap: 1 }}>
|
||||
<Controller
|
||||
name="final_area_space"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<TextField
|
||||
{...field}
|
||||
type="number"
|
||||
InputProps={{ readOnly: true }}
|
||||
fullWidth
|
||||
label="مساحت عرصه (متر مربع)"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
name="final_plan_space"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<TextField
|
||||
{...field}
|
||||
type="number"
|
||||
InputProps={{ readOnly: true }}
|
||||
fullWidth
|
||||
label="مساحت اعیان (متر مربع)"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
<Controller
|
||||
name="payment_amount"
|
||||
control={control}
|
||||
render={({ field }) => {
|
||||
const { value } = field;
|
||||
|
||||
return (
|
||||
<TextField
|
||||
fullWidth
|
||||
label="مبلغ پرداختی (ریال)"
|
||||
value={formatNumber(value)}
|
||||
InputProps={{ readOnly: true }}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="expert_description"
|
||||
control={control}
|
||||
rules={{ required: "توضیحات ناظر اجباری است" }}
|
||||
render={({ field }) => (
|
||||
<TextField
|
||||
{...field}
|
||||
fullWidth
|
||||
error={!!errors.expert_description}
|
||||
multiline
|
||||
minRows={3}
|
||||
label="توضیحات"
|
||||
helperText={errors.expert_description?.message}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<DialogActions>
|
||||
<Button onClick={onClose} variant="outlined" disabled={isSubmitting}>
|
||||
انصراف
|
||||
</Button>
|
||||
<Button variant="contained" onClick={handleSubmit(onSubmit)} disabled={isSubmitting}>
|
||||
انجام عملیات
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { Box, Button, DialogActions, TextField } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
|
||||
export default function ConfirmFileForm({ mutate, onClose, rowId }) {
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const request = useRequest({ notificationSuccess: true, notificationFailed: true });
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
defaultValues: {
|
||||
expert_description: "",
|
||||
},
|
||||
});
|
||||
|
||||
const onSubmit = (data) => {
|
||||
setIsSubmitting(true);
|
||||
|
||||
try {
|
||||
request(`${PRIVACY_ADMIN_ACTION_API}/file_accepted/${rowId}`, "post", {
|
||||
data,
|
||||
}).then(() => {
|
||||
onClose();
|
||||
mutate();
|
||||
});
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Box sx={{ display: "flex", flexDirection: "column", mt: 1 }}>
|
||||
<Controller
|
||||
name="expert_description"
|
||||
control={control}
|
||||
rules={{
|
||||
required: "توضیحات الزامی است",
|
||||
}}
|
||||
render={({ field }) => (
|
||||
<TextField
|
||||
{...field}
|
||||
fullWidth
|
||||
multiline
|
||||
minRows={3}
|
||||
label="توضیحات"
|
||||
error={!!errors.expert_description}
|
||||
helperText={errors.expert_description?.message}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<DialogActions>
|
||||
<Button onClick={onClose} variant="outlined" disabled={isSubmitting}>
|
||||
انصراف
|
||||
</Button>
|
||||
<Button variant="contained" onClick={handleSubmit(onSubmit)} disabled={isSubmitting}>
|
||||
{isSubmitting ? "در حال ثبت..." : "انجام عملیات"}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { Box, Button, Checkbox, DialogActions, FormControlLabel, TextField } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
|
||||
export default function ConfirmRequestForm({ mutate, onClose, rowId }) {
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const request = useRequest({ notificationSuccess: true, notificationFailed: true });
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
defaultValues: {
|
||||
expert_description: "",
|
||||
need_payment: false,
|
||||
needsAccessRoad: false,
|
||||
},
|
||||
});
|
||||
|
||||
const onSubmit = (data) => {
|
||||
const confirmType = data.needsAccessRoad ? "need_road_access" : "without_road_access";
|
||||
const url = `${PRIVACY_ADMIN_ACTION_API}/${confirmType}/${rowId}`;
|
||||
const body = {
|
||||
expert_description: data.expert_description,
|
||||
need_payment: data.need_payment ? 1 : 0,
|
||||
};
|
||||
|
||||
setIsSubmitting(true);
|
||||
try {
|
||||
request(url, "post", {
|
||||
data: body,
|
||||
}).then(() => {
|
||||
mutate();
|
||||
onClose();
|
||||
});
|
||||
} catch (error) {
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Box sx={{ display: "flex", flexDirection: "column", mt: 1 }}>
|
||||
<Controller
|
||||
name="expert_description"
|
||||
control={control}
|
||||
rules={{ required: "توضیحات الزامی است" }}
|
||||
render={({ field }) => (
|
||||
<TextField
|
||||
{...field}
|
||||
fullWidth
|
||||
multiline
|
||||
minRows={3}
|
||||
label="توضیحات"
|
||||
error={!!errors.expert_description}
|
||||
helperText={errors.expert_description?.message}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="need_payment"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<FormControlLabel
|
||||
control={<Checkbox {...field} checked={field.value} />}
|
||||
label="نیاز به پرداخت وجه خزانه"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="needsAccessRoad"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<FormControlLabel
|
||||
control={<Checkbox {...field} checked={field.value} />}
|
||||
label="نیاز به راه دسترسی"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<DialogActions>
|
||||
<Button onClick={onClose} variant="outlined" disabled={isSubmitting}>
|
||||
انصراف
|
||||
</Button>
|
||||
<Button variant="contained" onClick={handleSubmit(onSubmit)} disabled={isSubmitting}>
|
||||
انجام عملیات
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { Box, Button, DialogActions, TextField } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
|
||||
export default function ReferForm({ mutate, onClose, rowId }) {
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const request = useRequest({ notificationSuccess: true, notificationFailed: true });
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
defaultValues: {
|
||||
expert_description: "",
|
||||
},
|
||||
});
|
||||
|
||||
const onSubmit = (data) => {
|
||||
setIsSubmitting(true);
|
||||
try {
|
||||
request(`${PRIVACY_ADMIN_ACTION_API}/refer_request/${rowId}`, "post", {
|
||||
data,
|
||||
}).then(() => {
|
||||
onClose();
|
||||
mutate();
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Box sx={{ display: "flex", flexDirection: "column", mt: 1 }}>
|
||||
<Controller
|
||||
name="expert_description"
|
||||
control={control}
|
||||
rules={{
|
||||
required: "توضیحات الزامی است",
|
||||
}}
|
||||
render={({ field }) => (
|
||||
<TextField
|
||||
{...field}
|
||||
error={!!errors.expert_description}
|
||||
helperText={errors.expert_description?.message}
|
||||
fullWidth
|
||||
multiline
|
||||
minRows={3}
|
||||
label="توضیحات"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<DialogActions>
|
||||
<Button onClick={onClose} variant="outlined" disabled={isSubmitting}>
|
||||
انصراف
|
||||
</Button>
|
||||
<Button variant="contained" onClick={handleSubmit(onSubmit)} disabled={isSubmitting}>
|
||||
{isSubmitting ? "در حال ثبت..." : " انجام عملیات"}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { Box, Button, DialogActions, TextField } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
|
||||
export default function RejectFileForm({ mutate, onClose, rowId }) {
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const request = useRequest({ notificationSuccess: true, notificationFailed: true });
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
defaultValues: {
|
||||
expert_description: "",
|
||||
},
|
||||
});
|
||||
|
||||
const onSubmit = (data) => {
|
||||
setIsSubmitting(true);
|
||||
|
||||
try {
|
||||
request(`${PRIVACY_ADMIN_ACTION_API}/file_rejected/${rowId}`, "post", {
|
||||
data,
|
||||
}).then(() => {
|
||||
onClose();
|
||||
mutate();
|
||||
});
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Box sx={{ display: "flex", flexDirection: "column", mt: 1 }}>
|
||||
<Controller
|
||||
name="expert_description"
|
||||
control={control}
|
||||
rules={{
|
||||
required: "توضیحات الزامی است",
|
||||
}}
|
||||
render={({ field }) => (
|
||||
<TextField
|
||||
{...field}
|
||||
fullWidth
|
||||
multiline
|
||||
minRows={3}
|
||||
label="توضیحات"
|
||||
error={!!errors.expert_description}
|
||||
helperText={errors.expert_description?.message}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<DialogActions>
|
||||
<Button onClick={onClose} variant="outlined" disabled={isSubmitting}>
|
||||
انصراف
|
||||
</Button>
|
||||
<Button variant="contained" onClick={handleSubmit(onSubmit)} disabled={isSubmitting}>
|
||||
{isSubmitting ? "در حال ثبت..." : "انجام عملیات"}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import { PRIVACY_ADMIN_ACTION_API } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { Box, Button, DialogActions, TextField } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
|
||||
export default function RejectRequestForm({ mutate, onClose, rowId }) {
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const request = useRequest({ notificationSuccess: true, notificationFailed: true });
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
defaultValues: {
|
||||
expert_description: "",
|
||||
},
|
||||
});
|
||||
|
||||
const onSubmit = (data) => {
|
||||
setIsSubmitting(true);
|
||||
|
||||
try {
|
||||
request(`${PRIVACY_ADMIN_ACTION_API}/reject_request/${rowId}`, "post", {
|
||||
data,
|
||||
}).then(() => {
|
||||
onClose();
|
||||
mutate();
|
||||
});
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Box sx={{ display: "flex", flexDirection: "column", mt: 1 }}>
|
||||
<Controller
|
||||
name="expert_description"
|
||||
control={control}
|
||||
rules={{
|
||||
required: "توضیحات الزامی است",
|
||||
}}
|
||||
render={({ field }) => (
|
||||
<TextField
|
||||
{...field}
|
||||
fullWidth
|
||||
multiline
|
||||
minRows={3}
|
||||
label="توضیحات"
|
||||
error={!!errors.expert_description}
|
||||
helperText={errors.expert_description?.message}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<DialogActions>
|
||||
<Button onClick={onClose} variant="outlined" disabled={isSubmitting}>
|
||||
انصراف
|
||||
</Button>
|
||||
<Button variant="contained" onClick={handleSubmit(onSubmit)} disabled={isSubmitting}>
|
||||
{isSubmitting ? "در حال ثبت..." : "انجام عملیات"}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Button, DialogActions, DialogContent } from "@mui/material";
|
||||
import TableContent from "./TableContent";
|
||||
const HistoryContent = ({ setOpenReferReasonDialog, rowId }) => {
|
||||
return (
|
||||
<>
|
||||
<DialogContent>
|
||||
<TableContent rowId={rowId} />
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={() => setOpenReferReasonDialog(false)} variant="outlined" color="secondary" autoFocus>
|
||||
بستن
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default HistoryContent;
|
||||
@@ -0,0 +1,66 @@
|
||||
import {
|
||||
Box,
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableContainer,
|
||||
TableHead,
|
||||
TableRow,
|
||||
CircularProgress,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import "moment/locale/fa";
|
||||
import { useHistory } from "@/lib/hooks/useHistory";
|
||||
|
||||
const TableContent = ({ rowId }) => {
|
||||
const { historyData, loading, error } = useHistory(rowId);
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<Box display="flex" justifyContent="center" alignItems="center" height={200}>
|
||||
<CircularProgress />
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<Box display="flex" justifyContent="center" alignItems="center" height={200}>
|
||||
<Typography color="error">{error}</Typography>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
if (!historyData.length) {
|
||||
return (
|
||||
<Box display="flex" justifyContent="center" alignItems="center" height={200}>
|
||||
<Typography>اطلاعاتی وجود ندارد</Typography>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<TableContainer sx={{ maxHeight: 600 }}>
|
||||
<Table stickyHeader sx={{ minWidth: 800 }}>
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell>وضعیت</TableCell>
|
||||
<TableCell>توضیحات کارشناس</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{historyData.map((row) => (
|
||||
<TableRow key={row.id} sx={{ "&:last-child td, &:last-child th": { border: 0 } }}>
|
||||
<TableCell>{row.previous_state_name}</TableCell>
|
||||
<TableCell>{row.expert_description}</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</TableContainer>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default TableContent;
|
||||
@@ -0,0 +1,33 @@
|
||||
import { Dialog, DialogTitle, IconButton, Tooltip } from "@mui/material";
|
||||
import { RestorePage } from "@mui/icons-material";
|
||||
import HistoryContent from "./HistoryContent";
|
||||
import { useState } from "react";
|
||||
|
||||
const History = ({ rowId }) => {
|
||||
const [openReferReasonDialog, setOpenReferReasonDialog] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="تاریخچه">
|
||||
<IconButton color="warning" onClick={() => setOpenReferReasonDialog(true)}>
|
||||
<RestorePage />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
fullWidth
|
||||
maxWidth={"md"}
|
||||
open={openReferReasonDialog}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<DialogTitle>تاریخچه</DialogTitle>
|
||||
<HistoryContent rowId={rowId} setOpenReferReasonDialog={setOpenReferReasonDialog} />
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default History;
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Reply } from "@mui/icons-material";
|
||||
import { IconButton, Tooltip } from "@mui/material";
|
||||
|
||||
const ReferralAction = ({ onClick, disabled }) => {
|
||||
if (disabled) return;
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="ارجاع درخواست">
|
||||
<span>
|
||||
<IconButton color="info" onClick={onClick} disabled={disabled}>
|
||||
<Reply />
|
||||
</IconButton>
|
||||
</span>
|
||||
</Tooltip>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default ReferralAction;
|
||||
@@ -0,0 +1,18 @@
|
||||
import ThumbDownIcon from "@mui/icons-material/ThumbDown";
|
||||
import { IconButton, Tooltip } from "@mui/material";
|
||||
|
||||
const RejectAction = ({ onClick, disabled }) => {
|
||||
if (disabled) return;
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="عدم تایید اقدام">
|
||||
<span>
|
||||
<IconButton color="error" onClick={onClick} disabled={disabled}>
|
||||
<ThumbDownIcon />
|
||||
</IconButton>
|
||||
</span>
|
||||
</Tooltip>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default RejectAction;
|
||||
@@ -0,0 +1,32 @@
|
||||
import { DialogContent } from "@mui/material";
|
||||
import ComputePaymentForm from "./Forms/ComputePaymentForm";
|
||||
import ConfirmFileForm from "./Forms/ConfirmFileForm";
|
||||
import ConfirmRequestForm from "./Forms/ConfirmRequestForm";
|
||||
import ReferForm from "./Forms/ReferForm";
|
||||
import RejectFileForm from "./Forms/RejectFileForm";
|
||||
import RejectRequestForm from "./Forms/RejectRequestForm";
|
||||
|
||||
export default function RenderActionForm({ type, rowData, mutate, onClose }) {
|
||||
const formType = `${type}_${rowData?.state_id}`;
|
||||
|
||||
function renderForm() {
|
||||
switch (formType) {
|
||||
case "refer_request_2":
|
||||
return <ReferForm mutate={mutate} onClose={onClose} rowId={rowData.id} />;
|
||||
case "reject_request_2":
|
||||
return <RejectRequestForm mutate={mutate} onClose={onClose} rowId={rowData.id} />;
|
||||
case "reject_request_5":
|
||||
return <RejectFileForm mutate={mutate} onClose={onClose} rowId={rowData.id} />;
|
||||
case "confirm_request_2":
|
||||
return <ConfirmRequestForm mutate={mutate} onClose={onClose} rowId={rowData.id} />;
|
||||
case "confirm_request_5":
|
||||
return <ConfirmFileForm mutate={mutate} onClose={onClose} rowId={rowData.id} />;
|
||||
case "confirm_request_13":
|
||||
return <ComputePaymentForm mutate={mutate} onClose={onClose} rowData={rowData} />;
|
||||
default:
|
||||
return <></>;
|
||||
}
|
||||
}
|
||||
|
||||
return <DialogContent>{renderForm()}</DialogContent>;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import { Box } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import ActionDialog from "./ActionsDialog";
|
||||
import ConfirmAction from "./ConfirmAction";
|
||||
import ReferralAction from "./ReferralAction";
|
||||
import RejectAction from "./RejectAction";
|
||||
import History from "./History";
|
||||
|
||||
const RowActions = ({ row: { original }, mutate }) => {
|
||||
const [modal, setModal] = useState({
|
||||
open: false,
|
||||
type: null, // "reject_request" | "confirm_request" | "refer_request"
|
||||
rowData: null,
|
||||
});
|
||||
|
||||
const handleOpenModal = (type, rowData) => {
|
||||
setModal({ open: true, type, rowData });
|
||||
};
|
||||
|
||||
const handleCloseModal = () => {
|
||||
setModal({ open: false, type: null, rowData: null });
|
||||
};
|
||||
|
||||
const stateId = original.state_id;
|
||||
|
||||
const disabled = {
|
||||
referral: stateId !== 2,
|
||||
reject: stateId !== 2 && stateId !== 5,
|
||||
confirm: stateId !== 2 && stateId !== 5 && stateId !== 13,
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box sx={{ display: "flex", gap: 1, justifyContent: "center" }}>
|
||||
<History rowId={original.id} />
|
||||
<ReferralAction
|
||||
onClick={() => handleOpenModal("refer_request", original)}
|
||||
disabled={disabled.referral}
|
||||
/>
|
||||
<RejectAction onClick={() => handleOpenModal("reject_request", original)} disabled={disabled.reject} />
|
||||
<ConfirmAction
|
||||
onClick={() => handleOpenModal("confirm_request", original)}
|
||||
disabled={disabled.confirm}
|
||||
/>
|
||||
</Box>
|
||||
<ActionDialog
|
||||
open={modal.open}
|
||||
type={modal.type}
|
||||
rowData={modal.rowData}
|
||||
onClose={handleCloseModal}
|
||||
mutate={mutate}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default RowActions;
|
||||
@@ -0,0 +1,29 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { FeatureGroup, useMap } from "react-leaflet";
|
||||
|
||||
const ShowBound = ({ bound }) => {
|
||||
const map = useMap();
|
||||
const featureRef = useRef(null);
|
||||
|
||||
const safeFitBounds = (layer) => {
|
||||
if (!layer || !map) return;
|
||||
try {
|
||||
const latLngs = layer.getLatLngs();
|
||||
map.fitBounds(latLngs, {
|
||||
paddingTopLeft: [20, 20],
|
||||
paddingBottomRight: [20, 20],
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn("fitBounds failed:", e);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
bound?.editing?.disable();
|
||||
featureRef.current.addLayer(bound);
|
||||
safeFitBounds(bound);
|
||||
}, []);
|
||||
|
||||
return <FeatureGroup ref={featureRef} />;
|
||||
};
|
||||
export default ShowBound;
|
||||
@@ -0,0 +1,29 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { FeatureGroup, useMap } from "react-leaflet";
|
||||
|
||||
const ShowForbiddenBound = ({ bound }) => {
|
||||
const map = useMap();
|
||||
const featureRef = useRef(null);
|
||||
|
||||
const safeFitBounds = (layer) => {
|
||||
if (!layer || !map) return;
|
||||
try {
|
||||
const latLngs = layer.getLatLngs();
|
||||
map.fitBounds(latLngs, {
|
||||
paddingTopLeft: [20, 20],
|
||||
paddingBottomRight: [20, 20],
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn("fitBounds failed:", e);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
bound?.editing?.disable();
|
||||
featureRef.current.addLayer(bound);
|
||||
safeFitBounds(bound);
|
||||
}, []);
|
||||
|
||||
return <FeatureGroup ref={featureRef} />;
|
||||
};
|
||||
export default ShowForbiddenBound;
|
||||
@@ -0,0 +1,70 @@
|
||||
const { IconButton, Tooltip, Box, Dialog, DialogTitle, Typography, DialogContent } = require("@mui/material");
|
||||
import MapLayer from "@/core/components/MapLayer";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
import LayersIcon from "@mui/icons-material/Layers";
|
||||
import { useMemo, useState } from "react";
|
||||
import ShowBound from "./ShowBound";
|
||||
import ShowForbiddenBound from "./ShowForbiddenBound";
|
||||
|
||||
const ShowPrimaryArea = ({ primaryArea, forbiddenArea }) => {
|
||||
const [openShowAreaDialog, setOpenShowAreaDialog] = useState(false);
|
||||
const bound = useMemo(() => {
|
||||
const latLngCoords = primaryArea.coordinates.map((coord) => [coord[1], coord[0]]);
|
||||
return primaryArea.type === "polygon" ? L.polygon(latLngCoords) : L.polyline(latLngCoords);
|
||||
}, [primaryArea]);
|
||||
|
||||
const forbiddenBound = useMemo(() => {
|
||||
const latLngCoords = forbiddenArea.coordinates.map((coord) => [coord[1], coord[0]]);
|
||||
return forbiddenArea.type === "polygon"
|
||||
? L.polygon(latLngCoords, {
|
||||
color: "#ff5555",
|
||||
})
|
||||
: L.polyline(latLngCoords);
|
||||
}, [forbiddenArea]);
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<Tooltip title="نمایش پلیگان" placement="right" arrow>
|
||||
<IconButton size="small" color="primary" onClick={() => setOpenShowAreaDialog(true)}>
|
||||
<LayersIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog
|
||||
open={openShowAreaDialog}
|
||||
onClose={() => setOpenShowAreaDialog(false)}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
transition: "all .3s",
|
||||
boxShadow: "rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px",
|
||||
borderRadius: 2,
|
||||
padding: 1,
|
||||
},
|
||||
}}
|
||||
maxWidth="sm"
|
||||
fullWidth
|
||||
dir="rtl"
|
||||
>
|
||||
<DialogTitle sx={{ display: "flex", justifyContent: "space-between", padding: "16px 24px" }}>
|
||||
<Typography variant="body1" sx={{ fontWeight: "bold", fontSize: "large" }}>
|
||||
محدوده طرح
|
||||
</Typography>
|
||||
<IconButton onClick={() => setOpenShowAreaDialog(false)} size="small">
|
||||
<CloseIcon />
|
||||
</IconButton>
|
||||
</DialogTitle>
|
||||
<DialogContent>
|
||||
<Box sx={{ flex: 1 }}>
|
||||
<Box sx={{ width: "100%", height: "400px" }}>
|
||||
<MapLayer style={{ borderRadius: "4px" }}>
|
||||
<ShowBound bound={bound} />
|
||||
<ShowForbiddenBound bound={forbiddenBound} />
|
||||
</MapLayer>
|
||||
</Box>
|
||||
</Box>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default ShowPrimaryArea;
|
||||
@@ -0,0 +1,14 @@
|
||||
"use client";
|
||||
import PageTitle from "@/core/components/PageTitle";
|
||||
import { Stack } from "@mui/material";
|
||||
import PrivacyOfficeList from "./PrivacyOfficeList";
|
||||
|
||||
const PrivacyOfficePage = () => {
|
||||
return (
|
||||
<Stack spacing={1}>
|
||||
<PageTitle title={"کارتابل اداره حریم استعلام حریم"} />
|
||||
<PrivacyOfficeList />
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default PrivacyOfficePage;
|
||||
@@ -1,100 +0,0 @@
|
||||
import { Box, Button, ButtonGroup } from "@mui/material";
|
||||
import AutoModeIcon from "@mui/icons-material/AutoMode";
|
||||
import DeleteIcon from "@mui/icons-material/Delete";
|
||||
import EditLocationAltIcon from "@mui/icons-material/EditLocationAlt";
|
||||
import SaveIcon from "@mui/icons-material/Save";
|
||||
import CancelIcon from "@mui/icons-material/Cancel";
|
||||
|
||||
const MapActionButtons = ({
|
||||
disableToCreate,
|
||||
disableToEditAndDelete,
|
||||
disableToSaveAndCancel,
|
||||
onDraw,
|
||||
onEdit,
|
||||
onRemove,
|
||||
onSave,
|
||||
onCancel,
|
||||
}) => (
|
||||
<>
|
||||
<Box
|
||||
sx={{
|
||||
background: "#ffffff",
|
||||
position: "absolute",
|
||||
zIndex: "1999",
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
p: 2,
|
||||
pl: 0.5,
|
||||
pb: 0.5,
|
||||
borderTopRightRadius: 8,
|
||||
}}
|
||||
>
|
||||
<ButtonGroup variant="contained" orientation="vertical" aria-label="map action group button">
|
||||
<Button
|
||||
sx={{ justifyContent: "space-between" }}
|
||||
startIcon={<AutoModeIcon />}
|
||||
color="primary"
|
||||
disabled={disableToCreate}
|
||||
onClick={onDraw}
|
||||
>
|
||||
اصلاح
|
||||
</Button>
|
||||
<Button
|
||||
sx={{ justifyContent: "space-between" }}
|
||||
startIcon={<EditLocationAltIcon />}
|
||||
color="warning"
|
||||
disabled={disableToEditAndDelete}
|
||||
onClick={onEdit}
|
||||
>
|
||||
ویرایش
|
||||
</Button>
|
||||
<Button
|
||||
sx={{ justifyContent: "space-between" }}
|
||||
startIcon={<DeleteIcon />}
|
||||
color="error"
|
||||
disabled={disableToEditAndDelete}
|
||||
onClick={onRemove}
|
||||
>
|
||||
حذف
|
||||
</Button>
|
||||
</ButtonGroup>
|
||||
</Box>
|
||||
|
||||
<Box
|
||||
sx={{
|
||||
position: "absolute",
|
||||
zIndex: "1999",
|
||||
right: 10,
|
||||
top: 10,
|
||||
background: "#fff",
|
||||
borderRadius: 1,
|
||||
padding: 0.5,
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
sx={{ justifyContent: "space-between", mr: 1 }}
|
||||
startIcon={<SaveIcon />}
|
||||
variant="outlined"
|
||||
size="small"
|
||||
color="success"
|
||||
disabled={disableToSaveAndCancel}
|
||||
onClick={onSave}
|
||||
>
|
||||
ذخیره
|
||||
</Button>
|
||||
<Button
|
||||
sx={{ justifyContent: "space-between" }}
|
||||
startIcon={<CancelIcon />}
|
||||
variant="outlined"
|
||||
size="small"
|
||||
color="error"
|
||||
disabled={disableToSaveAndCancel}
|
||||
onClick={onCancel}
|
||||
>
|
||||
لغو تغییرات
|
||||
</Button>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
|
||||
export default MapActionButtons;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user