"use client"; import { FileText, X } from "lucide-react"; import type { ApiDocument } from "@/lib/api/types"; import { cn } from "@/lib/utils"; function formatMaterialType(materialType: string | null | undefined): string { if (!materialType || materialType === "unknown") return "Unclassified"; return materialType.replace(/_/g, " ").replace(/\b\w/g, (char) => char.toUpperCase()); } function getMaterialTypeBadgeColor(materialType: string | null | undefined): string { if (!materialType || materialType === "unknown") { return "border-white/12 bg-white/[0.04] text-white/46"; } const colors: Record = { notes: "border-white/14 bg-white/[0.06] text-white/72", chapter: "border-blue-300/16 bg-blue-400/[0.08] text-blue-200/80", textbook: "border-emerald-300/16 bg-emerald-400/[0.08] text-emerald-200/80", handwritten_notes: "border-amber-300/16 bg-amber-400/[0.08] text-amber-200/80", question_paper: "border-rose-300/16 bg-rose-400/[0.08] text-rose-200/80", pyq_collection: "border-orange-300/16 bg-orange-400/[0.08] text-orange-200/80", syllabus: "border-cyan-300/16 bg-cyan-400/[0.08] text-cyan-200/80", formula_sheet: "border-pink-300/16 bg-pink-400/[0.08] text-pink-200/80", mixed: "border-white/14 bg-white/[0.06] text-white/72", }; return colors[materialType] || colors.notes; } function compactEducationBadge(document: ApiDocument): string | null { if (document.education_extraction_status === "extraction_failed") return "Extraction failed"; if (document.education_extraction_status === "needs_review") return "Needs review"; if (document.material_type === "syllabus" && (document.syllabus_items_count ?? 0) > 0) { return `${document.syllabus_items_count} topics`; } if (document.material_type === "question_paper" && (document.pyq_questions_count ?? 0) > 0) { return `${document.pyq_questions_count} PYQ`; } return null; } export function SourcePill({ document, active, onToggle, onRemove, }: { document: ApiDocument; active: boolean; onToggle: () => void; onRemove?: () => void; }) { const educationBadge = compactEducationBadge(document); return ( ); } export function SelectedSourcesStrip({ selectedDocuments, documents, onToggleSource, onClear, }: { selectedDocuments: ApiDocument[]; documents: ApiDocument[]; onToggleSource: (id: string) => void; onClear: () => void; }) { const previewDocuments = selectedDocuments.length > 0 ? selectedDocuments : documents.slice(0, 4); if (previewDocuments.length === 0) return null; return (
{selectedDocuments.length > 0 ? "Selected sources" : "Recent sources"}
{previewDocuments.map((document) => ( item.id === document.id)} onToggle={() => onToggleSource(document.id)} onRemove={selectedDocuments.some((item) => item.id === document.id) ? () => onToggleSource(document.id) : undefined} /> ))}
{selectedDocuments.length > 0 ? ( ) : null}
); }