Make mentorship pages public-browse and avoid forced login redirects
cgen-f1271c7d29be4686ad3842b876581af9
This commit is contained in:
parent
f0fd25e8f9
commit
2fe007a831
1 changed files with 13 additions and 11 deletions
|
|
@ -22,7 +22,7 @@ import {
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from "@/components/ui/dialog";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useLocation, useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
interface MentorRow {
|
interface MentorRow {
|
||||||
user_id: string;
|
user_id: string;
|
||||||
|
|
@ -40,8 +40,9 @@ interface MentorRow {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function MentorshipRequest() {
|
export default function MentorshipRequest() {
|
||||||
const { user, loading } = useAuth();
|
const { user } = useAuth();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const location = useLocation();
|
||||||
const [mentors, setMentors] = useState<MentorRow[]>([]);
|
const [mentors, setMentors] = useState<MentorRow[]>([]);
|
||||||
const [query, setQuery] = useState("");
|
const [query, setQuery] = useState("");
|
||||||
const [expertiseInput, setExpertiseInput] = useState("");
|
const [expertiseInput, setExpertiseInput] = useState("");
|
||||||
|
|
@ -53,15 +54,7 @@ export default function MentorshipRequest() {
|
||||||
const [message, setMessage] = useState("");
|
const [message, setMessage] = useState("");
|
||||||
const [submitting, setSubmitting] = useState(false);
|
const [submitting, setSubmitting] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
// Allow public browsing; only require sign-in when sending a request
|
||||||
if (!loading && !user) {
|
|
||||||
aethexToast.info({
|
|
||||||
title: "Sign in required",
|
|
||||||
description: "Please sign in to request mentorship",
|
|
||||||
});
|
|
||||||
navigate("/login");
|
|
||||||
}
|
|
||||||
}, [user, loading, navigate]);
|
|
||||||
|
|
||||||
const loadMentors = async () => {
|
const loadMentors = async () => {
|
||||||
setLoadingMentors(true);
|
setLoadingMentors(true);
|
||||||
|
|
@ -106,6 +99,15 @@ export default function MentorshipRequest() {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onOpenRequest = (m: MentorRow) => {
|
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);
|
setSelectedMentor(m);
|
||||||
setMessage("");
|
setMessage("");
|
||||||
setDialogOpen(true);
|
setDialogOpen(true);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue