forked from BLC/sgeUpdated
Comment not needed orgnization code
This commit is contained in:
@@ -32,10 +32,10 @@ import { getCities } from "../redux/actions/cities";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { getCity } from "../redux/actions/city";
|
||||
import { getDistrict } from "../redux/actions/district";
|
||||
import {
|
||||
getOrganisations,
|
||||
getOrganisationById,
|
||||
} from "../redux/actions/organisations";
|
||||
// import {
|
||||
// getOrganisations,
|
||||
// getOrganisationById,
|
||||
// } from "../redux/actions/organisations";
|
||||
import { getAreasWithCriteria } from "../redux/actions/areas";
|
||||
import { ChromePicker } from "react-color";
|
||||
import { customFilterForSelect } from "../utility/Utils";
|
||||
@@ -117,20 +117,20 @@ const Map = () => {
|
||||
const citiesStore = useSelector((state) => state.cities);
|
||||
const cityStore = useSelector((state) => state.city);
|
||||
const districtStore = useSelector((state) => state.district);
|
||||
const OrganisationsStore = useSelector((state) => state.organizations);
|
||||
// const OrganisationsStore = useSelector((state) => state.organizations);
|
||||
const areasStore = useSelector((state) => state.areas);
|
||||
const dataCenterStore = useSelector((state) => state.dataCenter);
|
||||
|
||||
const [cities, setCities] = useState([]);
|
||||
const [districts, setDistricts] = useState([]);
|
||||
const [neighborhoods, setNeighborhoods] = useState([]);
|
||||
const [organizationOptions, setOrganizationOptions] = useState([]);
|
||||
const organizationId = localStorage.getItem("organizationId");
|
||||
const roleTag = localStorage.getItem("roleTag");
|
||||
const [selectedOrganization, setSelectedOrganization] = useState({
|
||||
label: localStorage.getItem("organizationName"),
|
||||
value: organizationId,
|
||||
});
|
||||
// const [organizationOptions, setOrganizationOptions] = useState([]);
|
||||
// const organizationId = localStorage.getItem("organizationId");
|
||||
// const roleTag = localStorage.getItem("roleTag");
|
||||
// const [selectedOrganization, setSelectedOrganization] = useState({
|
||||
// label: localStorage.getItem("organizationName"),
|
||||
// value: organizationId,
|
||||
// });
|
||||
const [areasOptions, setAreasOptions] = useState([]);
|
||||
|
||||
const [done, setDone] = useState(false);
|
||||
@@ -146,7 +146,7 @@ const Map = () => {
|
||||
|
||||
const [showDataInputModal, setShowDataInputModal] = useState(false);
|
||||
const [inputData, setInputData] = useState({
|
||||
organization: selectedOrganization,
|
||||
// organization: selectedOrganization,
|
||||
});
|
||||
const [referance, setReferance] = useState(
|
||||
Number(localStorage.getItem("referance")) || 1000
|
||||
@@ -176,15 +176,17 @@ const Map = () => {
|
||||
dispatch(getDataCenters());
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedOrganization?.value != "undefined") {
|
||||
dispatch(getAreasWithCriteria(selectedOrganization.value));
|
||||
}
|
||||
}, [selectedOrganization]);
|
||||
// useEffect(() => {
|
||||
// if (selectedOrganization?.value != "undefined") {
|
||||
// dispatch(getAreasWithCriteria(selectedOrganization.value));
|
||||
// }
|
||||
// }, [selectedOrganization]);
|
||||
|
||||
useEffect(() => {
|
||||
setAreasOptions([]);
|
||||
|
||||
// Load all areas without organization filter for now
|
||||
// You may want to add organization filtering back later if needed
|
||||
const citiesOptions =
|
||||
areasStore?.areasWithCriteria
|
||||
?.map((area) =>
|
||||
@@ -235,13 +237,13 @@ const Map = () => {
|
||||
]);
|
||||
}, [areasStore]);
|
||||
|
||||
useEffect(() => {
|
||||
if (roleTag === "SUPER_ADMIN") {
|
||||
dispatch(getOrganisations());
|
||||
} else {
|
||||
dispatch(getOrganisationById(organizationId));
|
||||
}
|
||||
}, []);
|
||||
// useEffect(() => {
|
||||
// if (roleTag === "SUPER_ADMIN") {
|
||||
// dispatch(getOrganisations());
|
||||
// } else {
|
||||
// dispatch(getOrganisationById(organizationId));
|
||||
// }
|
||||
// }, []);
|
||||
|
||||
const handleDataInputButtonPressed = ({ area, type }) => {
|
||||
const areaName =
|
||||
@@ -348,38 +350,38 @@ const Map = () => {
|
||||
});
|
||||
}, [selectedDistrict, districtStore?.district, year.value]);
|
||||
|
||||
useEffect(() => {
|
||||
let organizationOptions = [];
|
||||
// useEffect(() => {
|
||||
// let organizationOptions = [];
|
||||
|
||||
if (
|
||||
OrganisationsStore.organization &&
|
||||
OrganisationsStore.organization.length !== 0
|
||||
) {
|
||||
organizationOptions.push({
|
||||
value: OrganisationsStore.organization.id,
|
||||
label: OrganisationsStore.organization.tag,
|
||||
});
|
||||
// if (
|
||||
// OrganisationsStore.organization &&
|
||||
// OrganisationsStore.organization.length !== 0
|
||||
// ) {
|
||||
// organizationOptions.push({
|
||||
// value: OrganisationsStore.organization.id,
|
||||
// label: OrganisationsStore.organization.tag,
|
||||
// });
|
||||
|
||||
if (OrganisationsStore.organization.children) {
|
||||
organizationOptions = [
|
||||
...organizationOptions,
|
||||
...OrganisationsStore.organization.children.map((organization) => ({
|
||||
value: organization.child.id,
|
||||
label: organization.child.tag,
|
||||
})),
|
||||
];
|
||||
}
|
||||
} else {
|
||||
organizationOptions = OrganisationsStore.dataOrganization.map(
|
||||
(organization) => ({
|
||||
value: organization.id,
|
||||
label: organization.tag,
|
||||
})
|
||||
);
|
||||
}
|
||||
// if (OrganisationsStore.organization.children) {
|
||||
// organizationOptions = [
|
||||
// ...organizationOptions,
|
||||
// ...OrganisationsStore.organization.children.map((organization) => ({
|
||||
// value: organization.child.id,
|
||||
// label: organization.child.tag,
|
||||
// })),
|
||||
// ];
|
||||
// }
|
||||
// } else {
|
||||
// organizationOptions = OrganisationsStore.dataOrganization.map(
|
||||
// (organization) => ({
|
||||
// value: organization.id,
|
||||
// label: organization.tag,
|
||||
// })
|
||||
// );
|
||||
// }
|
||||
|
||||
setOrganizationOptions(organizationOptions);
|
||||
}, [OrganisationsStore]);
|
||||
// setOrganizationOptions(organizationOptions);
|
||||
// }, [OrganisationsStore]);
|
||||
|
||||
const renderDataInputModal = () => {
|
||||
return (
|
||||
@@ -625,27 +627,38 @@ const Map = () => {
|
||||
if (!dc.latitude || !dc.longitude) return null;
|
||||
|
||||
return (
|
||||
<Marker
|
||||
key={dc.id}
|
||||
position={[dc.latitude, dc.longitude]}
|
||||
>
|
||||
<Marker key={dc.id} position={[dc.latitude, dc.longitude]}>
|
||||
<Popup>
|
||||
<div className="data-center-popup">
|
||||
<h5 className="mb-2">{dc.dataCenter}</h5>
|
||||
<p className="mb-1"><strong>{t('DataCenter.number')}:</strong> {dc.number}</p>
|
||||
<p className="mb-1"><strong>{t('DataCenter.externalId')}:</strong> {dc.externalId}</p>
|
||||
<p className="mb-1"><strong>{t('DataCenter.city')}:</strong> {dc.area?.cities?.map(city => city.name).join(', ') || "-"}</p>
|
||||
{dc.area && <p className="mb-1"><strong>{t('Area')}:</strong> {dc.area.tag}</p>}
|
||||
{dc.projects?.length > 0 && (
|
||||
<p className="mb-1">
|
||||
<strong>{t('Projects')}:</strong> {dc.projects.length}
|
||||
<strong>{t("DataCenter.number")}:</strong> {dc.number}
|
||||
</p>
|
||||
<p className="mb-1">
|
||||
<strong>{t("DataCenter.externalId")}:</strong>{" "}
|
||||
{dc.externalId}
|
||||
</p>
|
||||
<p className="mb-1">
|
||||
<strong>{t("DataCenter.city")}:</strong>{" "}
|
||||
{dc.area?.cities?.map((city) => city.name).join(", ") ||
|
||||
"-"}
|
||||
</p>
|
||||
{dc.area && (
|
||||
<p className="mb-1">
|
||||
<strong>{t("Area")}:</strong> {dc.area.tag}
|
||||
</p>
|
||||
)}
|
||||
{dc.dataCenterEmissionSources?.length > 0 && (
|
||||
<p className="mb-1">
|
||||
<strong>{t("EmissionSources")}:</strong>{" "}
|
||||
{dc.dataCenterEmissionSources.length}
|
||||
</p>
|
||||
)}
|
||||
{dc.ayposURL && (
|
||||
<Button
|
||||
className="w-100 mb-1"
|
||||
color="primary"
|
||||
onClick={() => window.open(dc.ayposURL, '_blank')}
|
||||
onClick={() => window.open(dc.ayposURL, "_blank")}
|
||||
>
|
||||
Dashboard
|
||||
</Button>
|
||||
@@ -699,7 +712,9 @@ const Map = () => {
|
||||
setDistrictView(true);
|
||||
setZoom(8.0);
|
||||
|
||||
let convertCordinates = convertCoordinates(city.coordinates);
|
||||
let convertCordinates = convertCoordinates(
|
||||
city.coordinates
|
||||
);
|
||||
let length = convertCordinates[0][0][0].length;
|
||||
let mlength = ((length + 1) / 2).toFixed(0);
|
||||
let lat1 = convertCordinates[0][0][0][0];
|
||||
@@ -710,7 +725,7 @@ const Map = () => {
|
||||
lat: ((lat1 + lat2) / 2).toFixed(2),
|
||||
lng: ((lng1 + lng2) / 2).toFixed(2),
|
||||
});
|
||||
}
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Tooltip permanent direction="center">
|
||||
|
||||
Reference in New Issue
Block a user