feat: Implement LTI deep linking, live sessions, predictive analytics, and portfolios with associated UI and database migrations.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { lmsApi, Course, Module, Recommendation, UserGrade } from "@/lib/api";
|
||||
import { Sparkles, AlertTriangle, ArrowRight, CheckCircle2, XCircle, Circle } from "lucide-react";
|
||||
import { lmsApi, Course, Module, Recommendation, UserGrade, Meeting } from "@/lib/api";
|
||||
import { Sparkles, AlertTriangle, ArrowRight, CheckCircle2, XCircle, Circle, Video, ExternalLink } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { BookOpen, ChevronRight, PlayCircle, Calendar, Clock, Info, Lock } from "lucide-react";
|
||||
import { useAuth } from "@/context/AuthContext";
|
||||
@@ -19,6 +19,7 @@ export default function CourseOutlinePage({ params }: { params: { id: string } }
|
||||
const [isEnrolled, setIsEnrolled] = useState(false);
|
||||
const [lessonDependencies, setLessonDependencies] = useState<any[]>([]);
|
||||
const [instructors, setInstructors] = useState<any[]>([]);
|
||||
const [meetings, setMeetings] = useState<Meeting[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
@@ -58,6 +59,10 @@ export default function CourseOutlinePage({ params }: { params: { id: string } }
|
||||
.then(res => setRecommendations(res.recommendations))
|
||||
.catch(console.error)
|
||||
.finally(() => setLoadingAI(false));
|
||||
|
||||
lmsApi.getMeetings(params.id)
|
||||
.then(setMeetings)
|
||||
.catch(console.error);
|
||||
}, [params.id, user]);
|
||||
|
||||
const handleEnrollOrBuy = async () => {
|
||||
@@ -294,6 +299,47 @@ export default function CourseOutlinePage({ params }: { params: { id: string } }
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Live Sessions Section */}
|
||||
{meetings.length > 0 && (
|
||||
<div className="mb-20">
|
||||
<div className="flex items-center gap-3 mb-8">
|
||||
<div className="w-10 h-10 rounded-xl glass border-blue-500/20 bg-blue-500/10 flex items-center justify-center">
|
||||
<Video size={18} className="text-blue-400" />
|
||||
</div>
|
||||
<div>
|
||||
<h2 className="text-xl font-bold text-white tracking-tight">Sesiones en Vivo</h2>
|
||||
<p className="text-[10px] font-bold uppercase tracking-widest text-gray-500">Únete a las clases sincrónicas programadas</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-3">
|
||||
{meetings.map((m) => (
|
||||
<div key={m.id} className="glass-card border-white/5 hover:border-blue-500/30 transition-all p-5 flex items-center justify-between">
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="w-10 h-10 rounded-lg bg-blue-500/10 flex items-center justify-center text-blue-400">
|
||||
<Calendar size={18} />
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="font-bold text-sm">{m.title}</h3>
|
||||
<p className="text-[10px] text-gray-500 uppercase mt-1">
|
||||
{new Date(m.start_at).toLocaleString()} • {m.duration_minutes} min
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<a
|
||||
href={m.join_url}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="px-4 py-2 rounded-lg bg-blue-600 hover:bg-blue-700 text-white font-bold text-[10px] uppercase tracking-widest flex items-center gap-2 transition-all"
|
||||
>
|
||||
Unirse <ExternalLink size={12} />
|
||||
</a>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Announcements Section */}
|
||||
<div className="mb-16">
|
||||
<AnnouncementsList courseId={params.id} isInstructor={user?.role === 'instructor' || user?.role === 'admin'} />
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useParams } from "next/navigation";
|
||||
import { lmsApi, PublicProfile } from "@/lib/api";
|
||||
import {
|
||||
Award,
|
||||
BookOpen,
|
||||
Zap,
|
||||
ShieldCheck,
|
||||
Globe,
|
||||
Linkedin,
|
||||
Github,
|
||||
UserCircle
|
||||
} from "lucide-react";
|
||||
|
||||
export default function StudentPortfolioPage() {
|
||||
const { id } = useParams();
|
||||
const [profile, setProfile] = useState<PublicProfile | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const loadProfile = async () => {
|
||||
try {
|
||||
const data = await lmsApi.getPublicProfile(id as string);
|
||||
setProfile(data);
|
||||
} catch (err: any) {
|
||||
setError(err.message || "Failed to load profile");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
if (id) loadProfile();
|
||||
}, [id]);
|
||||
|
||||
if (loading) return <div className="min-h-screen flex items-center justify-center text-gray-400">Loading portfolio...</div>;
|
||||
if (error) return <div className="min-h-screen flex items-center justify-center text-red-400">{error}</div>;
|
||||
if (!profile) return null;
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-[#050505] text-white selection:bg-blue-500/30">
|
||||
{/* Hero Section / Profile Header */}
|
||||
<div className="relative h-64 bg-gradient-to-r from-blue-900/30 to-purple-900/30 border-b border-white/5">
|
||||
<div className="absolute inset-0 bg-[url('/grid.svg')] opacity-20" />
|
||||
<div className="max-w-5xl mx-auto px-6 h-full flex flex-col justify-end pb-8">
|
||||
<div className="flex items-end gap-6">
|
||||
<div className="relative group">
|
||||
<div className="absolute -inset-1 bg-gradient-to-r from-blue-600 to-purple-600 rounded-2xl blur opacity-30 group-hover:opacity-60 transition duration-1000"></div>
|
||||
<div className="relative w-32 h-32 rounded-2xl bg-black border-2 border-white/10 overflow-hidden shadow-2xl">
|
||||
{profile.avatar_url ? (
|
||||
<img src={profile.avatar_url} alt={profile.full_name} className="w-full h-full object-cover" />
|
||||
) : (
|
||||
<div className="w-full h-full flex items-center justify-center text-gray-600 bg-gray-900">
|
||||
<UserCircle size={64} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex-1 pb-2">
|
||||
<h1 className="text-4xl font-bold tracking-tight">{profile.full_name}</h1>
|
||||
<p className="text-gray-400 mt-1 flex items-center gap-2">
|
||||
<Zap className="text-yellow-400" size={16} />
|
||||
Level {profile.level} Apprentice • {profile.xp} XP
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex gap-2 pb-2">
|
||||
<button className="p-2 bg-white/5 hover:bg-white/10 border border-white/10 rounded-xl transition-all"><Linkedin size={20} /></button>
|
||||
<button className="p-2 bg-white/5 hover:bg-white/10 border border-white/10 rounded-xl transition-all"><Github size={20} /></button>
|
||||
<button className="p-2 bg-white/5 hover:bg-white/10 border border-white/10 rounded-xl transition-all"><Globe size={20} /></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="max-w-5xl mx-auto px-6 py-12 grid grid-cols-1 md:grid-cols-3 gap-12">
|
||||
{/* Left Column: Bio & Stats */}
|
||||
<div className="md:col-span-1 space-y-8">
|
||||
<section>
|
||||
<h2 className="text-sm font-bold text-gray-500 uppercase tracking-widest mb-4">About Me</h2>
|
||||
<p className="text-gray-300 leading-relaxed italic">
|
||||
{profile.bio || "No biography provided. This student is focused on mastering their craft."}
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section className="bg-white/5 border border-white/10 rounded-3xl p-6 space-y-6">
|
||||
<h2 className="text-sm font-bold text-gray-400 uppercase tracking-widest">Global Stats</h2>
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<div className="flex items-center gap-3 text-gray-400">
|
||||
<BookOpen size={18} className="text-blue-400" />
|
||||
<span>Courses Finished</span>
|
||||
</div>
|
||||
<span className="font-mono font-bold">{profile.completed_courses_count}</span>
|
||||
</div>
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<div className="flex items-center gap-3 text-gray-400">
|
||||
<Award size={18} className="text-purple-400" />
|
||||
<span>Badges Earned</span>
|
||||
</div>
|
||||
<span className="font-mono font-bold">{profile.badges.length}</span>
|
||||
</div>
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<div className="flex items-center gap-3 text-gray-400">
|
||||
<Zap size={18} className="text-yellow-400" />
|
||||
<span>Global Rank</span>
|
||||
</div>
|
||||
<span className="font-mono font-bold">Top 5%</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
{/* Right Column: Badges & Showcase */}
|
||||
<div className="md:col-span-2 space-y-12">
|
||||
<section>
|
||||
<div className="flex items-center justify-between mb-8">
|
||||
<h2 className="text-2xl font-bold flex items-center gap-3">
|
||||
<ShieldCheck className="text-blue-500" />
|
||||
Credentials & Badges
|
||||
</h2>
|
||||
<span className="text-xs text-gray-500 bg-white/5 px-3 py-1 rounded-full border border-white/10">VERIFIED BY OPENCCB</span>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
{profile.badges.map((badge: any) => (
|
||||
<div key={badge.id} className="relative group cursor-pointer bg-white/5 border border-white/10 rounded-2xl p-6 text-center hover:bg-white/10 transition-all">
|
||||
<div className="mx-auto w-16 h-16 mb-4 flex items-center justify-center bg-blue-500/10 rounded-2xl">
|
||||
<img src={badge.icon_url} alt={badge.name} className="w-10 h-10 object-contain drop-shadow-lg" onError={(e) => {
|
||||
const target = e.target as any;
|
||||
target.src = "https://cdn-icons-png.flaticon.com/512/10636/10636665.png";
|
||||
}} />
|
||||
</div>
|
||||
<h3 className="font-bold text-sm mb-1">{badge.name}</h3>
|
||||
<p className="text-[10px] text-gray-500 uppercase tracking-tighter line-clamp-2 leading-tight">
|
||||
{badge.description}
|
||||
</p>
|
||||
<div className="absolute inset-0 border-2 border-blue-500/50 rounded-2xl opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none shadow-[0_0_20px_rgba(59,130,246,0.3)]"></div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{profile.badges.length === 0 && (
|
||||
<div className="text-center py-20 border-2 border-dashed border-white/5 rounded-3xl">
|
||||
<p className="text-gray-600">This student hasn't collected any badges yet.</p>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -51,6 +51,11 @@ export default function AppHeader() {
|
||||
<Link href="/bookmarks" className="text-[10px] font-black uppercase tracking-[0.2em] text-gray-400 hover:text-white transition-colors">
|
||||
{t('nav.bookmarks')}
|
||||
</Link>
|
||||
{user && (
|
||||
<Link href={`/profile/${user.id}`} className="text-[10px] font-black uppercase tracking-[0.2em] text-blue-400 hover:text-blue-300 transition-colors">
|
||||
MI PORTAFOLIO
|
||||
</Link>
|
||||
)}
|
||||
</nav>
|
||||
|
||||
<div className="flex items-center gap-2 md:gap-4">
|
||||
@@ -127,6 +132,15 @@ export default function AppHeader() {
|
||||
>
|
||||
{t('nav.bookmarks')}
|
||||
</Link>
|
||||
{user && (
|
||||
<Link
|
||||
href={`/profile/${user.id}`}
|
||||
onClick={() => setIsMenuOpen(false)}
|
||||
className="text-sm font-black uppercase tracking-widest text-blue-400 hover:text-blue-300 border-l-2 border-transparent hover:border-blue-500 pl-4 transition-all"
|
||||
>
|
||||
MI PORTAFOLIO
|
||||
</Link>
|
||||
)}
|
||||
|
||||
<div className="pt-6 mt-6 border-t border-white/5 space-y-4">
|
||||
<div className="flex items-center gap-3 px-4 py-2 rounded-xl bg-white/5">
|
||||
|
||||
@@ -232,6 +232,39 @@ export interface ProgressStats {
|
||||
estimated_completion_date?: string;
|
||||
}
|
||||
|
||||
export interface Meeting {
|
||||
id: string;
|
||||
course_id: string;
|
||||
title: string;
|
||||
description?: string;
|
||||
provider: string;
|
||||
meeting_id: string;
|
||||
start_at: string;
|
||||
duration_minutes: number;
|
||||
join_url?: string;
|
||||
is_active: boolean;
|
||||
}
|
||||
|
||||
export interface Badge {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
icon_url: string;
|
||||
criteria: any;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface PublicProfile {
|
||||
user_id: string;
|
||||
full_name: string;
|
||||
avatar_url?: string;
|
||||
bio?: string;
|
||||
level: number;
|
||||
xp: number;
|
||||
badges: Badge[];
|
||||
completed_courses_count: number;
|
||||
}
|
||||
|
||||
export interface AuthResponse {
|
||||
user: User;
|
||||
token: string;
|
||||
@@ -706,5 +739,18 @@ export const lmsApi = {
|
||||
async getBookmarks(courseId?: string): Promise<UserBookmark[]> {
|
||||
const query = courseId ? `?cohort_id=${courseId}` : '';
|
||||
return apiFetch(`/bookmarks${query}`);
|
||||
},
|
||||
|
||||
// Live Learning & Portfolio
|
||||
async getMeetings(courseId: string): Promise<Meeting[]> {
|
||||
return apiFetch(`/courses/${courseId}/meetings`, {}, false);
|
||||
},
|
||||
|
||||
async getPublicProfile(userId: string): Promise<PublicProfile> {
|
||||
return apiFetch(`/profile/${userId}`, {}, false);
|
||||
},
|
||||
|
||||
async getMyBadges(): Promise<Badge[]> {
|
||||
return apiFetch(`/my/badges`, {}, false);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user