build and format
This commit is contained in:
@@ -8,7 +8,7 @@ import { useAuth } from "@/lib/contexts/auth";
|
||||
import { missionRegions } from "@/core/utils/missionRegions";
|
||||
|
||||
const MissionList = ({ setMission, setOpenDialog }) => {
|
||||
const {user} = useAuth()
|
||||
const { user } = useAuth();
|
||||
const columns = useMemo(
|
||||
() => [
|
||||
{
|
||||
|
||||
@@ -42,33 +42,31 @@ const ReportPage = () => {
|
||||
{ value: `${data.date_to}`, datatype: "date", id: "date_to", fn: "between" },
|
||||
]);
|
||||
// if (data.province_id === "-1") {
|
||||
try {
|
||||
params.set("province_id", `${data.province_id}`);
|
||||
const response = await requestServer(`${GET_CITY_ACTIVITY_REPORT}?${params}`);
|
||||
const result = response.data.data;
|
||||
console.log(result);
|
||||
const nationalReportForItem = result.activities.find((report) => report.province_id === -1);
|
||||
const nationalReport = {
|
||||
edare_name: "کل کشور",
|
||||
...nationalReportForItem,
|
||||
};
|
||||
try {
|
||||
params.set("province_id", `${data.province_id}`);
|
||||
const response = await requestServer(`${GET_CITY_ACTIVITY_REPORT}?${params}`);
|
||||
const result = response.data.data;
|
||||
console.log(result);
|
||||
const nationalReportForItem = result.activities.find((report) => report.province_id === -1);
|
||||
const nationalReport = {
|
||||
edare_name: "کل کشور",
|
||||
...nationalReportForItem,
|
||||
};
|
||||
|
||||
setData({
|
||||
data: [
|
||||
nationalReport,
|
||||
...result.provinces.map((province) => {
|
||||
const filteredReports = result.activities.find(
|
||||
(report) => report.province_id === province.id
|
||||
);
|
||||
return {
|
||||
...filteredReports,
|
||||
edare_name: province.name_fa,
|
||||
};
|
||||
}),
|
||||
],
|
||||
filters: data,
|
||||
});
|
||||
} catch (e) {}
|
||||
setData({
|
||||
data: [
|
||||
nationalReport,
|
||||
...result.provinces.map((province) => {
|
||||
const filteredReports = result.activities.find((report) => report.province_id === province.id);
|
||||
return {
|
||||
...filteredReports,
|
||||
edare_name: province.name_fa,
|
||||
};
|
||||
}),
|
||||
],
|
||||
filters: data,
|
||||
});
|
||||
} catch (e) {}
|
||||
// } else {
|
||||
// try {
|
||||
// params.set("province_id", `${data.province_id}`);
|
||||
|
||||
@@ -1,29 +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;
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user