Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"@chakra-ui/icons": "^2.0.17",
"@chakra-ui/react": "^2.5.1",
"@codeday/topo": "^9.1.1",
"@codeday/topocons": "^1.5.0",
"@emotion/react": "^11.0.0",
"@emotion/styled": "^11.0.0",
"@codeday/topocons": "^1.5.0",
"@emotion/utils": "1.0.0",
"@headwayapp/react-widget": "^0.0.4",
"@rjsf/antd": "^3.1.0",
Expand Down
40 changes: 18 additions & 22 deletions src/components/CheckinCounter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function CheckinCounter({ event, ...props }) {
const fetch = useFetcher();
const { data, isValidating } = useSwr([getCheckinCountsQuery, { data: { id: event.id } }], fetch, { revalidateOnFocus: true, refreshInterval: 15*1000 });

if (!data?.clear?.event) return <></>;
if (!data || !data.clear || !data.clear.event) return <></>;
const { notCheckedInStudents, checkedInStudents, notCheckedInStaff, checkedInStaff, venue } = data.clear.event;
const total = notCheckedInStudents.length + checkedInStudents.length + notCheckedInStaff.length + checkedInStaff.length;
const absoluteTotal = Math.max(total, venue.capacity);
Expand All @@ -16,35 +16,31 @@ export default function CheckinCounter({ event, ...props }) {
return (
<Box {...props}>
<Text fontSize="sm" textTransform="uppercase" fontWeight="bold">Here Now</Text>
<Grid templateColumns="1fr 3em">
<Box>
<Box w="100%" textAlign="left">
<Grid templateColumns="">
<Box w="full">
<Box w="100%" textAlign="left" display="flex">
{(checkedInStudents.length > 0 || notCheckedInStudents.length > 0) && (
<>
<Box textAlign="center" borderWidth={1} borderColor="green.600" bgColor="green.600" display="inline-block" w={`${Math.floor((checkedInStudents.length/absoluteTotal)*100)}%`}>{checkedInStudents.length}</Box>
<Box textAlign="center" borderWidth={1} borderColor="green.100" bgColor="green.100" display="inline-block" w={`${Math.floor((notCheckedInStudents.length/absoluteTotal)*100)}%`}>{notCheckedInStudents.length}</Box>
<Box textAlign="center" borderWidth={1} borderColor="green.600" bgColor="green.600" w={`${Math.floor((checkedInStudents.length/absoluteTotal)*100)}%`}>{checkedInStudents.length}</Box>
<Box textAlign="center" borderWidth={1} borderColor="green.100" bgColor="green.100" w={`${Math.floor((notCheckedInStudents.length/absoluteTotal)*100)}%`}>{notCheckedInStudents.length}</Box>
</>
)}
{(checkedInStaff.length > 0 || notCheckedInStaff.length > 0) && (
<>
<Box textAlign="center" borderWidth={1} borderColor="red.600" bgColor="red.600" display="inline-block" w={`${Math.floor((checkedInStaff.length/absoluteTotal)*100)}%`}>{checkedInStaff.length}</Box>
<Box textAlign="center" borderWidth={1} borderColor="red.100" bgColor="red.100" display="inline-block" w={`${Math.floor((notCheckedInStaff.length/absoluteTotal)*100)}%`}>{notCheckedInStaff.length}</Box>
</>
)}
{venue.capacity > total && <Box textAlign="center" borderWidth={1} display="inline-block" w={`${(Math.floor((Math.max(0, venue.capacity - total)/venue.capacity) * 100)) - 2}%`}>{venue.capacity - total}</Box>}
{venue.capacity > total && <Box textAlign="center" borderWidth={1} w={`${Math.floor((Math.max(0, venue.capacity - total)/absoluteTotal)*100)}%`}>{venue.capacity - total}</Box>}
</Box>
<Box w="100%" textTransform="lowercase" fontSize="sm">
<Box w="100%" textTransform="lowercase" fontSize="xs" textAlign="center">
{(checkedInStudents.length > 0 || notCheckedInStudents.length > 0) && (
<Box color="green.600" display="inline-block" w={`${((checkedInStudents.length + notCheckedInStudents.length)/absoluteTotal)*100}%`}>
Students ({Math.floor(checkedInStudents.length/(checkedInStudents.length + notCheckedInStudents.length) * 100)}% here)
</Box>
)}
{(checkedInStaff.length > 0 || notCheckedInStaff.length > 0) && (
<Box color="red.600" display="inline-block" w={`${((checkedInStaff.length + notCheckedInStaff.length)/absoluteTotal)*100}%`}>
Staff ({Math.floor(checkedInStaff.length/(checkedInStaff.length + notCheckedInStaff.length) * 100)}% here)
<Box w="100%" display="flex">
<Box flex={`0 0 ${Math.floor((checkedInStudents.length/absoluteTotal)*100)}%`} color="green.600" textAlign="center">
Students ({Math.floor(checkedInStudents.length/(checkedInStudents.length + notCheckedInStudents.length) * 100)}% here)
</Box>
<Box flex={`0 0 ${Math.floor((notCheckedInStudents.length/absoluteTotal)*100)}%`} color="green.600" textAlign="center">
signed up ({Math.floor(notCheckedInStudents.length/(checkedInStudents.length + notCheckedInStudents.length) * 100)}% not here)
</Box>
{venue.capacity > total && <Box flex="1" color="gray.600" textAlign="center">
open ({100-Math.floor(((checkedInStudents.length + checkedInStaff.length + notCheckedInStudents.length + notCheckedInStaff.length) / venue.capacity)*100)}% of capacity)
</Box>}
</Box>
)}
{venue.capacity > total && <Box color="gray.600" display="inline-block">Open</Box>}
</Box>
</Box>
<Box>{isValidating && <Spinner />}</Box>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/events/[event]/tickets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ export default function Tickets({ event }) {
</Text>
<Text>
Staff:&nbsp;
{tickets.filter((ticket) => ticket.type != "STUDENT").length}
{tickets.filter((ticket) => ticket.type != "STUDENT").length}{" "}
({tickets.filter((ticket) => ticket.type != "STUDENT" && ticket.checkedIn && !ticket.checkedOut).length} here)
</Text>
</HStack>
<TicketSurveyBreakdown tickets={tickets || []} />
Expand Down
Loading