This commit is contained in:
Marcelo
2026-02-17 00:07:00 +00:00
parent b7a86a2d1c
commit be4ca2ed78
92 changed files with 6850 additions and 1188 deletions

14
lib/data/courseCatalog.ts Normal file → Executable file
View File

@@ -2,12 +2,14 @@ import { mockCourses } from "@/lib/data/mockCourses";
import { getTeacherCourseBySlug, getTeacherCourses } from "@/lib/data/teacherCourses";
import type { Course } from "@/types/course";
const isPublished = (course: Course) => course.status === "Published";
export const getAllCourses = (): Course[] => {
const teacherCourses = getTeacherCourses();
if (teacherCourses.length === 0) return mockCourses;
const teacherCourses = getTeacherCourses().filter(isPublished);
if (teacherCourses.length === 0) return mockCourses.filter(isPublished);
const teacherSlugs = new Set(teacherCourses.map((course) => course.slug));
const baseCourses = mockCourses.filter((course) => !teacherSlugs.has(course.slug));
const baseCourses = mockCourses.filter((course) => isPublished(course) && !teacherSlugs.has(course.slug));
return [...baseCourses, ...teacherCourses];
};
@@ -17,4 +19,8 @@ export const getCourseBySlug = (slug: string): Course | undefined => {
return mockCourses.find((course) => course.slug === slug);
};
export const getAllCourseSlugs = (): string[] => getAllCourses().map((course) => course.slug);
export const getAllCourseSlugs = (): string[] => {
const teacherCourses = getTeacherCourses();
const all = [...mockCourses, ...teacherCourses];
return all.map((course) => course.slug);
};