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


const Callback = () => {
    const config = useContext(ConfigContext).config;
    useEffect(() => {
        const userManager = new UserManager(config.OIDC_CONFIG);
        userManager.signinRedirectCallback()
            .then(() => {
                window.location.href = "/";
            });
    }, []);

    return (
        <div className="flex min-h-screen items-center justify-center">
            <Spinner label="Logging in" />
        </div>
    );
};

export default Callback;