-

-
- ${labelText}
+
- `,
- iconSize: size,
- iconAnchor: [size[0] / 2, size[1]],
- popupAnchor: [0, -size[1]],
+
+
`,
+ iconSize: [50, 50],
+ iconAnchor: [25, 50],
});
}
-
return L.icon({
iconUrl: iconUrl,
iconSize: size,
@@ -48,6 +42,8 @@ const MapInteraction = ({ setValue, startLat, startLng, endLat, endLng }) => {
const [startPosition, setStartPosition] = useState(startLat && startLng ? { lat: startLat, lng: startLng } : null);
const [endPosition, setEndPosition] = useState(endLat && endLng ? { lat: endLat, lng: endLng } : null);
const [enableSend, setEnableSend] = useState(false);
+ const [startIconColor, setStartIconColor] = useState(startLat ? "#1CAC66" : "#003d4f"); // رنگ آیکن شروع
+ const [endIconColor, setEndIconColor] = useState(endLat ? "#D13131" : "#003d4f"); // رنگ آیکن پایان
const startRef = useRef();
const endRef = useRef();
@@ -86,6 +82,7 @@ const MapInteraction = ({ setValue, startLat, startLng, endLat, endLng }) => {
setIsStartLocked(false);
setStartPosition(null);
setValue("start_point", null);
+ setStartIconColor("#003d4f");
};
const handleUnlockEnd = () => {
@@ -95,6 +92,8 @@ const MapInteraction = ({ setValue, startLat, startLng, endLat, endLng }) => {
setStartPosition(null);
setValue("end_point", "");
setValue("start_point", null);
+ setStartIconColor("#003d4f");
+ setEndIconColor("#003d4f");
};
return (
@@ -102,7 +101,7 @@ const MapInteraction = ({ setValue, startLat, startLng, endLat, endLng }) => {
{
if (!enableSend) return;
@@ -111,6 +110,8 @@ const MapInteraction = ({ setValue, startLat, startLng, endLat, endLng }) => {
setValue("start_point", { lat: center.lat.toString(), lng: center.lng.toString() });
setStartPosition({ lat: center.lat, lng: center.lng });
setIsStartLocked(true);
+ setStartIconColor("#1CAC66");
+ map.panBy([25, 25])
}
},
}}
@@ -172,7 +173,7 @@ const MapInteraction = ({ setValue, startLat, startLng, endLat, endLng }) => {
{
if (!enableSend) return;
@@ -181,6 +182,14 @@ const MapInteraction = ({ setValue, startLat, startLng, endLat, endLng }) => {
setValue("end_point", { lat: center.lat.toString(), lng: center.lng.toString() });
setEndPosition({ lat: center.lat, lng: center.lng });
setIsEndLocked(true);
+ setEndIconColor("#D13131");
+ map.fitBounds(
+ [
+ startPosition,
+ map.getCenter(),
+ ],
+ { paddingTopLeft: [16, 16], paddingBottomRight: [16, 16] }
+ );
}
},
}}
diff --git a/src/core/components/MuiDatePicker.jsx b/src/core/components/MuiDatePicker.jsx
index 78ffe58..10d5dff 100644
--- a/src/core/components/MuiDatePicker.jsx
+++ b/src/core/components/MuiDatePicker.jsx
@@ -59,9 +59,11 @@ function MuiDatePicker({ value, setFieldValue, name, minDate, maxDate, helperTex
},
}}
/>
-
- {helperText ? helperText : ""}
-
+ {helperText ? (
+
+ {helperText}
+
+ ) : null}
);
diff --git a/src/core/components/MuiTimePicker.jsx b/src/core/components/MuiTimePicker.jsx
index 35532fd..8aeace6 100644
--- a/src/core/components/MuiTimePicker.jsx
+++ b/src/core/components/MuiTimePicker.jsx
@@ -64,9 +64,11 @@ function MuiTimePicker({ value, setFieldValue, name, minTime, maxTime, helperTex
},
}}
/>
-
- {helperText ? helperText : ""}
-
+ {helperText ? (
+
+ {helperText}
+
+ ) : null}
);
diff --git a/src/core/components/RahdarCode.jsx b/src/core/components/RahdarCode.jsx
index 76592ef..1c374ee 100644
--- a/src/core/components/RahdarCode.jsx
+++ b/src/core/components/RahdarCode.jsx
@@ -22,7 +22,11 @@ const RahdarCode = ({ rahdarsCode, setRahdarsCode, error, multiple = true }) =>
requestOptions: { signal: controller.signal },
})
.then((response) => {
- setOptions(response.data.data || []);
+ const combinedArray = rahdarsCode
+ ? [...rahdarsCode, ...response.data.data]
+ : [...response.data.data];
+ const uniqueArray = Array.from(new Map(combinedArray.map((item) => [item.id, item])).values());
+ setOptions(uniqueArray || []);
})
.catch(() => {
setOptions([]);
diff --git a/src/core/middlewares/withPermission.js b/src/core/middlewares/withPermission.js
index c6e3661..0da81c9 100644
--- a/src/core/middlewares/withPermission.js
+++ b/src/core/middlewares/withPermission.js
@@ -2,16 +2,24 @@
import { Box, Typography } from "@mui/material";
import { usePermissions } from "@/lib/hooks/usePermissions";
+import { useEffect, useState } from "react";
function WithPermission({ children, permission_name }) {
const { data, error, isLoading } = usePermissions();
+ const [cachedData, setCachedData] = useState(null);
- if (error || isLoading || !data || !permission_name) {
+ useEffect(() => {
+ if (data) {
+ setCachedData(data);
+ }
+ }, [data]);
+
+ if (error || isLoading || !cachedData || !permission_name) {
return null;
}
const hasPermission =
- permission_name.includes("all") || permission_name.some((permission) => data.includes(permission));
+ permission_name.includes("all") || permission_name.some((permission) => cachedData.includes(permission));
if (!hasPermission) {
return (
diff --git a/src/core/utils/formatCounter.js b/src/core/utils/formatCounter.js
new file mode 100644
index 0000000..7cf9122
--- /dev/null
+++ b/src/core/utils/formatCounter.js
@@ -0,0 +1,7 @@
+export const formatCounter = (counter) => {
+ const minutes = Math.floor(counter / 60)
+ .toString()
+ .padStart(2, "0");
+ const seconds = (counter % 60).toString().padStart(2, "0");
+ return `${minutes}:${seconds}`;
+};
diff --git a/src/core/utils/pageMenu.js b/src/core/utils/pageMenu.js
index f77574f..bf392e4 100644
--- a/src/core/utils/pageMenu.js
+++ b/src/core/utils/pageMenu.js
@@ -195,13 +195,6 @@ export const pageMenu = [
hasSubitems: true,
badges: ["road_patrols.operation_cnt"],
Subitems: [
- {
- id: "roadPatrolManagmentOparationCreate",
- label: "ثبت اقدام",
- type: "page",
- route: "/dashboard/road-patrols/operator",
- permissions: ["add-road-patrol"],
- },
{
id: "roadPatrolManagmentOparationCartable",
label: "کارتابل",
diff --git a/src/core/utils/routes.js b/src/core/utils/routes.js
index db6c244..06fe15d 100644
--- a/src/core/utils/routes.js
+++ b/src/core/utils/routes.js
@@ -30,9 +30,13 @@ export const UPDATE_AZMAYESH_TYPE = api + "/api/v3/azmayesh_types/update";
//road patrol
export const GET_ROAD_PATROL_OPERATOR_LIST = api + "/api/v3/road_patrols/operator_index";
-export const EXPORT_ROAD_PATROL_OPERATOR_LIST = "https://rms.rmto.ir/v2/road_patrols/operator/cartable/report";
+export const EXPORT_ROAD_PATROL_OPERATOR_LIST = "https://rms.witel.ir/v2/road_patrols/operator/cartable/report";
export const GET_ROAD_PATROL_SUPERVISOR_LIST = api + "/api/v3/road_patrols/supervisor_index";
-export const EXPORT_ROAD_PATROL_SUPERVISOR_LIST = "https://rms.rmto.ir/v2/road_patrols/supervisor/cartable/report";
+export const EXPORT_ROAD_PATROL_SUPERVISOR_LIST = "https://rms.witel.ir/v2/road_patrols/supervisor/cartable/report";
+export const DELETE_ROAD_PATROL_SUPERVISOR = api + "/api/v3/road_patrols/delete";
+export const CREATE_PATROL = api + "/api/v3/road_patrols/store";
+export const GET_FMS_DATA = api + "/api/v3/fms_vehicle/get_activity";
+export const GET_OTP_TOKEN = api + "/v2/get_otp_token";
// road items
export const GET_ROAD_ITEMS_SUPERVISOR_LIST = api + "/api/v3/road_items/supervisor_index";
@@ -50,3 +54,7 @@ export const DELETE_BY_SUPERVISOR = api + "/api/v3/road_items/delete";
export const RESTORE_BY_SUPERVISOR = api + "/api/v3/road_items/restore";
export const GET_CAR_LIST_SEARCH = api + "/api/v3/cmms_machines/search";
export const GET_RAHDARANS_LIST_SEARCH = api + "/api/v3/rahdaran/search";
+export const GET_OBSERVED_GASHT_LIST = api + "/api/v3/observed_items/filter";
+
+// activity code log
+export const ACTIVITY_LOG = api + "/api/v3/profile/add_activity";
diff --git a/src/core/utils/theme.js b/src/core/utils/theme.js
index 85c8f68..7cde9e0 100644
--- a/src/core/utils/theme.js
+++ b/src/core/utils/theme.js
@@ -1,5 +1,6 @@
"use client";
import { createTheme } from "@mui/material";
+import { grey } from '@mui/material/colors';
const theme = createTheme({
direction: "rtl",
@@ -16,6 +17,9 @@ const theme = createTheme({
main: "#015688",
contrastText: "#fff",
},
+ secondary: {
+ main: grey[700],
+ }
},
components: {
MuiBackdrop: {
diff --git a/src/lib/hooks/usePermissions.js b/src/lib/hooks/usePermissions.js
index 004ff6d..3fb4921 100644
--- a/src/lib/hooks/usePermissions.js
+++ b/src/lib/hooks/usePermissions.js
@@ -14,5 +14,5 @@ export const usePermissions = () => {
}
};
- return useSWR(GET_PERMISSIONS_ROUTE, fetcher, { keepPreviousData: true });
+ return useSWR(GET_PERMISSIONS_ROUTE, fetcher, { keepPreviousData: true, dedupingInterval: 30000 });
};
diff --git a/src/lib/hooks/useRequest.js b/src/lib/hooks/useRequest.js
index f160f53..8e6d121 100644
--- a/src/lib/hooks/useRequest.js
+++ b/src/lib/hooks/useRequest.js
@@ -20,7 +20,6 @@ const useRequest = (initOptions) => {
return async (url = "", method = "get", options) => {
const mergedOptions = Object.assign({}, _options, options);
-
try {
const response = await axios({
url,
diff --git a/src/lib/hooks/useSidebarBadge.js b/src/lib/hooks/useSidebarBadge.js
index 621ce55..29e5fed 100644
--- a/src/lib/hooks/useSidebarBadge.js
+++ b/src/lib/hooks/useSidebarBadge.js
@@ -14,5 +14,5 @@ export const useSidebarBadge = () => {
}
};
- return useSWR(GET_SIDEBAR_BADGE_ROUTE, fetcher, { keepPreviousData: true });
+ return useSWR(GET_SIDEBAR_BADGE_ROUTE, fetcher, { keepPreviousData: true, dedupingInterval: 10000 });
};