From e804f259b7ebd1dae1e5d792162175a2833dc7a5 Mon Sep 17 00:00:00 2001 From: Rafi Arrafif Date: Thu, 28 Aug 2025 23:26:33 +0700 Subject: [PATCH] :construction: (wip) forward callback to backend --- .../oauth-callback/lib/sendCallbackToServer.ts | 16 ++++++++++++++++ features/oauth-callback/ui/LoadingProcess.tsx | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 features/oauth-callback/lib/sendCallbackToServer.ts diff --git a/features/oauth-callback/lib/sendCallbackToServer.ts b/features/oauth-callback/lib/sendCallbackToServer.ts new file mode 100644 index 0000000..1ab5780 --- /dev/null +++ b/features/oauth-callback/lib/sendCallbackToServer.ts @@ -0,0 +1,16 @@ +"use server"; +import { api } from "@/shared/api/connector"; + +export const SendCallbackToServer = async (data: Record) => { + try { + const response = await api.get("auth/google/callback", { + searchParams: { ...data }, + }); + + const result = await response.json(); + console.log(result); + } catch (error) { + console.error("Error sending callback to server:", error); + throw error; + } +}; diff --git a/features/oauth-callback/ui/LoadingProcess.tsx b/features/oauth-callback/ui/LoadingProcess.tsx index 381afc9..fe0748c 100644 --- a/features/oauth-callback/ui/LoadingProcess.tsx +++ b/features/oauth-callback/ui/LoadingProcess.tsx @@ -1,10 +1,25 @@ "use client"; import { CircularProgress } from "@heroui/react"; -import React from "react"; +import React, { useEffect } from "react"; import { ParamProps } from "../types/ParamProps"; +import { SendCallbackToServer } from "../lib/sendCallbackToServer"; const LoadingProcess = ({ callbackData }: { callbackData: ParamProps }) => { + useEffect(() => { + (async () => { + try { + const response = await SendCallbackToServer(callbackData); + console.log( + `Callback data sent to server successfully: ${JSON.stringify( + response + )}` + ); + } catch (error) { + console.error("Error during loading process:", error); + } + })(); + }, []); return (