This repository has been archived by the owner on Dec 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
InfoBox.tsx
97 lines (83 loc) · 2.18 KB
/
InfoBox.tsx
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { useEffect, useState } from 'react';
import Paper from '@mui/material/Paper';
import { Language, NumeralSystem } from '../../types';
import en2 from './content/2/en.md';
import fi2 from './content/2/fi.md';
import it2 from './content/2/it.md';
import ko2 from './content/2/ko.md';
import sv2 from './content/2/sv.md';
import en8 from './content/8/en.md';
import fi8 from './content/8/fi.md';
import it8 from './content/8/it.md';
import ko8 from './content/8/ko.md';
import sv8 from './content/8/sv.md';
import en10 from './content/10/en.md';
import fi10 from './content/10/fi.md';
import it10 from './content/10/it.md';
import ko10 from './content/10/ko.md';
import sv10 from './content/10/sv.md';
import en16 from './content/16/en.md';
import fi16 from './content/16/fi.md';
import it16 from './content/16/it.md';
import ko16 from './content/16/ko.md';
import sv16 from './content/16/sv.md';
import InfoBoxContent from './InfoBoxContent';
import ReadMoreButton from './ReadMoreButton';
interface InfoBoxProps {
language: Language
system: NumeralSystem
}
const InfoBox = ({ language, system }: InfoBoxProps): JSX.Element => {
const [content, setContent] = useState('');
type FileDictionary = {
[key in NumeralSystem]: {
[key in Language]: string
}
};
const file: FileDictionary = {
2: {
'en': en2,
'fi': fi2,
'it': it2,
'ko': ko2,
'sv': sv2,
},
8: {
'en': en8,
'fi': fi8,
'it': it8,
'ko': ko8,
'sv': sv8,
},
10: {
'en': en10,
'fi': fi10,
'it': it10,
'ko': ko10,
'sv': sv10,
},
16: {
'en': en16,
'fi': fi16,
'it': it16,
'ko': ko16,
'sv': sv16,
},
};
useEffect(() => {
fetch(file[system][language])
.then(content => content.text())
.then(text => setContent(text))
.catch(error => console.error(error));
}, [language, system]);
return (
<Paper
sx={{ padding: '0px 15px 35px 15px', position: 'relative', width: '1' }}
variant="outlined"
>
<InfoBoxContent content={content} />
<ReadMoreButton language={language} system={system} />
</Paper>
);
};
export default InfoBox;