import data from "@/data/academy/courses-detail.json";

export type CourseHighlight = { title: string; body: string };
export type CourseProgrammeBlock = {
  time: string;
  title: string;
  items: string[];
};
export type CourseTestimonial = { quote: string; author: string };
export type CourseConvenor = {
  name: string;
  role: string;
  bio: string;
  badges: string[];
};

export type CourseDetail = {
  slug: string;
  overview: string;
  whoShouldAttend: string[];
  outcomes: string[];
  highlights: CourseHighlight[];
  whyDifferent: string[];
  programme: CourseProgrammeBlock[];
  testimonials: CourseTestimonial[];
  convenor: CourseConvenor | null;
};

const payload = data as unknown as {
  courses: Record<string, CourseDetail>;
};

/**
 * Look up the richer content extracted from orthoglobe-courses.html for a
 * given course slug. Returns null when the slug is not in the source file
 * (so the detail page gracefully falls back to DB-only rendering).
 */
export function getCourseDetailContent(slug: string): CourseDetail | null {
  return payload.courses[slug] ?? null;
}
