diff --git a/features/oauth-callback/ui/LoadingProcess.tsx b/features/oauth-callback/ui/LoadingProcess.tsx index 3ef51ad..bc70b56 100644 --- a/features/oauth-callback/ui/LoadingProcess.tsx +++ b/features/oauth-callback/ui/LoadingProcess.tsx @@ -1,29 +1,25 @@ "use client"; +import React from "react"; import { CircularProgress } from "@heroui/react"; -import React, { useEffect, useRef } from "react"; import { SendCallbackToServer } from "../lib/sendCallbackToServer"; import { useParams } from "next/navigation"; +import { useRunOnce } from "@/shared/hooks/useRunOnce"; const LoadingProcess = () => { const params = useParams(); - const calledRef = useRef(false); - useEffect(() => { - if (calledRef.current) return; - calledRef.current = true; - (async () => { - try { - await SendCallbackToServer( - window.location.search, - params.provider as string - ); - window.close(); - } catch (error) { - console.log(error); - } - })(); - }, []); + useRunOnce("forwardCallbackResponseToBackend", async () => { + try { + await SendCallbackToServer( + window.location.search, + params.provider as string + ); + window.close(); + } catch (error) { + console.log(error); + } + }); return (