import React, { useEffect, useContext } from "react";
import { UserManager } from "oidc-client-ts";
import {ConfigContext} from "../../ConfigProvider";


const PopupCallback = () => {
    const { config } = useContext(ConfigContext);

    useEffect(() => {
        const userManager = new UserManager(config.OIDC_CONFIG);
        userManager.signinPopupCallback()
            .then(() => {
                window.close();
            })
            .catch((err) => {
                console.error("Popup callback error:", err);
                window.close();
            });
    }, [config]);

    return <div>Processing...</div>;
};

export default PopupCallback;