From 2fe007a831faa7b3caf741f814a2b3018fec77e6 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sun, 19 Oct 2025 00:51:09 +0000 Subject: [PATCH] Make mentorship pages public-browse and avoid forced login redirects cgen-f1271c7d29be4686ad3842b876581af9 --- client/pages/community/MentorshipRequest.tsx | 24 +++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/client/pages/community/MentorshipRequest.tsx b/client/pages/community/MentorshipRequest.tsx index 4e3d50a7..b6a6c506 100644 --- a/client/pages/community/MentorshipRequest.tsx +++ b/client/pages/community/MentorshipRequest.tsx @@ -22,7 +22,7 @@ import { DialogHeader, DialogTitle, } from "@/components/ui/dialog"; -import { useNavigate } from "react-router-dom"; +import { useLocation, useNavigate } from "react-router-dom"; interface MentorRow { user_id: string; @@ -40,8 +40,9 @@ interface MentorRow { } export default function MentorshipRequest() { - const { user, loading } = useAuth(); + const { user } = useAuth(); const navigate = useNavigate(); + const location = useLocation(); const [mentors, setMentors] = useState([]); const [query, setQuery] = useState(""); const [expertiseInput, setExpertiseInput] = useState(""); @@ -53,15 +54,7 @@ export default function MentorshipRequest() { const [message, setMessage] = useState(""); const [submitting, setSubmitting] = useState(false); - useEffect(() => { - if (!loading && !user) { - aethexToast.info({ - title: "Sign in required", - description: "Please sign in to request mentorship", - }); - navigate("/login"); - } - }, [user, loading, navigate]); + // Allow public browsing; only require sign-in when sending a request const loadMentors = async () => { setLoadingMentors(true); @@ -106,6 +99,15 @@ export default function MentorshipRequest() { }; const onOpenRequest = (m: MentorRow) => { + if (!user) { + aethexToast.info({ + title: "Sign in required", + description: "Sign in to send a mentorship request.", + }); + const next = encodeURIComponent(location.pathname + location.search); + navigate(`/login?next=${next}`); + return; + } setSelectedMentor(m); setMessage(""); setDialogOpen(true);