import { useEffect, useState } from "react"; import { CredentialSignInForm, type AtpSignIn, } from "./credential/credential-sign-in-form"; import { OAuthSignInForm, type OAuthSignIn } from "./oauth-login"; export function AuthForm({ atpSignIn, oauthSignIn, }: { atpSignIn?: AtpSignIn; oauthSignIn?: OAuthSignIn; }) { const defaultMethod = oauthSignIn ? "oauth" : atpSignIn ? "credential" : undefined; const [method, setMethod] = useState( defaultMethod ); useEffect(() => { if (method === "oauth" && !oauthSignIn) { setMethod(defaultMethod); } else if (method === "credential" && !atpSignIn) { setMethod(defaultMethod); } else if (!method) { setMethod(defaultMethod); } }, [atpSignIn, oauthSignIn, defaultMethod, method]); // Tailwind css tabs return (
{method === "oauth" && } {method === "credential" && } {method == null &&
No auth method available
}
); }