-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathSectionContentManager.tsx
More file actions
56 lines (52 loc) · 1.44 KB
/
SectionContentManager.tsx
File metadata and controls
56 lines (52 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import type { Content } from './types';
type SectionContentManagerProps = {
content: Content;
};
const SectionContentManager = ({ content }: SectionContentManagerProps) => (
<div className="section__content">
{(() => {
switch (content.type) {
case 'list':
return (
<ul>
{content.items.map((item, index) => (
<li key={index}>{item.value}</li>
))}
</ul>
);
case 'text':
return <p dangerouslySetInnerHTML={{ __html: content.value }} />;
case 'faq':
return (
<ol>
{content.questions &&
content.questions.map((question, index) => (
<li key={index}>
<h3>
{index + 1}. {question.question}
</h3>
<p>{question.answer}</p>
</li>
))}
</ol>
);
case 'definitions':
return (
<table>
<tbody>
{content.definitions.map((item) => (
<tr key={item.term}>
<th scope="row">{item.term}</th>
<td>{item.definition}</td>
</tr>
))}
</tbody>
</table>
);
default:
return null;
}
})()}
</div>
);
export default SectionContentManager;