ScheduleItem.js
1.17 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
import { useContext } from "react";
import { CalendarStateContext } from "../pages/Calendar";
import zoomSymbol from "../assets/zoom.png";
import ecampusSymbol from "../assets/e-Campus.png";
const ScheduleItem = ({ schedule }) => {
const { subCode, type, category, label, start, end } = schedule;
const { subsObj } = useContext(CalendarStateContext);
const subject = subsObj[subCode];
if (!subject) {
console.log("can't find " + subCode);
return;
}
if (!subject.selected) return;
const selectSymbol = () => {
let symbol;
switch (type) {
case "zoom":
symbol = zoomSymbol;
break;
case "ecampus":
symbol = ecampusSymbol;
break;
default:
}
return symbol;
};
return (
<div className="ScheduleItem" style={{ borderColor: subject.color }}>
<img className="s_symbol" src={selectSymbol()} alt="404" />
{start && <span className="s_start">{start[0] + ":" + start[1]}</span>}
{end && <span className="s_end">{end[0] + ":" + end[1]}</span>}
<span className="s_category">{category}</span>
<span className="s_slabel">{label}</span>
</div>
);
};
export default ScheduleItem;