build and format
This commit is contained in:
@@ -8,7 +8,7 @@ import { useAuth } from "@/lib/contexts/auth";
|
|||||||
import { missionRegions } from "@/core/utils/missionRegions";
|
import { missionRegions } from "@/core/utils/missionRegions";
|
||||||
|
|
||||||
const MissionList = ({ setMission, setOpenDialog }) => {
|
const MissionList = ({ setMission, setOpenDialog }) => {
|
||||||
const {user} = useAuth()
|
const { user } = useAuth();
|
||||||
const columns = useMemo(
|
const columns = useMemo(
|
||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -42,33 +42,31 @@ const ReportPage = () => {
|
|||||||
{ value: `${data.date_to}`, datatype: "date", id: "date_to", fn: "between" },
|
{ value: `${data.date_to}`, datatype: "date", id: "date_to", fn: "between" },
|
||||||
]);
|
]);
|
||||||
// if (data.province_id === "-1") {
|
// if (data.province_id === "-1") {
|
||||||
try {
|
try {
|
||||||
params.set("province_id", `${data.province_id}`);
|
params.set("province_id", `${data.province_id}`);
|
||||||
const response = await requestServer(`${GET_CITY_ACTIVITY_REPORT}?${params}`);
|
const response = await requestServer(`${GET_CITY_ACTIVITY_REPORT}?${params}`);
|
||||||
const result = response.data.data;
|
const result = response.data.data;
|
||||||
console.log(result);
|
console.log(result);
|
||||||
const nationalReportForItem = result.activities.find((report) => report.province_id === -1);
|
const nationalReportForItem = result.activities.find((report) => report.province_id === -1);
|
||||||
const nationalReport = {
|
const nationalReport = {
|
||||||
edare_name: "کل کشور",
|
edare_name: "کل کشور",
|
||||||
...nationalReportForItem,
|
...nationalReportForItem,
|
||||||
};
|
};
|
||||||
|
|
||||||
setData({
|
setData({
|
||||||
data: [
|
data: [
|
||||||
nationalReport,
|
nationalReport,
|
||||||
...result.provinces.map((province) => {
|
...result.provinces.map((province) => {
|
||||||
const filteredReports = result.activities.find(
|
const filteredReports = result.activities.find((report) => report.province_id === province.id);
|
||||||
(report) => report.province_id === province.id
|
return {
|
||||||
);
|
...filteredReports,
|
||||||
return {
|
edare_name: province.name_fa,
|
||||||
...filteredReports,
|
};
|
||||||
edare_name: province.name_fa,
|
}),
|
||||||
};
|
],
|
||||||
}),
|
filters: data,
|
||||||
],
|
});
|
||||||
filters: data,
|
} catch (e) {}
|
||||||
});
|
|
||||||
} catch (e) {}
|
|
||||||
// } else {
|
// } else {
|
||||||
// try {
|
// try {
|
||||||
// params.set("province_id", `${data.province_id}`);
|
// params.set("province_id", `${data.province_id}`);
|
||||||
|
|||||||
@@ -1,29 +1,29 @@
|
|||||||
import { useEffect, useRef } from "react";
|
import { useEffect, useRef } from "react";
|
||||||
import { FeatureGroup, useMap } from "react-leaflet";
|
import { FeatureGroup, useMap } from "react-leaflet";
|
||||||
|
|
||||||
const ShowBound = ({ bound }) => {
|
const ShowBound = ({ bound }) => {
|
||||||
const map = useMap();
|
const map = useMap();
|
||||||
const featureRef = useRef(null);
|
const featureRef = useRef(null);
|
||||||
|
|
||||||
const safeFitBounds = (layer) => {
|
const safeFitBounds = (layer) => {
|
||||||
if (!layer || !map) return;
|
if (!layer || !map) return;
|
||||||
try {
|
try {
|
||||||
const latLngs = layer.getLatLngs();
|
const latLngs = layer.getLatLngs();
|
||||||
map.fitBounds(latLngs, {
|
map.fitBounds(latLngs, {
|
||||||
paddingTopLeft: [20, 20],
|
paddingTopLeft: [20, 20],
|
||||||
paddingBottomRight: [20, 20],
|
paddingBottomRight: [20, 20],
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn("fitBounds failed:", e);
|
console.warn("fitBounds failed:", e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
bound?.editing?.disable();
|
bound?.editing?.disable();
|
||||||
featureRef.current.addLayer(bound);
|
featureRef.current.addLayer(bound);
|
||||||
safeFitBounds(bound);
|
safeFitBounds(bound);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return <FeatureGroup ref={featureRef} />;
|
return <FeatureGroup ref={featureRef} />;
|
||||||
};
|
};
|
||||||
export default ShowBound;
|
export default ShowBound;
|
||||||
|
|||||||
Reference in New Issue
Block a user