(props: {
view: "sign_in" | "sign_up" | "update_password";
})
| 8 | } |
| 9 | |
| 10 | export default function SignInComponent(props: { |
| 11 | view: "sign_in" | "sign_up" | "update_password"; |
| 12 | }) { |
| 13 | const supabase = useSupabaseClient(); |
| 14 | const [redirectUrl, setRedirectUrl] = React.useState<string | null>(null); |
| 15 | const [view, setView] = React.useState< |
| 16 | "sign_in" | "sign_up" | "update_password" |
| 17 | >(props.view); |
| 18 | |
| 19 | useEffect(() => { |
| 20 | const url = getRedirectUrl(); |
| 21 | setRedirectUrl(url); |
| 22 | supabase.auth.onAuthStateChange((event, session) => { |
| 23 | if (event === "PASSWORD_RECOVERY") { |
| 24 | setView("update_password"); |
| 25 | } |
| 26 | }); |
| 27 | }, []); |
| 28 | |
| 29 | return ( |
| 30 | <> |
| 31 | <div className="relative flex min-h-screen bg-gray-850 flex-col justify-center py-20 sm:px-6 lg:px-8"> |
| 32 | <a |
| 33 | href={"/"} |
| 34 | className="absolute top-5 left-5 text-center sm:text-lg lg:text-xl text-white" |
| 35 | > |
| 36 | Superflows |
| 37 | </a> |
| 38 | <div className="sm:mx-auto sm:w-full sm:max-w-md flex flex-col place-items-center"> |
| 39 | <div className="w-full rounded-md px-10 py-6 bg-gray-800 border border-gray-400 shadow shadow-gray-200"> |
| 40 | <h2 className="mb-1 text-center text-3xl tracking-tight text-gray-50"> |
| 41 | {view === "sign_up" |
| 42 | ? "Get Started" |
| 43 | : view === "update_password" |
| 44 | ? "Update your password" |
| 45 | : "Welcome Back"} |
| 46 | </h2> |
| 47 | <p className={"w-full text-center text-sm mb-6 text-gray-500"}> |
| 48 | {view === "sign_up" |
| 49 | ? "Create a free account" |
| 50 | : view === "update_password" |
| 51 | ? "Enter your new password below" |
| 52 | : "Sign in"} |
| 53 | </p> |
| 54 | <Auth |
| 55 | supabaseClient={supabase} |
| 56 | providers={["google", "github"]} |
| 57 | view={view} |
| 58 | redirectTo={redirectUrl ?? ""} |
| 59 | appearance={{ |
| 60 | theme: ThemeSupa, |
| 61 | variables: { |
| 62 | default: { |
| 63 | colors: { |
| 64 | brand: "#a855f7", |
| 65 | brandAccent: "#9333ea", |
| 66 | }, |
| 67 | }, |
nothing calls this directly
no test coverage detected