👔 create callback forwader
create a handler to forward callback requests from the OAuth provider to the main backend system.
This commit is contained in:
@ -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>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user