import { useEffect, useState } from "react" import { Link } from "react-router-dom" import { FolderOpen, RefreshCw, AlertCircle, BookOpen } from "lucide-react" import { Card, CardContent, CardHeader, CardTitle } from "../../components/ui/card" import { getCourseCategories } from "../../api/courses.api" import type { CourseCategory } from "../../types/course.types" export function CourseCategoryPage() { const [categories, setCategories] = useState([]) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) const fetchCategories = async () => { setLoading(true) setError(null) try { const res = await getCourseCategories() setCategories(res.data.data.categories) } catch (err) { console.error("Failed to fetch categories:", err) setError("Failed to load categories") } finally { setLoading(false) } } useEffect(() => { fetchCategories() }, []) if (loading) { return (
Loading categories…
) } if (error) { return (

{error}

Please check your connection and try again

) } return (
{/* Page header */}

Course Categories

Browse and manage your course categories below

{categories.length === 0 ? (

No categories yet

Course categories will appear here once created. Start by adding your first category.

) : (
{categories.map((category) => ( {/* Decorative gradient strip */}
{category.name}
View Courses → ))}
)}
) }