diff --git a/sge-frontend/src/views/Map.js b/sge-frontend/src/views/Map.js index c044980..2b7b4fd 100644 --- a/sge-frontend/src/views/Map.js +++ b/sge-frontend/src/views/Map.js @@ -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 ( @@ -623,29 +625,40 @@ const Map = () => { {dataCenterStore.dataCenters.map((dc) => { if (!dc.latitude || !dc.longitude) return null; - + return ( - +
{dc.dataCenter}
-

{t('DataCenter.number')}: {dc.number}

-

{t('DataCenter.externalId')}: {dc.externalId}

-

{t('DataCenter.city')}: {dc.area?.cities?.map(city => city.name).join(', ') || "-"}

- {dc.area &&

{t('Area')}: {dc.area.tag}

} - {dc.projects?.length > 0 && ( +

+ {t("DataCenter.number")}: {dc.number} +

+

+ {t("DataCenter.externalId")}:{" "} + {dc.externalId} +

+

+ {t("DataCenter.city")}:{" "} + {dc.area?.cities?.map((city) => city.name).join(", ") || + "-"} +

+ {dc.area && (

- {t('Projects')}: {dc.projects.length} + {t("Area")}: {dc.area.tag} +

+ )} + {dc.dataCenterEmissionSources?.length > 0 && ( +

+ {t("EmissionSources")}:{" "} + {dc.dataCenterEmissionSources.length}

)} {dc.ayposURL && ( @@ -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), }); - } + }, }} >