("sessions")
+ .select("*")
+ .eq("status", "upcoming");
+
+ if (error || !data || data.length === 0) {
+ throw new Error("No sessions found in DB");
+ }
+ setUpcomingSessions(data);
+ } catch (err) {
+ console.warn("Sessions retrieval failed, utilizing premium mock sessions:", err);
+ setUpcomingSessions([
+ {
+ id: "s1",
+ title: "Advanced React Hooks & Patterns",
+ topic: "React",
+ description: "Deep dive into custom hooks, concurrency, and context performance optimization.",
+ mentor_name: "Dr. Sarah Jenkins",
+ scheduled_at: new Date(Date.now() + 2 * 3600000).toISOString(),
+ duration: 90,
+ status: "upcoming",
+ max_participants: 20,
+ joined_participants: 12
+ },
+ {
+ id: "s2",
+ title: "PostgreSQL Indexing & Optimization Tips",
+ topic: "Database",
+ description: "Learn how to speed up your backend by indexing columns, query planning, and scaling DB queries.",
+ mentor_name: "Alex Rivera",
+ scheduled_at: new Date(Date.now() + 26 * 3600000).toISOString(),
+ duration: 60,
+ status: "upcoming",
+ max_participants: 15,
+ joined_participants: 6
+ }
+ ]);
+ }
const { data, error } = await supabase
.from("sessions")
.select("*")
@@ -201,6 +273,25 @@ const Dashboard = () => {
// Leaderboard
useEffect(() => {
+ const fetchLeaderboard = async () => {
+ try {
+ const { data, error } = await supabase
+ .from("profiles")
+ .select("*")
+ .order("points", { ascending: false });
+
+ if (error || !data || data.length === 0) {
+ throw new Error("No profiles found for leaderboard");
+ }
+ setLeaderboard(data);
+ } catch (err) {
+ console.warn("Leaderboard retrieval failed, utilizing pre-seeded standings:", err);
+ setLeaderboard([
+ { id: "1", name: "Riya Petle", points: 1250 },
+ { id: "2", name: "Dr. Sarah Jenkins", points: 1100 },
+ { id: "3", name: "Alex Rivera", points: 980 },
+ { id: "00000000-0000-0000-0000-000000000000", name: "Demo Student (You)", points: 480 }
+ ]);
const fetchLeaderboardData = async () => {
// 1. Fetch top 5 for the mini-leaderboard
const { data } = await supabase
@@ -395,6 +486,11 @@ const Dashboard = () => {
+ {/* AI PERSONALIZED RECOMMENDATIONS */}
+
+
+
+
{/* MAIN */}
diff --git a/src/pages/Discover.tsx b/src/pages/Discover.tsx
index b994bcd..37f07c1 100644
--- a/src/pages/Discover.tsx
+++ b/src/pages/Discover.tsx
@@ -84,6 +84,10 @@ const Discover = () => {
setCurrentUser(current);
+ // ALL USERS
+ const { data: allUsers } = await supabase
+ .from("profiles")
+ .select("*");
// ALL USERS — capped at 100 and filtered server-side
let query = supabase
.from("profiles")
diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx
index ee6c6f7..244ee42 100644
--- a/src/pages/Login.tsx
+++ b/src/pages/Login.tsx
@@ -26,7 +26,7 @@ const Login = () => {
const [isLoading, setIsLoading] = useState(false);
const [errors, setErrors] = useState({});
- const { user, loading } = useAuth();
+ const { user, loading, signIn } = useAuth();
const { toast } = useToast();
const navigate = useNavigate();
@@ -50,10 +50,7 @@ const Login = () => {
setIsLoading(true);
- const { error } = await supabase.auth.signInWithPassword({
- email,
- password,
- });
+ const { error } = await signIn(email, password);
setIsLoading(false);
@@ -72,6 +69,27 @@ const Login = () => {
}
};
+ // ✅ Quick Demo login
+ const handleDemoLogin = async () => {
+ setIsLoading(true);
+ const { error } = await signIn("demo@peerlearn.com", "demo123");
+ setIsLoading(false);
+
+ if (error) {
+ toast({
+ title: "Demo login failed",
+ description: error.message,
+ variant: "destructive",
+ });
+ } else {
+ toast({
+ title: "Welcome to PeerLearn Demo! 🎉",
+ description: "Logged in as Demo Student. No confirmation email needed.",
+ });
+ navigate("/dashboard");
+ }
+ };
+
const handleGoogleLogin = async () => {
if (supabaseMisconfigured) {
toast({
@@ -295,6 +313,20 @@ const Login = () => {
+ {/* DEMO LOGIN BUTTON */}
+
+
+ ✨ Quick Demo Login
+
+
+
{/* GOOGLE */}