👔 create callback forwader

create a handler to forward callback requests from the OAuth provider to the main backend system.
This commit is contained in:
2025-08-31 22:02:31 +07:00
parent e804f259b7
commit 2bcd2a4ead
6 changed files with 24 additions and 31 deletions

View File

@ -1,22 +1,21 @@
"use client";
import { CircularProgress } from "@heroui/react";
import React, { useEffect } from "react";
import { ParamProps } from "../types/ParamProps";
import React, { useEffect, useRef } from "react";
import { SendCallbackToServer } from "../lib/sendCallbackToServer";
const LoadingProcess = ({ callbackData }: { callbackData: ParamProps }) => {
const LoadingProcess = () => {
const calledRef = useRef(false);
useEffect(() => {
if (calledRef.current) return;
calledRef.current = true;
(async () => {
try {
const response = await SendCallbackToServer(callbackData);
console.log(
`Callback data sent to server successfully: ${JSON.stringify(
response
)}`
);
await SendCallbackToServer(window.location.search);
window.close();
} catch (error) {
console.error("Error during loading process:", error);
console.log(error);
}
})();
}, []);
@ -28,9 +27,6 @@ const LoadingProcess = ({ callbackData }: { callbackData: ParamProps }) => {
<p className="text-sm text-neutral-400">
Your request is being processed
</p>
<p className="text-sm text-neutral-400">
{JSON.stringify(callbackData)}
</p>
</div>
</div>
);