better UX when resetting pw

This commit is contained in:
jackiettran
2025-12-29 00:38:10 -05:00
parent e153614993
commit ac1e22f194
3 changed files with 23 additions and 8 deletions

View File

@@ -8,7 +8,7 @@ import VerificationCodeModal from "./VerificationCodeModal";
interface AuthModalProps {
show: boolean;
onHide: () => void;
initialMode?: "login" | "signup";
initialMode?: "login" | "signup" | "forgot-password";
}
const AuthModal: React.FC<AuthModalProps> = ({
@@ -16,14 +16,14 @@ const AuthModal: React.FC<AuthModalProps> = ({
onHide,
initialMode = "login",
}) => {
const [mode, setMode] = useState<"login" | "signup">(initialMode);
const [mode, setMode] = useState<"login" | "signup">(initialMode === "forgot-password" ? "login" : initialMode);
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [firstName, setFirstName] = useState("");
const [lastName, setLastName] = useState("");
const [loading, setLoading] = useState(false);
const [error, setError] = useState("");
const [showForgotPassword, setShowForgotPassword] = useState(false);
const [showForgotPassword, setShowForgotPassword] = useState(initialMode === "forgot-password");
const [showVerificationModal, setShowVerificationModal] = useState(false);
const { login, register } = useAuth();
@@ -32,7 +32,13 @@ const AuthModal: React.FC<AuthModalProps> = ({
// Update mode when modal is opened with different initialMode
useEffect(() => {
if (show && initialMode) {
setMode(initialMode);
if (initialMode === "forgot-password") {
setShowForgotPassword(true);
setMode("login"); // Default to login when returning from forgot password
} else {
setMode(initialMode);
setShowForgotPassword(false);
}
}
}, [show, initialMode]);