Last active
March 7, 2023 08:54
-
-
Save florianwalther-private/dad2e063a3fd09872c2188c495cf7354 to your computer and use it in GitHub Desktop.
AuthModals component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type AuthModalState = "none" | "login" | "signup" | "resetpassword"; | |
interface AuthModalProps { | |
state: AuthModalState | |
setState: (state: AuthModalState) => void, | |
} | |
function AuthModals({ state, setState }: AuthModalProps) { | |
if (state === "signup") { | |
return ( | |
<SignUpModal | |
onDismiss={() => setState("none")} | |
onLoginInsteadClicked={() => setState("login")} | |
/> | |
); | |
} | |
if (state === "login") { | |
return ( | |
<LoginModal | |
onDismiss={() => setState("none")} | |
onSignUpInsteadClicked={() => setState("signup")} | |
onForgotPasswordClicked={() => setState("resetpassword")} /> | |
); | |
} | |
if (state === "resetpassword") { | |
<ResetPasswordModal | |
onDismiss={() => setState("none")} | |
onSignUpClicked={() => setState("signup")} | |
/> | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment