-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathProgressDisplay.jsx
More file actions
75 lines (70 loc) · 2.08 KB
/
Copy pathProgressDisplay.jsx
File metadata and controls
75 lines (70 loc) · 2.08 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
67
68
69
70
71
72
73
74
75
import PropTypes from "prop-types";
import { Label, Progress } from "flowbite-react";
import "flowbite-react";
import { getHours } from "../screens/Stats/User/hourParsing";
const ProgressDisplay = ({
className,
type,
attendance,
header,
medalDefaults,
}) => {
let level = "Bronze";
let num = 0;
let outOf;
if (type === "Events") {
outOf = medalDefaults.eventSilver;
if (attendance.length > 15) {
level = "Gold";
outOf = medalDefaults.eventGold * 2;
} else if (attendance.length > 10) {
level = "Silver";
outOf = medalDefaults.eventGold;
}
num = attendance.length;
} else {
let add = 0;
outOf = medalDefaults.hoursSilver;
for (let i = 0; i < attendance.length; i++) {
if (attendance[i].checkoutTime != null) {
add += getHours(
attendance[i].checkinTime.slice(11, 16),
attendance[i].checkoutTime.slice(11, 16)
);
}
}
if (add >= 15) {
level = "Gold";
outOf = medalDefaults.hoursGold * 2;
} else if (add >= 10) {
level = "Silver";
outOf = medalDefaults.hoursGold;
}
num = Math.round(add * 10) / 10;
}
return (
<div className={"rounded-md bg-grey px-12 py-4 " + (className || "")}>
<Label class="text-black-800 text-xl font-semibold">{header}</Label>
<div className="flex flex-nowrap items-center">
<img
className="h-16"
src={"/images/Hours Earned - " + level + ".png"}
alt="medal"
/>
<div className="flex flex-nowrap items-center font-semibold">
<p className="pl-6 text-2xl">{num}</p>
<p className="text-md pl-2 text-slate-600">/ {outOf}</p>
<p className="text-md pl-2 text-slate-600">{type}</p>
</div>
</div>
<Progress className="mt-4" progress={(num / outOf) * 100} color="green" />
</div>
);
};
ProgressDisplay.propTypes = {
type: PropTypes.string.isRequired,
attendance: PropTypes.object.isRequired,
header: PropTypes.string.isRequired,
medalDefaults: PropTypes.object.isRequired,
};
export default ProgressDisplay;