Skip to content

Instantly share code, notes, and snippets.

@florianwalther-private
Last active March 7, 2023 08:54
Show Gist options
  • Save florianwalther-private/dad2e063a3fd09872c2188c495cf7354 to your computer and use it in GitHub Desktop.
Save florianwalther-private/dad2e063a3fd09872c2188c495cf7354 to your computer and use it in GitHub Desktop.
AuthModals component
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