"use client";

import { useEffect } from "react";
import { redirectToAuth } from "supertokens-auth-react";
import { ThirdPartyEmailPasswordPreBuiltUI } from "supertokens-auth-react/recipe/thirdpartyemailpassword/prebuiltui";
import { canHandleRoute, getRoutingComponent } from "supertokens-auth-react/ui";

export default function SuperTokensAuthComponent() {
  useEffect(() => {
    if (!canHandleRoute([ThirdPartyEmailPasswordPreBuiltUI])) {
      redirectToAuth();
    }
  }, []);

  if (canHandleRoute([ThirdPartyEmailPasswordPreBuiltUI])) {
    return getRoutingComponent([ThirdPartyEmailPasswordPreBuiltUI]);
  }

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