advance
This commit is contained in:
14
lib/data/courseCatalog.ts
Normal file → Executable file
14
lib/data/courseCatalog.ts
Normal file → Executable 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);
|
||||
};
|
||||
|
||||
0
lib/data/mockCaseStudies.ts
Normal file → Executable file
0
lib/data/mockCaseStudies.ts
Normal file → Executable file
4
lib/data/mockCourses.ts
Normal file → Executable file
4
lib/data/mockCourses.ts
Normal file → Executable file
@@ -5,6 +5,7 @@ export const mockCourses: Course[] = [
|
||||
slug: "legal-english-foundations",
|
||||
title: "Legal English Foundations",
|
||||
level: "Beginner",
|
||||
status: "Published",
|
||||
summary: "Build legal vocabulary, core writing patterns, and court terminology.",
|
||||
rating: 4.8,
|
||||
weeks: 4,
|
||||
@@ -24,6 +25,7 @@ export const mockCourses: Course[] = [
|
||||
slug: "contract-analysis-practice",
|
||||
title: "Contract Analysis Practice",
|
||||
level: "Intermediate",
|
||||
status: "Published",
|
||||
summary: "Analyze contract sections and identify risk-heavy clauses quickly.",
|
||||
rating: 4.7,
|
||||
weeks: 5,
|
||||
@@ -44,6 +46,7 @@ export const mockCourses: Course[] = [
|
||||
slug: "litigation-brief-writing",
|
||||
title: "Litigation Brief Writing",
|
||||
level: "Advanced",
|
||||
status: "Published",
|
||||
summary: "Craft persuasive briefs with strong authority usage and argument flow.",
|
||||
rating: 4.9,
|
||||
weeks: 6,
|
||||
@@ -65,6 +68,7 @@ export const mockCourses: Course[] = [
|
||||
slug: "cross-border-ip-strategy",
|
||||
title: "Cross-Border IP Strategy",
|
||||
level: "Advanced",
|
||||
status: "Published",
|
||||
summary: "Understand IP enforcement strategy across multiple jurisdictions.",
|
||||
rating: 4.6,
|
||||
weeks: 4,
|
||||
|
||||
0
lib/data/mockPractice.ts
Normal file → Executable file
0
lib/data/mockPractice.ts
Normal file → Executable file
1
lib/data/teacherCourses.ts
Normal file → Executable file
1
lib/data/teacherCourses.ts
Normal file → Executable file
@@ -92,6 +92,7 @@ export const createTeacherCourse = (input: TeacherCourseInput, reservedSlugs: st
|
||||
slug,
|
||||
title: input.title,
|
||||
level: input.level,
|
||||
status: "Draft",
|
||||
summary: input.summary,
|
||||
rating: 5,
|
||||
weeks: Math.max(1, input.weeks),
|
||||
|
||||
Reference in New Issue
Block a user