diff --git a/components/RecentRequest/OnMapRequests.tsx b/components/RecentRequest/OnMapRequests.tsx index 5efebf4..71cda95 100644 --- a/components/RecentRequest/OnMapRequests.tsx +++ b/components/RecentRequest/OnMapRequests.tsx @@ -1,9 +1,51 @@ -import React from 'react' +"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 = () => { - return ( -
OnMapRequests
- ) -} + const { + data: LocationData, + isLoading, + isError, + isSuccess, + refetch, + } = useQuery({ + queryKey: ["Location"], + queryFn: () => getLocation(), + refetchOnWindowFocus: false, + }); -export default OnMapRequests \ No newline at end of file + if (isSuccess) { + console.log(LocationData?.locations[0].locations); + const fetchedContent = LocationData?.locations[0].locations; + console.log(fetchedContent); + } + + return ( + <> + {isLoading ? ( +
+ +
+ ) : ( +
+

Map On

+
+ )} + {isError &&

Map Failed

} + + ); +}; + +export default OnMapRequests; diff --git a/components/RecentRequest/RecentRequests.tsx b/components/RecentRequest/RecentRequests.tsx index fb6d2e0..d872f56 100644 --- a/components/RecentRequest/RecentRequests.tsx +++ b/components/RecentRequest/RecentRequests.tsx @@ -1,14 +1,42 @@ -import React from "react"; +"use client"; +import React, { useEffect } from "react"; import OnMapRequests from "./OnMapRequests"; import AllRequests from "./AllRequests"; import NearestRequests from "./NearestRequests"; import { TabRequests } from "./TabRequests"; // import UserContainer from "../User/UserContainer"; +// import { useRouter } from "next/navigation"; +// import { useMutation } from "@tanstack/react-query"; +// import { revoke } from "@/utils/authenticateApi"; +// import { deleteCookie, getCookie } from "cookies-next"; function RecentRequests() { + // const router = useRouter(); + + // const revokeMutation = useMutation({ + // mutationFn: revoke, + // onSuccess: (res) => {}, + // onError: (err: any | string) => {}, + // }); + + // const logout = () => { + // revokeMutation.mutate({ + // refreshToken: getCookie("Shahrbin_Refresh_Token"), + // }); + // // saveToken(false); + // deleteCookie("Shahrbin_Refresh_Token"); + // deleteCookie("Shahrbin_Token"); + // router.push("/"); + // }; + + // useEffect(() => { + // if (!getCookie("Shahrbin_Token")) { + // logout(); + // } + // }, []); + return (
- {/* Right */}
@@ -26,7 +54,6 @@ function RecentRequests() {
*/} -
); diff --git a/utils/CitizenReport.ts b/utils/CitizenReport.ts index ae62f31..64fdf17 100644 --- a/utils/CitizenReport.ts +++ b/utils/CitizenReport.ts @@ -4,7 +4,7 @@ import { CookieValueTypes } from "cookies-next"; axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP; // axios.defaults.baseURL = "https://shahrbinapi.shetabdahi.ir/"; -// Get Captcha +// Get Location export async function getLocation() { const data = await axios.get(`/api/CitizenReport/Locations`, { });