Repository navigation
Expand file tree
/
Copy pathExamSelect.tsx
More file actions
66 lines (60 loc) · 1.67 KB
/
Copy pathExamSelect.tsx
File metadata and controls
66 lines (60 loc) · 1.67 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
57
58
59
60
61
62
63
64
65
66
import { formatExamLabelDropdown, formatExamLabelFull } from '@alea/spec';
import { FormControl, InputLabel, Select, MenuItem, Tooltip, Typography } from '@mui/material';
interface ExamInfo {
uri: string;
term?: string;
number?: string;
date?: string;
}
interface ExamSelectProps {
exams: ExamInfo[];
courseId?: string;
value: string;
onChange: (examUri: string) => void;
label?: string;
size?: 'small' | 'medium';
}
export function ExamSelect({
exams,
courseId,
value,
onChange,
label = 'Appeared in exams',
size = 'small',
}: ExamSelectProps) {
return (
<FormControl size={size} sx={{ minWidth: 180 }}>
<InputLabel sx={{ fontSize: '0.85rem' }}>{label}</InputLabel>
<Select
size="small"
value={value}
label={label}
onChange={(e) => onChange(e.target.value as string)}
sx={{
height: 32,
fontSize: '0.80rem',
'& .MuiSelect-select': {
py: 0.5,
},
}}
>
<MenuItem disabled value="">
<em>{exams.length ? 'Select' : 'No items available'}</em>
</MenuItem>
{exams.map((exam) => {
const dropdownLabel = formatExamLabelDropdown(exam.uri, exam, courseId);
const fullLabel = formatExamLabelFull(exam.uri, exam, courseId);
return (
<MenuItem key={exam.uri} value={exam.uri}>
<Tooltip title={fullLabel} placement="right" arrow>
<Typography noWrap sx={{ maxWidth: 300 }}>
{dropdownLabel}
</Typography>
</Tooltip>
</MenuItem>
);
})}
</Select>
</FormControl>
);
}