import Modal from './Modal.jsx';
function StudyGuideContent({ doc }) {
return (
{doc.title}
{doc.sections?.map((section, i) => (
{section.heading}
{section.bullets?.length > 0 && (
{section.bullets.map((b, j) => - {b}
)}
)}
{section.keyTerms?.length > 0 && (
Key Terms
{section.keyTerms.map((kt, j) => (
- {kt.term}
- {kt.definition}
))}
)}
{section.reviewQuestions?.length > 0 && (
Self-Review
{section.reviewQuestions.map((q, j) => - {q}
)}
)}
))}
{doc.mnemonics?.length > 0 && (
Memory Aids
{doc.mnemonics.map((m, i) => - {m}
)}
)}
);
}
function FaqContent({ doc }) {
return (
FAQ: {doc.subject}
{doc.faqPairs?.map((pair, i) => (
Q: {pair.question}
{pair.answer}
))}
);
}
function ExecBriefContent({ doc }) {
return (
{doc.title}
{doc.sections?.map((section, i) => (
{section.subhead}
{section.prose}
))}
);
}
const LABELS = {
'study-guide': 'Study Guide',
'faq': 'F.A.Q.',
'executive-brief': 'Executive Brief',
};
const RENDERERS = {
'study-guide': StudyGuideContent,
'faq': FaqContent,
'executive-brief': ExecBriefContent,
};
function DocumentModal({ open, onClose, type, document: doc, loading }) {
const Renderer = type ? RENDERERS[type] : null;
const label = type ? LABELS[type] : '';
return (
{loading ? (
Generating {label}
) : (
<>
{Renderer && doc && }
>
)}
);
}
export default DocumentModal;