-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathEventStatsTable.jsx
More file actions
54 lines (51 loc) · 1.68 KB
/
Copy pathEventStatsTable.jsx
File metadata and controls
54 lines (51 loc) · 1.68 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
import { Table } from "flowbite-react";
import Link from "next/link";
import PropTypes from "prop-types";
const convertTime = (time) => {
let [hour, min] = time.split(":");
let hours = parseInt(hour);
let suffix = time[-2];
if (!(suffix in ["pm", "am", "PM", "AM"])) {
suffix = hours > 11 ? "pm" : "am";
}
hours = ((hours + 11) % 12) + 1;
return hours.toString() + ":" + min + suffix;
};
const EventStatsTable = ({ stats, isVolunteer }) => {
return (
<Table style={{ width: "100%", maxWidth: "none" }} striped={true}>
<Table.Head>
<Table.HeadCell>Event Name</Table.HeadCell>
<Table.HeadCell>Date</Table.HeadCell>
<Table.HeadCell>Time</Table.HeadCell>
<Table.HeadCell>Attendance</Table.HeadCell>
<Table.HeadCell>Hours</Table.HeadCell>
</Table.Head>
<Table.Body>
{isVolunteer === false &&
stats.map((stat) => (
<Table.Row key={stat._id}>
<Table.Cell>
<a className="text-primaryColor" href={`events/${stat._id}`}>
{stat.title}
</a>
</Table.Cell>
<Table.Cell>{stat.date.substring(0, 10)}</Table.Cell>
<Table.Cell>
{convertTime(stat.startTime)} - {convertTime(stat.endTime)}{" "}
</Table.Cell>
<Table.Cell>{stat.attendance}</Table.Cell>
<Table.Cell>{stat.hours}</Table.Cell>
</Table.Row>
))}
</Table.Body>
</Table>
);
};
EventStatsTable.propTypes = {
stats: PropTypes.Array,
isVolunteer: PropTypes.Boolean,
onDeleteClicked: PropTypes.func,
onEditClicked: PropTypes.func,
};
export default EventStatsTable;