diff --git a/frontend/src/components/AuthModal.tsx b/frontend/src/components/AuthModal.tsx index bcdb42d..cf68d95 100644 --- a/frontend/src/components/AuthModal.tsx +++ b/frontend/src/components/AuthModal.tsx @@ -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 = ({ @@ -16,14 +16,14 @@ const AuthModal: React.FC = ({ 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 = ({ // 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]); diff --git a/frontend/src/contexts/AuthContext.tsx b/frontend/src/contexts/AuthContext.tsx index 87f0356..21d1367 100644 --- a/frontend/src/contexts/AuthContext.tsx +++ b/frontend/src/contexts/AuthContext.tsx @@ -27,8 +27,8 @@ interface AuthContextType { updateUser: (user: User) => void; checkAuth: () => Promise; showAuthModal: boolean; - authModalMode: "login" | "signup"; - openAuthModal: (mode: "login" | "signup") => void; + authModalMode: "login" | "signup" | "forgot-password"; + openAuthModal: (mode: "login" | "signup" | "forgot-password") => void; closeAuthModal: () => void; } @@ -50,7 +50,7 @@ export const AuthProvider: React.FC = ({ children }) => { const [user, setUser] = useState(null); const [loading, setLoading] = useState(true); const [showAuthModal, setShowAuthModal] = useState(false); - const [authModalMode, setAuthModalMode] = useState<"login" | "signup">("login"); + const [authModalMode, setAuthModalMode] = useState<"login" | "signup" | "forgot-password">("login"); const isAuthenticating = useRef(false); const checkAuth = async () => { @@ -144,7 +144,7 @@ export const AuthProvider: React.FC = ({ children }) => { setUser(user); }; - const openAuthModal = (mode: "login" | "signup") => { + const openAuthModal = (mode: "login" | "signup" | "forgot-password") => { setAuthModalMode(mode); setShowAuthModal(true); }; diff --git a/frontend/src/pages/ResetPassword.tsx b/frontend/src/pages/ResetPassword.tsx index 459c5aa..ab04a1f 100644 --- a/frontend/src/pages/ResetPassword.tsx +++ b/frontend/src/pages/ResetPassword.tsx @@ -140,6 +140,15 @@ const ResetPassword: React.FC = () => {
Invalid Reset Link

{error}

+ Return to Home