"use client"; import React, { useRef, useState } from "react"; import { getLocations } from "@/utils/CitizenReport"; import { useQuery } from "@tanstack/react-query"; import { ThreeDots } from "react-loader-spinner"; import ReactMapboxGl, { Marker, ZoomControl } from "react-mapbox-gl"; import marker from "@/assets/images/location.svg"; import RequestCard from "../Requests/RequestCard"; import { cn } from "@/lib/utils"; const accessToken = process.env.REACT_APP_ACCESS_TOKEN || ""; const MapContainer = ReactMapboxGl({ accessToken: accessToken, minZoom: 8, maxZoom: 15, // zoom: 9, }); const OnMapRequests = () => { const [selected, setSelected] = useState(null); // refs const detailsRef = useRef(null); const wrappersRef = useRef(null); const defaultCoords = { // latitude: instances[0].latitude, // longitude: instances[0].longitude, }; // hooks // const [detailsClicked, setDetailsClicked] = useClick({ // element: detailsRef, // // whitelists, // }); // functions // const showDetails = (request) => { // setSelected(request); // setDetailsClicked(true); // }; const showDetails = () => { // setSelected(request); // setDetailsClicked(true); }; // const onMapClicked = (e, x) => { // setSelected(null); // }; const { data: LocationData, isLoading, isError, isSuccess, refetch, } = useQuery({ queryKey: ["Locations"], queryFn: () => getLocations(), // refetchOnWindowFocus: false, }); if (isSuccess) { console.log(LocationData?.locations[0].locations); const fetchedContent = LocationData?.locations[0].locations; console.log(fetchedContent); } if (isError) { console.log("have a errorrrrrrr "); } return ( <> {isLoading ? (
) : ( {/* {LocationData?.map((d) => ( showDetails(d)} /> ))} */} {LocationData?.map(() => ( showDetails()} /> ))}
{/* {selected && } */}
// )} {isError &&

Map Failed

} ); }; export default OnMapRequests;