shahrbin-citizen/components/RecentRequest/OnMapRequests.tsx

52 lines
1.2 KiB
TypeScript

"use client";
import React, { useState } from "react";
import { getLocation } from "@/utils/CitizenReport";
import { useQuery } from "@tanstack/react-query";
import { ThreeDots } from "react-loader-spinner";
const OnMapRequests = () => {
const {
data: LocationData,
isLoading,
isError,
isSuccess,
refetch,
} = useQuery({
queryKey: ["Location"],
queryFn: () => getLocation(),
refetchOnWindowFocus: false,
});
if (isSuccess) {
console.log(LocationData?.locations[0].locations);
const fetchedContent = LocationData?.locations[0].locations;
console.log(fetchedContent);
}
return (
<>
{isLoading ? (
<div className="flex justify-center text-center w-36">
<ThreeDots
visible={true}
height="50"
width="50"
color="#003778"
radius="9"
ariaLabel="three-dots-loading"
wrapperStyle={{}}
wrapperClass=""
/>
</div>
) : (
<div className="flex justify-center items-center gap-2 text-center ">
<p>Map On</p>
</div>
)}
{isError && <p>Map Failed</p>}
</>
);
};
export default OnMapRequests;