import { Badge } from "@/components/ui/badge"; import { cn } from "@/lib/utils"; import type { CoursePlanMaterial } from "@/types"; export const SKILL_STYLE: Record = { reading: "bg-blue-100 text-blue-800 border-blue-200", writing: "bg-purple-100 text-purple-800 border-purple-200", listening: "bg-emerald-100 text-emerald-800 border-emerald-200", speaking: "bg-amber-100 text-amber-800 border-amber-200", grammar: "bg-rose-100 text-rose-800 border-rose-200", vocabulary: "bg-cyan-100 text-cyan-800 border-cyan-200", integrated: "bg-slate-100 text-slate-800 border-slate-200", }; export function SkillBadge({ skill }: { skill: string }) { return ( {skill || "integrated"} ); } function renderAny(value: unknown): React.ReactNode { if (value == null) return null; if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") { return

{String(value)}

; } if (Array.isArray(value)) { if (value.length === 0) return null; return ( ); } if (typeof value === "object") { const entries = Object.entries(value as Record); return (
{entries.map(([k, v]) => (
{k.replace(/_/g, " ")}
{renderAny(v)}
))}
); } return null; } export default function MaterialBookView({ material, }: { material: Pick; }) { const body = material.body ?? {}; const hasStructured = Object.keys(body).length > 0; return (
{hasStructured ? ( renderAny(body) ) : (

{material.body_text || "No content available yet."}

)}
); }