feat: update CMS service handlers and main application logic.
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { lmsApi } from "@/lib/api";
|
||||
import { useAuth } from "@/context/AuthContext";
|
||||
import { useRouter } from "next/navigation";
|
||||
import Link from "next/link";
|
||||
import { LogIn, Mail, Lock } from "lucide-react";
|
||||
|
||||
export default function LoginPage() {
|
||||
const [email, setEmail] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const [error, setError] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const { login } = useAuth();
|
||||
const router = useRouter();
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
setLoading(true);
|
||||
setError("");
|
||||
try {
|
||||
const res = await lmsApi.login({ email, password });
|
||||
login(res.user, res.token);
|
||||
router.push("/");
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : "Login failed. Please check your credentials.";
|
||||
setError(message);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-[calc(100vh-64px)] flex items-center justify-center p-6 bg-[#050505]">
|
||||
<div className="w-full max-w-md space-y-8 animate-in fade-in zoom-in duration-500">
|
||||
<div className="text-center space-y-2">
|
||||
<div className="w-16 h-16 rounded-2xl bg-blue-600/10 border border-blue-500/20 flex items-center justify-center mx-auto text-blue-500 mb-6">
|
||||
<LogIn size={32} />
|
||||
</div>
|
||||
<h1 className="text-3xl font-black tracking-tighter text-white">Student Login</h1>
|
||||
<p className="text-gray-500 font-bold uppercase tracking-widest text-[10px]">Welcome back to your learning journey</p>
|
||||
</div>
|
||||
|
||||
<div className="glass-card p-8 border-white/5 bg-white/[0.02]">
|
||||
<form onSubmit={handleSubmit} className="space-y-6">
|
||||
{error && (
|
||||
<div className="p-4 rounded-xl bg-red-500/10 border border-red-500/20 text-red-400 text-xs font-bold text-center">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-2">
|
||||
<label className="text-[10px] font-black uppercase tracking-widest text-gray-500 px-1">Email Address</label>
|
||||
<div className="relative">
|
||||
<Mail className="absolute left-4 top-1/2 -translate-y-1/2 text-gray-500" size={18} />
|
||||
<input
|
||||
type="email"
|
||||
required
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
placeholder="name@company.com"
|
||||
className="w-full bg-white/5 border border-white/10 rounded-xl py-4 pl-12 pr-4 text-sm text-white focus:outline-none focus:border-blue-500 transition-all"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<label className="text-[10px] font-black uppercase tracking-widest text-gray-500 px-1">Password</label>
|
||||
<div className="relative">
|
||||
<Lock className="absolute left-4 top-1/2 -translate-y-1/2 text-gray-500" size={18} />
|
||||
<input
|
||||
type="password"
|
||||
required
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
placeholder="••••••••"
|
||||
className="w-full bg-white/5 border border-white/10 rounded-xl py-4 pl-12 pr-4 text-sm text-white focus:outline-none focus:border-blue-500 transition-all"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
disabled={loading}
|
||||
type="submit"
|
||||
className="btn-premium w-full !py-4 font-black text-xs uppercase tracking-[0.2em] shadow-xl shadow-blue-500/20 disabled:opacity-50"
|
||||
>
|
||||
{loading ? "Authenticating..." : "Continue to Dashboard"}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<p className="text-center text-[10px] font-bold uppercase tracking-widest text-gray-600">
|
||||
Don't have an account? <Link href="/auth/register" className="text-blue-500 hover:text-blue-400">Sign up here</Link>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { lmsApi } from "@/lib/api";
|
||||
import { useAuth } from "@/context/AuthContext";
|
||||
import { useRouter } from "next/navigation";
|
||||
import Link from "next/link";
|
||||
import { UserPlus, Mail, Lock, User } from "lucide-react";
|
||||
|
||||
export default function RegisterPage() {
|
||||
const [email, setEmail] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const [fullName, setFullName] = useState("");
|
||||
const [error, setError] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const { login } = useAuth();
|
||||
const router = useRouter();
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
setLoading(true);
|
||||
setError("");
|
||||
try {
|
||||
const res = await lmsApi.register({ email, password, full_name: fullName });
|
||||
login(res.user, res.token);
|
||||
router.push("/");
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : "Registration failed. Please try again.";
|
||||
setError(message);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-[calc(100vh-64px)] flex items-center justify-center p-6 bg-[#050505]">
|
||||
<div className="w-full max-w-md space-y-8 animate-in fade-in zoom-in duration-500">
|
||||
<div className="text-center space-y-2">
|
||||
<div className="w-16 h-16 rounded-2xl bg-blue-600/10 border border-blue-500/20 flex items-center justify-center mx-auto text-blue-500 mb-6">
|
||||
<UserPlus size={32} />
|
||||
</div>
|
||||
<h1 className="text-3xl font-black tracking-tighter text-white">Create Account</h1>
|
||||
<p className="text-gray-500 font-bold uppercase tracking-widest text-[10px]">Join the next generation of learners</p>
|
||||
</div>
|
||||
|
||||
<div className="glass-card p-8 border-white/5 bg-white/[0.02]">
|
||||
<form onSubmit={handleSubmit} className="space-y-6">
|
||||
{error && (
|
||||
<div className="p-4 rounded-xl bg-red-500/10 border border-red-500/20 text-red-400 text-xs font-bold text-center">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-2">
|
||||
<label className="text-[10px] font-black uppercase tracking-widest text-gray-500 px-1">Full Name</label>
|
||||
<div className="relative">
|
||||
<User className="absolute left-4 top-1/2 -translate-y-1/2 text-gray-500" size={18} />
|
||||
<input
|
||||
type="text"
|
||||
required
|
||||
value={fullName}
|
||||
onChange={(e) => setFullName(e.target.value)}
|
||||
placeholder="John Doe"
|
||||
className="w-full bg-white/5 border border-white/10 rounded-xl py-4 pl-12 pr-4 text-sm text-white focus:outline-none focus:border-blue-500 transition-all"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<label className="text-[10px] font-black uppercase tracking-widest text-gray-500 px-1">Email Address</label>
|
||||
<div className="relative">
|
||||
<Mail className="absolute left-4 top-1/2 -translate-y-1/2 text-gray-500" size={18} />
|
||||
<input
|
||||
type="email"
|
||||
required
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
placeholder="name@company.com"
|
||||
className="w-full bg-white/5 border border-white/10 rounded-xl py-4 pl-12 pr-4 text-sm text-white focus:outline-none focus:border-blue-500 transition-all"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<label className="text-[10px] font-black uppercase tracking-widest text-gray-500 px-1">Password</label>
|
||||
<div className="relative">
|
||||
<Lock className="absolute left-4 top-1/2 -translate-y-1/2 text-gray-500" size={18} />
|
||||
<input
|
||||
type="password"
|
||||
required
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
placeholder="••••••••"
|
||||
className="w-full bg-white/5 border border-white/10 rounded-xl py-4 pl-12 pr-4 text-sm text-white focus:outline-none focus:border-blue-500 transition-all"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
disabled={loading}
|
||||
type="submit"
|
||||
className="btn-premium w-full !py-4 font-black text-xs uppercase tracking-[0.2em] shadow-xl shadow-blue-500/20 disabled:opacity-50"
|
||||
>
|
||||
{loading ? "Creating..." : "Start Learning"}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<p className="text-center text-[10px] font-bold uppercase tracking-widest text-gray-600">
|
||||
Already have an account? <Link href="/auth/login" className="text-blue-500 hover:text-blue-400">Login here</Link>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { lmsApi, Lesson, Course, Module } from "@/lib/api";
|
||||
import Link from "next/link";
|
||||
import { ChevronLeft, ChevronRight, Menu, CheckCircle2 } from "lucide-react";
|
||||
|
||||
import DescriptionPlayer from "@/components/blocks/DescriptionPlayer";
|
||||
import MediaPlayer from "@/components/blocks/MediaPlayer";
|
||||
import QuizPlayer from "@/components/blocks/QuizPlayer";
|
||||
import FillInTheBlanksPlayer from "@/components/blocks/FillInTheBlanksPlayer";
|
||||
import MatchingPlayer from "@/components/blocks/MatchingPlayer";
|
||||
import OrderingPlayer from "@/components/blocks/OrderingPlayer";
|
||||
import ShortAnswerPlayer from "@/components/blocks/ShortAnswerPlayer";
|
||||
|
||||
export default function LessonPlayerPage({ params }: { params: { id: string, lessonId: string } }) {
|
||||
const [lesson, setLesson] = useState<Lesson | null>(null);
|
||||
const [course, setCourse] = useState<(Course & { modules: Module[] }) | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [sidebarOpen, setSidebarOpen] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchAll = async () => {
|
||||
try {
|
||||
const [lessonData, courseData] = await Promise.all([
|
||||
lmsApi.getLesson(params.lessonId),
|
||||
lmsApi.getCourseOutline(params.id)
|
||||
]);
|
||||
setLesson(lessonData);
|
||||
setCourse(courseData);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
fetchAll();
|
||||
}, [params.id, params.lessonId]);
|
||||
|
||||
if (loading) return <div className="p-20 text-center animate-pulse text-gray-500 font-bold uppercase tracking-widest">Loading Experience...</div>;
|
||||
if (!lesson || !course) return <div className="p-20 text-center text-red-400">Content not found.</div>;
|
||||
|
||||
const allLessons = course.modules.flatMap(m => m.lessons);
|
||||
const currentIndex = allLessons.findIndex(l => l.id === params.lessonId);
|
||||
const prevLesson = allLessons[currentIndex - 1];
|
||||
const nextLesson = allLessons[currentIndex + 1];
|
||||
|
||||
return (
|
||||
<div className="flex h-[calc(100vh-64px)] overflow-hidden">
|
||||
{/* Navigation Sidebar */}
|
||||
<aside
|
||||
className={`glass border-r border-white/5 transition-all duration-500 bg-black/40 flex flex-col ${sidebarOpen ? 'w-80' : 'w-0 overflow-hidden border-none'}`}
|
||||
>
|
||||
<div className="p-6 border-b border-white/5">
|
||||
<h2 className="text-xs font-black uppercase tracking-widest text-blue-500 mb-1">Course Content</h2>
|
||||
<p className="text-sm font-bold text-white truncate">{course.title}</p>
|
||||
</div>
|
||||
|
||||
<div className="flex-1 overflow-y-auto py-4 px-3 space-y-6">
|
||||
{course.modules.map((module) => (
|
||||
<div key={module.id} className="space-y-2">
|
||||
<h4 className="px-3 text-[10px] font-black uppercase tracking-widest text-gray-500 mb-2">{module.title}</h4>
|
||||
<div className="space-y-1">
|
||||
{module.lessons.map((l) => (
|
||||
<Link
|
||||
key={l.id}
|
||||
href={`/courses/${params.id}/lessons/${l.id}`}
|
||||
className={`sidebar-link ${l.id === params.lessonId ? 'sidebar-link-active' : 'sidebar-link-inactive'}`}
|
||||
>
|
||||
<div className="flex-1 truncate">{l.title}</div>
|
||||
{/* Placeholder for progress checkmark */}
|
||||
<div className="w-4 h-4 rounded-full border border-white/10" />
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
{/* Main Content Area */}
|
||||
<main className="flex-1 flex flex-col relative">
|
||||
<div className="absolute top-4 left-4 z-10">
|
||||
<button
|
||||
onClick={() => setSidebarOpen(!sidebarOpen)}
|
||||
className="p-3 rounded-xl glass border-white/10 text-gray-400 hover:text-white transition-all bg-black/40"
|
||||
>
|
||||
<Menu size={20} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="flex-1 overflow-y-auto px-6 py-12">
|
||||
<div className="max-w-4xl mx-auto space-y-20 pb-40">
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center gap-2 text-[10px] font-black uppercase tracking-widest text-blue-400">
|
||||
<span>{lesson.content_type === 'activity' ? 'Interactive Activity' : 'Video Lesson'}</span>
|
||||
</div>
|
||||
<h1 className="text-4xl font-black tracking-tighter text-white">{lesson.title}</h1>
|
||||
</div>
|
||||
|
||||
{/* Render Blocks */}
|
||||
{(lesson.metadata?.blocks || []).length > 0 ? (
|
||||
<div className="space-y-24">
|
||||
{lesson.metadata?.blocks?.map((block) => (
|
||||
<div key={block.id} className="animate-in fade-in slide-in-from-bottom-6 duration-700 delay-100">
|
||||
{block.type === 'description' && (
|
||||
<DescriptionPlayer id={block.id} title={block.title} content={block.content || ""} />
|
||||
)}
|
||||
{block.type === 'media' && (
|
||||
<MediaPlayer
|
||||
id={block.id}
|
||||
title={block.title}
|
||||
url={block.url || ""}
|
||||
media_type={block.media_type || 'video'}
|
||||
config={block.config}
|
||||
/>
|
||||
)}
|
||||
{block.type === 'quiz' && (
|
||||
<QuizPlayer id={block.id} title={block.title} quizData={block.quiz_data || { questions: [] }} />
|
||||
)}
|
||||
{block.type === 'fill-in-the-blanks' && (
|
||||
<FillInTheBlanksPlayer id={block.id} title={block.title} content={block.content || ""} />
|
||||
)}
|
||||
{block.type === 'matching' && (
|
||||
<MatchingPlayer id={block.id} title={block.title} pairs={block.pairs || []} />
|
||||
)}
|
||||
{block.type === 'ordering' && (
|
||||
<OrderingPlayer id={block.id} title={block.title} items={block.items || []} />
|
||||
)}
|
||||
{block.type === 'short-answer' && (
|
||||
<ShortAnswerPlayer
|
||||
id={block.id}
|
||||
title={block.title}
|
||||
prompt={block.prompt || ""}
|
||||
correctAnswers={block.correctAnswers || []}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className="py-20 text-center glass-card border-dashed border-white/10">
|
||||
<p className="text-gray-500 font-bold uppercase tracking-widest">This lesson currently has no content.</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{lesson.is_graded && (
|
||||
<div className="pt-20 border-t border-white/5 animate-in fade-in slide-in-from-bottom-8 duration-1000">
|
||||
<div className="bg-blue-600/10 border border-blue-500/20 rounded-[2rem] p-12 text-center relative overflow-hidden group">
|
||||
<div className="absolute top-0 right-0 w-32 h-32 bg-blue-500/10 blur-3xl rounded-full -translate-y-1/2 translate-x-1/2 group-hover:bg-blue-500/20 transition-all duration-700"></div>
|
||||
<h3 className="text-2xl font-black mb-4">Complete & Submit</h3>
|
||||
<p className="text-gray-400 max-w-sm mx-auto mb-8 text-sm">
|
||||
This activity is graded. Make sure you've completed all blocks before submitting your work for evaluation.
|
||||
</p>
|
||||
|
||||
<button
|
||||
onClick={async () => {
|
||||
const userData = localStorage.getItem("user");
|
||||
if (userData) {
|
||||
const u = JSON.parse(userData);
|
||||
try {
|
||||
// In a real scenario, we'd calculate the actual score from blocks
|
||||
await lmsApi.submitScore(u.id, params.id, params.lessonId, 100);
|
||||
alert("Score submitted successfully!");
|
||||
} catch (err) {
|
||||
console.error("Submission failed", err);
|
||||
}
|
||||
}
|
||||
}}
|
||||
className="btn-premium px-12 py-4 rounded-2xl shadow-blue-500/40 shadow-xl group/btn"
|
||||
>
|
||||
<span className="flex items-center gap-2 font-black italic">
|
||||
SUBMIT FOR GRADING <CheckCircle2 className="w-5 h-5 group-hover/btn:scale-110 transition-transform" />
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Footer Controls */}
|
||||
<footer className="h-20 glass border-t border-white/5 px-6 flex items-center justify-between bg-black/60 backdrop-blur-3xl">
|
||||
{prevLesson ? (
|
||||
<Link href={`/courses/${params.id}/lessons/${prevLesson.id}`} className="group flex items-center gap-3">
|
||||
<div className="w-10 h-10 rounded-xl glass border-white/10 flex items-center justify-center group-hover:bg-white/5 transition-all text-gray-400 group-hover:text-white">
|
||||
<ChevronLeft size={20} />
|
||||
</div>
|
||||
<div className="hidden sm:block">
|
||||
<p className="text-[10px] font-black uppercase tracking-widest text-gray-500">Previous</p>
|
||||
<p className="text-xs font-bold text-gray-300 group-hover:text-white truncate max-w-[120px]">{prevLesson.title}</p>
|
||||
</div>
|
||||
</Link>
|
||||
) : <div />}
|
||||
|
||||
<div className="hidden lg:flex items-center gap-2">
|
||||
<div className="flex gap-1">
|
||||
{allLessons.map((l, i) => (
|
||||
<div key={l.id} className={`w-8 h-1 rounded-full ${i <= currentIndex ? 'bg-blue-500' : 'bg-white/10'}`} />
|
||||
))}
|
||||
</div>
|
||||
<span className="text-[10px] font-black uppercase tracking-widest text-gray-500 ml-4">
|
||||
{currentIndex + 1} OF {allLessons.length} COMPLETED
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{nextLesson ? (
|
||||
<Link href={`/courses/${params.id}/lessons/${nextLesson.id}`} className="btn-premium !py-3 !px-6 text-xs !shadow-none">
|
||||
Next Lesson <ChevronRight size={18} />
|
||||
</Link>
|
||||
) : (
|
||||
<Link href="/" className="btn-premium !bg-green-600 !py-3 !px-6 text-xs !shadow-none">
|
||||
Finish Course <CheckCircle2 size={18} />
|
||||
</Link>
|
||||
)}
|
||||
</footer>
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { lmsApi, Course, Module } from "@/lib/api";
|
||||
import Link from "next/link";
|
||||
import { BookOpen, ChevronRight, PlayCircle } from "lucide-react";
|
||||
|
||||
export default function CourseOutlinePage({ params }: { params: { id: string } }) {
|
||||
const [courseData, setCourseData] = useState<(Course & { modules: Module[] }) | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
lmsApi.getCourseOutline(params.id)
|
||||
.then(setCourseData)
|
||||
.catch(console.error)
|
||||
.finally(() => setLoading(false));
|
||||
}, [params.id]);
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="max-w-4xl mx-auto px-6 py-20 animate-pulse">
|
||||
<div className="h-12 w-2/3 bg-white/5 rounded-xl mb-6"></div>
|
||||
<div className="h-6 w-1/3 bg-white/5 rounded-xl mb-12"></div>
|
||||
<div className="space-y-6">
|
||||
{[1, 2, 3].map(i => (
|
||||
<div key={i} className="h-32 glass-card bg-white/5 border-white/5"></div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!courseData) return <div className="text-center py-20 text-gray-500">Course not found.</div>;
|
||||
|
||||
return (
|
||||
<div className="max-w-4xl mx-auto px-6 py-20">
|
||||
<div className="mb-16">
|
||||
<div className="flex items-center gap-2 mb-6 text-blue-500 font-bold text-xs uppercase tracking-widest">
|
||||
<Link href="/" className="hover:text-white transition-colors">Catalog</Link>
|
||||
<ChevronRight size={14} className="text-gray-600" />
|
||||
<span>Course Details</span>
|
||||
</div>
|
||||
<h1 className="text-5xl font-black tracking-tighter mb-6">{courseData.title}</h1>
|
||||
<p className="text-gray-400 text-lg leading-relaxed max-w-2xl mb-10">
|
||||
{courseData.description || "Master the core principles and advanced techniques in this structured curriculum. Each module is designed to provide actionable insights and hands-on experience."}
|
||||
</p>
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-8">
|
||||
<div className="flex flex-col">
|
||||
<span className="text-[10px] font-black uppercase tracking-widest text-gray-600 mb-1">Modules</span>
|
||||
<span className="text-xl font-bold text-white">{courseData.modules.length}</span>
|
||||
</div>
|
||||
<div className="w-px h-8 bg-white/10" />
|
||||
<div className="flex flex-col">
|
||||
<span className="text-[10px] font-black uppercase tracking-widest text-gray-600 mb-1">Total Lessons</span>
|
||||
<span className="text-xl font-bold text-white">
|
||||
{courseData.modules.reduce((acc, m) => acc + m.lessons.length, 0)}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Link href={`/courses/${params.id}/progress`}>
|
||||
<button className="px-8 py-3 glass hover:border-blue-500/50 transition-all font-bold text-xs uppercase tracking-widest flex items-center gap-3 active:scale-95">
|
||||
📊 View Progress
|
||||
</button>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-12">
|
||||
{courseData.modules.map((module, idx) => (
|
||||
<div key={module.id} className="relative">
|
||||
<div className="flex items-center gap-4 mb-6">
|
||||
<div className="w-10 h-10 rounded-xl glass border-blue-500/20 bg-blue-500/10 flex items-center justify-center">
|
||||
<span className="text-blue-400 font-black text-xs">{idx + 1}</span>
|
||||
</div>
|
||||
<h2 className="text-xl font-bold text-white tracking-tight">{module.title}</h2>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-3 pl-14">
|
||||
{module.lessons.map((lesson) => (
|
||||
<Link key={lesson.id} href={`/courses/${params.id}/lessons/${lesson.id}`}>
|
||||
<div className="glass-card !p-4 group hover:bg-white/10 border-white/5 active:scale-[0.99] transition-all">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="w-10 h-10 rounded-lg bg-white/5 flex items-center justify-center group-hover:bg-blue-500/20 transition-colors">
|
||||
{lesson.content_type === 'video' ? (
|
||||
<PlayCircle size={18} className="text-gray-400 group-hover:text-blue-400" />
|
||||
) : (
|
||||
<BookOpen size={18} className="text-gray-400 group-hover:text-blue-400" />
|
||||
)}
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="text-sm font-bold text-gray-200 group-hover:text-white transition-colors">{lesson.title}</h3>
|
||||
<span className="text-[10px] font-bold uppercase tracking-widest text-gray-500">
|
||||
{lesson.content_type === 'activity' ? 'Interactive Activity' : 'Video Lesson'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="opacity-0 group-hover:opacity-100 transition-opacity">
|
||||
<ChevronRight size={18} className="text-blue-500" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { lmsApi, GradingCategory, UserGrade, Course, Module } from "@/lib/api";
|
||||
import {
|
||||
Award,
|
||||
BarChart3,
|
||||
CheckCircle2,
|
||||
ChevronRight,
|
||||
Target,
|
||||
BookOpen,
|
||||
ArrowLeft,
|
||||
TrendingUp
|
||||
} from "lucide-react";
|
||||
import { clsx, type ClassValue } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
}
|
||||
|
||||
export default function StudentProgressPage() {
|
||||
const { id } = useParams() as { id: string };
|
||||
const router = useRouter();
|
||||
const [course, setCourse] = useState<(Course & { modules: Module[], grading_categories?: GradingCategory[] }) | null>(null);
|
||||
const [userGrades, setUserGrades] = useState<UserGrade[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [user, setUser] = useState<any>(null);
|
||||
|
||||
const loadData = React.useCallback(async () => {
|
||||
try {
|
||||
const courseData = await lmsApi.getCourseOutline(id);
|
||||
setCourse(courseData as any);
|
||||
|
||||
const userData = localStorage.getItem("user");
|
||||
if (userData) {
|
||||
const u = JSON.parse(userData);
|
||||
const grades = await lmsApi.getUserGrades(u.id, id);
|
||||
setUserGrades(grades);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to load progress data", err);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [id]);
|
||||
|
||||
useEffect(() => {
|
||||
const userData = localStorage.getItem("user");
|
||||
if (userData) setUser(JSON.parse(userData));
|
||||
loadData();
|
||||
}, [id, loadData]);
|
||||
|
||||
if (loading) return (
|
||||
<div className="min-h-screen bg-slate-950 flex items-center justify-center">
|
||||
<div className="w-12 h-12 border-4 border-blue-500/20 border-t-blue-500 rounded-full animate-spin"></div>
|
||||
</div>
|
||||
);
|
||||
|
||||
if (!course) return <div className="p-20 text-center text-white">Course not found.</div>;
|
||||
|
||||
const gradingCategories = course.grading_categories || [];
|
||||
|
||||
// Calculate progress
|
||||
const categoryStats = gradingCategories.map(cat => {
|
||||
const catLessons = course.modules.flatMap(m => m.lessons).filter(l => l.grading_category_id === cat.id);
|
||||
const catGrades = userGrades.filter(g => catLessons.some(l => l.id === g.lesson_id));
|
||||
|
||||
const count = catLessons.length;
|
||||
const completedCount = catGrades.length;
|
||||
const avgScore = completedCount > 0
|
||||
? catGrades.reduce((sum, g) => sum + g.score, 0) / completedCount
|
||||
: 0;
|
||||
|
||||
const weightedScore = (avgScore * cat.weight) / 100;
|
||||
|
||||
return {
|
||||
...cat,
|
||||
count,
|
||||
completedCount,
|
||||
avgScore,
|
||||
weightedScore
|
||||
};
|
||||
});
|
||||
|
||||
const totalWeightedGrade = categoryStats.reduce((sum, s) => sum + s.weightedScore, 0);
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-slate-950 text-white pb-20">
|
||||
{/* Nav */}
|
||||
<div className="sticky top-0 z-50 bg-slate-950/80 backdrop-blur-xl border-b border-white/5 py-4 px-8">
|
||||
<div className="max-w-6xl mx-auto flex items-center justify-between">
|
||||
<div className="flex items-center gap-4">
|
||||
<button onClick={() => router.back()} className="p-2 hover:bg-white/5 rounded-full transition-colors">
|
||||
<ArrowLeft className="w-5 h-5 text-gray-400" />
|
||||
</button>
|
||||
<h1 className="text-xl font-bold">{course.title}</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="max-w-6xl mx-auto px-8 mt-12 grid grid-cols-1 lg:grid-cols-3 gap-12">
|
||||
{/* Left: Overall Progress */}
|
||||
<div className="lg:col-span-1 space-y-8">
|
||||
<div className="bg-gradient-to-br from-blue-600/20 to-indigo-600/20 rounded-[2.5rem] p-12 border border-blue-500/20 text-center relative overflow-hidden group">
|
||||
<div className="absolute top-0 right-0 w-32 h-32 bg-blue-500/10 blur-3xl rounded-full -translate-y-1/2 translate-x-1/2 group-hover:bg-blue-500/20 transition-all duration-700"></div>
|
||||
<h2 className="text-gray-400 font-bold uppercase tracking-widest text-xs mb-8">Overall Standing</h2>
|
||||
|
||||
<div className="relative inline-flex items-center justify-center mb-8">
|
||||
<svg className="w-48 h-48 -rotate-90">
|
||||
<circle
|
||||
className="text-white/5"
|
||||
strokeWidth="8"
|
||||
stroke="currentColor"
|
||||
fill="transparent"
|
||||
r="88"
|
||||
cx="96"
|
||||
cy="96"
|
||||
/>
|
||||
<circle
|
||||
className="text-blue-500 transition-all duration-1000 ease-out"
|
||||
strokeWidth="8"
|
||||
strokeDasharray={88 * 2 * Math.PI}
|
||||
strokeDashoffset={88 * 2 * Math.PI * (1 - totalWeightedGrade / 100)}
|
||||
strokeLinecap="round"
|
||||
stroke="currentColor"
|
||||
fill="transparent"
|
||||
r="88"
|
||||
cx="96"
|
||||
cy="96"
|
||||
/>
|
||||
</svg>
|
||||
<div className="absolute inset-0 flex flex-col items-center justify-center">
|
||||
<span className="text-6xl font-black">{Math.round(totalWeightedGrade)}%</span>
|
||||
<span className="text-xs text-blue-400 font-bold uppercase tracking-widest mt-1">Current Grade</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-center gap-2 text-green-400 bg-green-400/10 py-2 px-4 rounded-full w-fit mx-auto border border-green-400/20">
|
||||
<Award className="w-4 h-4" />
|
||||
<span className="text-sm font-bold">Passing Standing</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-white/5 rounded-3xl p-8 border border-white/10 space-y-6">
|
||||
<h3 className="text-sm font-bold uppercase tracking-[0.2em] text-gray-500 flex items-center gap-2">
|
||||
<BarChart3 className="w-4 h-4" /> Assessment Summary
|
||||
</h3>
|
||||
<div className="space-y-4">
|
||||
{categoryStats.map(stat => (
|
||||
<div key={stat.id} className="flex items-center justify-between group">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-2 h-2 rounded-full bg-blue-500 shadow-[0_0_10px_rgba(59,130,246,0.5)]"></div>
|
||||
<span className="text-gray-400 group-hover:text-white transition-colors">{stat.name}</span>
|
||||
</div>
|
||||
<span className="font-bold">{Math.round(stat.weightedScore)} / {stat.weight}%</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Right: Detailed Breakdown */}
|
||||
<div className="lg:col-span-2 space-y-12">
|
||||
<section>
|
||||
<h2 className="text-2xl font-black mb-8 flex items-center gap-3">
|
||||
<Target className="w-8 h-8 text-blue-500" />
|
||||
Detailed Breakdown
|
||||
</h2>
|
||||
|
||||
<div className="space-y-4">
|
||||
{categoryStats.map(cat => (
|
||||
<div key={cat.id} className="bg-white/5 border border-white/10 rounded-3xl p-8 hover:bg-white/[0.07] transition-all group">
|
||||
<div className="flex items-start justify-between mb-8">
|
||||
<div>
|
||||
<h3 className="text-xl font-bold">{cat.name}</h3>
|
||||
<p className="text-gray-400 text-sm mt-1">
|
||||
Weight: {cat.weight}% of total course grade
|
||||
</p>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<div className="text-4xl font-black text-blue-500">{Math.round(cat.avgScore)}%</div>
|
||||
<div className="text-[10px] text-gray-500 font-bold uppercase tracking-widest mt-1">Average Score</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-6">
|
||||
<div className="relative h-2 bg-white/5 rounded-full overflow-hidden">
|
||||
<div
|
||||
className="absolute inset-y-0 left-0 bg-gradient-to-r from-blue-600 to-indigo-600 rounded-full transition-all duration-1000 ease-out"
|
||||
style={{ width: `${cat.avgScore}%` }}
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<BookOpen className="w-4 h-4 text-gray-500" />
|
||||
<span className="text-gray-400">{cat.completedCount} / {cat.count} assessments completed</span>
|
||||
</div>
|
||||
</div>
|
||||
{cat.completedCount === cat.count && (
|
||||
<div className="flex items-center gap-2 text-green-400 font-bold">
|
||||
<CheckCircle2 className="w-4 h-4" />
|
||||
Category Finished
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="bg-indigo-600/10 border border-indigo-500/20 rounded-[2rem] p-8 flex items-center justify-between">
|
||||
<div className="flex items-center gap-6">
|
||||
<div className="w-16 h-16 rounded-2xl bg-indigo-500/20 flex items-center justify-center text-indigo-400">
|
||||
<TrendingUp className="w-8 h-8" />
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="text-lg font-bold">Certification Track</h3>
|
||||
<p className="text-sm text-indigo-300/60 mt-0.5">Maintain 60% or higher to earn your verified certificate.</p>
|
||||
</div>
|
||||
</div>
|
||||
<ChevronRight className="w-6 h-6 text-indigo-500/50" />
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
@@ -0,0 +1,87 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
:root {
|
||||
--foreground-rgb: 255, 255, 255;
|
||||
--background-start-rgb: 10, 10, 20;
|
||||
--background-end-rgb: 0, 0, 0;
|
||||
|
||||
--accent-primary: #3b82f6;
|
||||
--accent-secondary: #8b5cf6;
|
||||
--glass-bg: rgba(255, 255, 255, 0.03);
|
||||
--glass-border: rgba(255, 255, 255, 0.08);
|
||||
--glass-blur: blur(16px);
|
||||
}
|
||||
|
||||
body {
|
||||
color: rgb(var(--foreground-rgb));
|
||||
background: radial-gradient(circle at top left, #1a1a2e, #000000);
|
||||
background-attachment: fixed;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.glass {
|
||||
background: var(--glass-bg);
|
||||
backdrop-filter: var(--glass-blur);
|
||||
-webkit-backdrop-filter: var(--glass-blur);
|
||||
border: 1px solid var(--glass-border);
|
||||
}
|
||||
|
||||
.glass-card {
|
||||
@apply glass rounded-2xl p-6 transition-all duration-300;
|
||||
}
|
||||
|
||||
.glass-card:hover {
|
||||
@apply border-white/20 bg-white/5;
|
||||
}
|
||||
|
||||
.gradient-text {
|
||||
background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
}
|
||||
|
||||
.btn-premium {
|
||||
@apply relative px-8 py-3 rounded-xl font-bold transition-all duration-300 flex items-center justify-center gap-2;
|
||||
background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
|
||||
box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
|
||||
}
|
||||
|
||||
.btn-premium:hover {
|
||||
@apply scale-[1.02] -translate-y-0.5 shadow-blue-500/40;
|
||||
}
|
||||
|
||||
.btn-premium:active {
|
||||
@apply scale-95;
|
||||
}
|
||||
|
||||
.sidebar-link {
|
||||
@apply flex items-center gap-3 px-4 py-3 rounded-xl text-sm font-medium transition-all;
|
||||
}
|
||||
|
||||
.sidebar-link-active {
|
||||
@apply bg-blue-500/10 text-blue-400 border border-blue-500/20;
|
||||
}
|
||||
|
||||
.sidebar-link-inactive {
|
||||
@apply text-gray-400 hover:text-white hover:bg-white/5;
|
||||
}
|
||||
|
||||
/* Custom Scrollbar */
|
||||
::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import type { Metadata } from "next";
|
||||
import { Inter } from "next/font/google";
|
||||
import "./globals.css";
|
||||
import Link from "next/link";
|
||||
import { AuthProvider } from "@/context/AuthContext";
|
||||
|
||||
const inter = Inter({ subsets: ["latin"] });
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "OpenCCB | Learning Experience",
|
||||
description: "Consume high-fidelity educational content with OpenCCB",
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
return (
|
||||
<html lang="en" className="dark">
|
||||
<body className={`${inter.className} bg-[#050505] text-[#e5e5e5] min-h-screen flex flex-col`}>
|
||||
<AuthProvider>
|
||||
{/* Header */}
|
||||
<header className="h-16 glass sticky top-0 z-50 px-6 flex items-center justify-between border-b border-white/5 backdrop-blur-xl bg-black/40">
|
||||
<Link href="/" className="flex items-center gap-2 group">
|
||||
<div className="w-8 h-8 rounded-lg bg-blue-600 flex items-center justify-center font-black text-white shadow-lg shadow-blue-500/20 group-hover:scale-105 transition-transform">
|
||||
L
|
||||
</div>
|
||||
<span className="font-black text-xl tracking-tighter text-white">LEARN<span className="text-blue-500">EXPERIENCE</span></span>
|
||||
</Link>
|
||||
|
||||
<nav className="hidden md:flex items-center gap-8">
|
||||
<Link href="/" className="text-xs font-black uppercase tracking-widest text-gray-400 hover:text-white transition-colors">Catalog</Link>
|
||||
<Link href="#" className="text-xs font-black uppercase tracking-widest text-gray-400 hover:text-white transition-colors">My Learning</Link>
|
||||
<div className="w-8 h-8 rounded-full bg-white/5 border border-white/10" />
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main className="flex-1">
|
||||
{children}
|
||||
</main>
|
||||
|
||||
{/* Footer */}
|
||||
<footer className="py-12 px-6 border-t border-white/5 text-center bg-black/20">
|
||||
<p className="text-[10px] font-black uppercase tracking-[0.2em] text-gray-600">
|
||||
Powered by OpenCCB © 2023. Advanced Agentic Coding.
|
||||
</p>
|
||||
</footer>
|
||||
</AuthProvider>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { lmsApi, Course } from "@/lib/api";
|
||||
import Link from "next/link";
|
||||
import { useAuth } from "@/context/AuthContext";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Rocket, CheckCircle2, ArrowRight, Star } from "lucide-react";
|
||||
|
||||
export default function CatalogPage() {
|
||||
const [courses, setCourses] = useState<Course[]>([]);
|
||||
const [enrollments, setEnrollments] = useState<string[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
const { user } = useAuth();
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
const coursesData = await lmsApi.getCatalog();
|
||||
setCourses(coursesData);
|
||||
|
||||
if (user) {
|
||||
const enrollmentData = await lmsApi.getEnrollments(user.id);
|
||||
setEnrollments(enrollmentData.map(e => e.course_id));
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
fetchData();
|
||||
}, [user]);
|
||||
|
||||
const handleEnroll = async (courseId: string) => {
|
||||
if (!user) {
|
||||
router.push("/auth/login");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await lmsApi.enroll(courseId, user.id);
|
||||
setEnrollments(prev => [...prev, courseId]);
|
||||
} catch (err) {
|
||||
console.error("Enrollment failed", err);
|
||||
}
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="max-w-7xl mx-auto px-6 py-20">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
|
||||
{[1, 2, 3].map(i => (
|
||||
<div key={i} className="h-80 glass-card animate-pulse bg-white/5 border-white/5 rounded-3xl"></div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="max-w-7xl mx-auto px-6 py-20">
|
||||
<div className="mb-20 flex flex-col md:flex-row md:items-end justify-between gap-8">
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center gap-2 text-[10px] font-black uppercase tracking-[0.3em] text-blue-500">
|
||||
<Star size={14} className="fill-blue-500" />
|
||||
<span>Premier Curriculum</span>
|
||||
</div>
|
||||
<h1 className="text-6xl font-black tracking-tighter leading-none">
|
||||
Explore <span className="text-transparent bg-clip-text bg-gradient-to-r from-blue-400 to-indigo-600">Courses</span>
|
||||
</h1>
|
||||
<p className="text-gray-500 font-medium max-w-xl text-lg">
|
||||
Master the skills of the future with our high-fidelity educational content.
|
||||
</p>
|
||||
</div>
|
||||
{!user && (
|
||||
<Link href="/auth/register" className="btn-premium !bg-white !text-black shadow-none !px-8">
|
||||
Get Started Free
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{courses.length === 0 ? (
|
||||
<div className="py-20 text-center glass-card border-dashed border-white/10 rounded-3xl bg-white/[0.01]">
|
||||
<p className="text-gray-500 font-bold uppercase tracking-widest">No courses published yet.</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
|
||||
{courses.map((course) => {
|
||||
const isEnrolled = enrollments.includes(course.id);
|
||||
|
||||
return (
|
||||
<div key={course.id} className="glass-card group relative overflow-hidden h-full flex flex-col p-8 border-white/5 bg-white/[0.02] hover:bg-white/[0.04] transition-all duration-500 rounded-3xl">
|
||||
<div className="mb-8 flex items-start justify-between">
|
||||
<div className="w-14 h-14 rounded-2xl bg-gradient-to-br from-blue-600 to-indigo-700 flex items-center justify-center shadow-2xl shadow-blue-500/20 group-hover:scale-110 transition-transform duration-500">
|
||||
<Rocket size={24} className="text-white fill-white/10" />
|
||||
</div>
|
||||
{isEnrolled && (
|
||||
<span className="text-[10px] font-black uppercase tracking-widest px-3 py-1 rounded-full bg-green-500/10 text-green-400 border border-green-500/20">
|
||||
Enrolled
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<h2 className="text-2xl font-black text-white mb-4 leading-tight group-hover:text-blue-400 transition-colors">
|
||||
{course.title}
|
||||
</h2>
|
||||
|
||||
<div className="flex-1">
|
||||
<p className="text-gray-500 text-sm font-medium line-clamp-3 mb-10 leading-relaxed">
|
||||
{course.description || "In-depth curriculum covering foundational principles to advanced mastery, crafted by industry veterans."}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="pt-8 border-t border-white/5 flex items-center justify-between mt-auto">
|
||||
{isEnrolled ? (
|
||||
<Link href={`/courses/${course.id}`} className="btn-premium w-full !bg-blue-600/10 !text-blue-400 border border-blue-500/20 hover:!bg-blue-600/20 !shadow-none gap-2">
|
||||
Continue Learning <ArrowRight size={16} />
|
||||
</Link>
|
||||
) : (
|
||||
<button
|
||||
onClick={() => handleEnroll(course.id)}
|
||||
className="btn-premium w-full group-hover:scale-[1.02] transition-transform flex items-center justify-center gap-2 group/btn"
|
||||
>
|
||||
<CheckCircle2 size={18} className="text-white/50 group-hover/btn:text-white transition-colors" />
|
||||
Enroll for Free
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user