solve bug of two polygon editable
This commit is contained in:
170
src/assets/scss/leaflet-measure.scss
Normal file
170
src/assets/scss/leaflet-measure.scss
Normal file
@@ -0,0 +1,170 @@
|
||||
// leaflet-measure.scss
|
||||
|
||||
$color-divider: #ddd;
|
||||
$color-button: #5e66cc;
|
||||
$color-lightertext: #999;
|
||||
|
||||
$spacing-external: 12px;
|
||||
$spacing-internal: 10px;
|
||||
|
||||
$max-width: 280px;
|
||||
|
||||
$button-icon-size: 12px;
|
||||
$button-icon-spacing: 4px;
|
||||
|
||||
@mixin hoverbutton {
|
||||
color: $color-button;
|
||||
text-decoration: none;
|
||||
&:hover {
|
||||
opacity: 0.5;
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin button ($icon) {
|
||||
display: inline;
|
||||
width: auto;
|
||||
height: auto;
|
||||
padding-left: 20px;
|
||||
margin-right: $button-icon-spacing;
|
||||
line-height: 1em;
|
||||
border: 0;
|
||||
text-align: left;
|
||||
color: $color-button;
|
||||
&,
|
||||
&:hover {
|
||||
background-color: transparent;
|
||||
}
|
||||
background: {
|
||||
image: url('assets/#{ $icon }.png');
|
||||
repeat: no-repeat;
|
||||
position: 0% 50%;
|
||||
size: $button-icon-size $button-icon-size;
|
||||
}
|
||||
.leaflet-retina & {
|
||||
background-image: url('assets/#{ $icon }_@2X.png');
|
||||
}
|
||||
|
||||
@include hoverbutton;
|
||||
}
|
||||
|
||||
.leaflet-control-measure,
|
||||
.leaflet-measure-resultpopup {
|
||||
h3 {
|
||||
margin: 0 0 $spacing-external 0;
|
||||
padding-bottom: $spacing-internal;
|
||||
border-bottom: solid 1px $color-divider;
|
||||
}
|
||||
p {
|
||||
margin: $spacing-internal 0 0 0;
|
||||
line-height: 1.5em;
|
||||
&:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
.tasks {
|
||||
margin: $spacing-external 0 0 0;
|
||||
padding: $spacing-internal 0 0 0;
|
||||
border-top: solid 1px $color-divider;
|
||||
text-align: right;
|
||||
|
||||
list-style: none;
|
||||
list-style-image: none;
|
||||
|
||||
li {
|
||||
display: inline;
|
||||
margin: 0 $spacing-internal 0 0;
|
||||
&:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.coorddivider {
|
||||
color: $color-lightertext;
|
||||
}
|
||||
}
|
||||
|
||||
.leaflet-control-measure {
|
||||
max-width: $max-width;
|
||||
background: #fff;
|
||||
|
||||
.leaflet-control-measure-toggle,
|
||||
.leaflet-control-measure-toggle:hover {
|
||||
background: {
|
||||
size: 14px 14px;
|
||||
image: url(assets/rulers.png);
|
||||
}
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
.leaflet-touch & {
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
// Hide text
|
||||
text-indent: 100%;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
|
||||
.leaflet-retina & {
|
||||
background-image: url(assets/rulers_@2X.png);
|
||||
}
|
||||
|
||||
.leaflet-touch & {
|
||||
background-size: 16px 16px;
|
||||
}
|
||||
}
|
||||
|
||||
// Special styling because start prompt has no content, just header and tasks
|
||||
.startprompt {
|
||||
h3 {
|
||||
margin-bottom: $spacing-internal;
|
||||
}
|
||||
.tasks {
|
||||
margin-top: 0;
|
||||
padding-top: 0;
|
||||
border-top: 0;
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
|
||||
.leaflet-control-measure-interaction {
|
||||
padding: $spacing-internal $spacing-external;
|
||||
}
|
||||
|
||||
.results {
|
||||
.group {
|
||||
margin-top: $spacing-internal;
|
||||
padding-top: $spacing-internal;
|
||||
border-top: dotted 1px lighten($color-divider, 5);
|
||||
&:first-child {
|
||||
margin-top: 0;
|
||||
padding-top: 0;
|
||||
border-top: 0;
|
||||
}
|
||||
}
|
||||
.heading {
|
||||
margin-right: $spacing-internal * 0.5;
|
||||
color: $color-lightertext;
|
||||
}
|
||||
}
|
||||
|
||||
a.start {
|
||||
@include button(start);
|
||||
}
|
||||
a.cancel {
|
||||
@include button(cancel);
|
||||
}
|
||||
a.finish {
|
||||
@include button(check);
|
||||
}
|
||||
}
|
||||
|
||||
.leaflet-measure-resultpopup {
|
||||
a.zoomto {
|
||||
@include button(focus);
|
||||
}
|
||||
a.deletemarkup {
|
||||
@include button(trash);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,37 @@
|
||||
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 { Box } from '@mui/material';
|
||||
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: "id",
|
||||
header: "کد یکتا",
|
||||
accessorKey: "panjare_vahed_id",
|
||||
header: "کدرهگیری درخواست",
|
||||
id: "panjare_vahed_id",
|
||||
enableColumnFilter: true,
|
||||
datatype: "text",
|
||||
@@ -33,6 +55,166 @@ const CityAdminList = () => {
|
||||
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,
|
||||
},
|
||||
];
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
import React, { useCallback, useEffect, useRef, useState } from "react";
|
||||
import L from "leaflet";
|
||||
import { FeatureGroup, useMap } from "react-leaflet";
|
||||
import "leaflet-draw";
|
||||
|
||||
const DrawPolygon = ({ control, controlDispach, drawBound, setDrawBound }) => {
|
||||
const map = useMap();
|
||||
const featureRef = useRef(null);
|
||||
const [area, setArea] = useState();
|
||||
const drawControlRef = useRef(null);
|
||||
|
||||
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 = (layer) => {
|
||||
if (!layer) return;
|
||||
layer.on("edit", function (e) {
|
||||
const editedLayer = e.target;
|
||||
setArea(editedLayer);
|
||||
setDrawBound(editedLayer);
|
||||
});
|
||||
};
|
||||
|
||||
const handlerCreatedBound = useCallback((event) => {
|
||||
const { layer } = event;
|
||||
layer.editing.enable();
|
||||
featureRef.current.addLayer(layer);
|
||||
setArea(layer);
|
||||
setDrawBound(layer);
|
||||
bindEditEvent(layer);
|
||||
controlDispach({ type: "SET_STATUS", status: 2 });
|
||||
}, []);
|
||||
|
||||
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 && area && featureRef.current) {
|
||||
featureRef.current.removeLayer(area);
|
||||
setArea(null);
|
||||
setDrawBound(null);
|
||||
}
|
||||
}, [control.status, area]);
|
||||
|
||||
useEffect(() => {
|
||||
if (control.status === 2 && drawBound && featureRef.current) {
|
||||
setArea(drawBound);
|
||||
featureRef.current.addLayer(drawBound);
|
||||
drawBound.editing.enable();
|
||||
safeFitBounds(drawBound);
|
||||
bindEditEvent(drawBound);
|
||||
}
|
||||
}, [control.status, drawBound]);
|
||||
|
||||
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: false,
|
||||
},
|
||||
});
|
||||
|
||||
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,116 @@
|
||||
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} />
|
||||
<Stack
|
||||
direction={"row"}
|
||||
justifyContent={"center"}
|
||||
sx={{ 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>
|
||||
</Stack>
|
||||
<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))",
|
||||
}}
|
||||
>
|
||||
<Stack direction={"row"} justifyContent={"center"} spacing={2}>
|
||||
{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>
|
||||
))}
|
||||
</Stack>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default MapDrawPolygon;
|
||||
@@ -0,0 +1,135 @@
|
||||
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 { useEffect, 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]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
console.log("drawBound", drawBound);
|
||||
|
||||
}, [drawBound])
|
||||
|
||||
|
||||
const {
|
||||
control,
|
||||
register,
|
||||
handleSubmit,
|
||||
setValue,
|
||||
formState: { isSubmitting, errors },
|
||||
} = useForm({
|
||||
defaultValues: {expert_description: "", forbidden_area: ""},
|
||||
resolver: yupResolver(validationSchema),
|
||||
mode: "all"
|
||||
});
|
||||
|
||||
|
||||
const onSubmit = async (data) => {
|
||||
const formData = new FormData();
|
||||
formData.append("expert_description", data.expert_description);
|
||||
|
||||
try {
|
||||
await requestServer(`${CITY_ADMIN_FEEDBACK}/${rowId}`, "post", {
|
||||
data: formData,
|
||||
});
|
||||
mutate();
|
||||
setOpenFeedbackDialog(false);
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box>
|
||||
<Tooltip title="ارسال بازخورد">
|
||||
<IconButton color="primary" 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
|
||||
@@ -1,13 +1,10 @@
|
||||
import { Box } from "@mui/material";
|
||||
import ConfirmAction from "./ConfirmAction";
|
||||
import RejectAction from "./RejectAction";
|
||||
import FeedbackAction from "./FeedbackAction";
|
||||
|
||||
const RowActions = ({ row, mutate }) => {
|
||||
|
||||
return (
|
||||
<Box sx={{ display: "flex", gap: 1 }}>
|
||||
<RejectAction />
|
||||
<ConfirmAction />
|
||||
<Box sx={{ display: "flex", gap: 1, justifyContent: "Center" }}>
|
||||
<FeedbackAction mutate={mutate} rowId={row.original.id} rowPrimaryArea={row.original.primary_area} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -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,61 @@
|
||||
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 @@
|
||||
import { Box } from "@mui/material";
|
||||
import ConfirmAction from "./ConfirmAction";
|
||||
import RejectAction from "./RejectAction";
|
||||
|
||||
const RowActions = ({ row, mutate }) => {
|
||||
|
||||
return (
|
||||
<Box sx={{ display: "flex", gap: 1, justifyContent: "Center" }}>
|
||||
<RejectAction />
|
||||
<ConfirmAction />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
export default RowActions;
|
||||
@@ -24,6 +24,10 @@ import RouteIcon from "@mui/icons-material/Route";
|
||||
import ScienceIcon from "@mui/icons-material/Science";
|
||||
import SpaceDashboardIcon from "@mui/icons-material/SpaceDashboard";
|
||||
import SpeedIcon from "@mui/icons-material/Speed";
|
||||
import PsychologyAltIcon from '@mui/icons-material/PsychologyAlt';
|
||||
import MapsHomeWorkIcon from '@mui/icons-material/MapsHomeWork';
|
||||
import SecurityIcon from '@mui/icons-material/Security';
|
||||
import ManageAccountsIcon from '@mui/icons-material/ManageAccounts';
|
||||
|
||||
export const pageMenuDev = [
|
||||
{
|
||||
@@ -299,6 +303,7 @@ export const pageMenuDev = [
|
||||
label: "کارتابل شهرستان",
|
||||
type: "page",
|
||||
route: "/dashboard/inquiry-privacy/city-admin",
|
||||
icon: <MapsHomeWorkIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||
permissions: ["all"],
|
||||
},
|
||||
{
|
||||
@@ -306,6 +311,7 @@ export const pageMenuDev = [
|
||||
label: "کارتابل اداره حریم",
|
||||
type: "page",
|
||||
route: "/dashboard/inquiry-privacy/privacy-office",
|
||||
icon: <SecurityIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||
permissions: ["all"],
|
||||
},
|
||||
{
|
||||
@@ -313,6 +319,7 @@ export const pageMenuDev = [
|
||||
label: "کارتابل معاون",
|
||||
type: "page",
|
||||
route: "/dashboard/inquiry-privacy/assistant",
|
||||
icon: <ManageAccountsIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||
permissions: ["all"],
|
||||
},
|
||||
{
|
||||
@@ -320,6 +327,7 @@ export const pageMenuDev = [
|
||||
label: "کارتابل مدیر",
|
||||
type: "page",
|
||||
route: "/dashboard/inquiry-privacy/general-manager",
|
||||
icon: <PsychologyAltIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||
permissions: ["all"],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -236,4 +236,6 @@ export const UPDATE_RAHDARAN_ITEM = api + "/api/v3/rahdaran";
|
||||
export const CREATE_RAHDARAN_ITEM = api + "/api/v3/rahdaran";
|
||||
|
||||
// estelam harim
|
||||
export const GET_CITY_ADMIN_LIST = api + "/api/v3/harim/province_office";
|
||||
export const GET_CITY_ADMIN_LIST = api + "/api/v3/harim/province_office";
|
||||
export const GET_INQUIRY_PRIVACY_STATE_LIST = api + "/api/v3/harim/detail/states";
|
||||
export const CITY_ADMIN_FEEDBACK = api + "/api/v3/harim/province_office/feedback";
|
||||
30
src/lib/hooks/useInquiryPrivacyState.js
Normal file
30
src/lib/hooks/useInquiryPrivacyState.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import { GET_INQUIRY_PRIVACY_STATE_LIST } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
const useInquiryPrivacyState = () => {
|
||||
const requestServer = useRequest();
|
||||
const [itemsList, setItemsList] = useState([]);
|
||||
const [loadingItemsList, setLoadingItemsList] = useState(true);
|
||||
const [errorItemsList, setErrorItemsList] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchItems = async () => {
|
||||
try {
|
||||
const response = await requestServer(`${GET_INQUIRY_PRIVACY_STATE_LIST}`);
|
||||
setItemsList(response.data.data);
|
||||
setLoadingItemsList(false);
|
||||
setErrorItemsList(false);
|
||||
} catch (e) {
|
||||
setErrorItemsList(e);
|
||||
setLoadingItemsList(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchItems();
|
||||
}, []);
|
||||
|
||||
return { itemsList, loadingItemsList, errorItemsList };
|
||||
};
|
||||
|
||||
export default useInquiryPrivacyState;
|
||||
Reference in New Issue
Block a user