diff --git a/app/routes/events-team.tsx b/app/routes/events-team.tsx index 138716b..c987012 100644 --- a/app/routes/events-team.tsx +++ b/app/routes/events-team.tsx @@ -6,6 +6,8 @@ import { CardFooter, Container, Flex, + FormControl, + FormLabel, Heading, Link, Modal, @@ -17,6 +19,7 @@ import { ModalOverlay, Stack, StackDivider, + Switch, Text, useDisclosure, useToast, @@ -102,6 +105,7 @@ export default function () { } = useDisclosure(); const toast = useToast(); const [selectedEvent, setSelectedEvent] = useState(""); + const [showOld, setShowOld] = useState(false); async function decide(approved: boolean, eventId: string) { const decisionResp = await fetch( @@ -338,136 +342,154 @@ export default function () { - {eventData.map((event) => { - const eventCreatorName = members.find( - (member) => member.id === event.created_by, - )?.name; - - const eventColors: { [k: string]: string } = { - fotd: "cyan", - gamenight: "blue", - rotw: "magenta", - qotd: "#9900FF", - }; - - return ( - - - } spacing="4"> - - Date - - {event.year}-{event.month}-{event.day} - - - - Event Type - - {event.type.toUpperCase()} - - - - Event Details - - {event.details} - - - {event.type === "rotw" ? ( + {eventData + .map((event) => { + if (!showOld && event.day < new Date().getUTCDate()) return; + + const eventCreatorName = members.find( + (member) => member.id === event.created_by, + )?.name; + + const eventColors: { [k: string]: string } = { + fotd: "cyan", + gamenight: "blue", + rotw: "magenta", + qotd: "#9900FF", + }; + + return ( + + + } spacing="4"> - Riddle Answer + Date - {event.answer} + {event.year}-{event.month}-{event.day} - ) : null} - - Host - - {eventCreatorName - ? `${eventCreatorName} (${event.created_by})` - : event.created_by} - - - - - - - {can_approve && event.pending ? ( - <> + + Event Type + + {event.type.toUpperCase()} + + + + Event Details + + {event.details} + + + {event.type === "rotw" ? ( + + Riddle Answer + + {event.answer} + + + ) : null} + + Host + + {eventCreatorName + ? `${eventCreatorName} (${event.created_by})` + : event.created_by} + + + + + + + {can_approve && event.pending ? ( + <> + + + + ) : null} + {can_approve && !event.pending && !event.performed_at ? ( + + ) : null} + {can_approve && + !event.pending && + event.approved && + event.performed_at && + event.type === "rotw" && + !event.answered_at ? ( + ) : null} + {can_approve && + event.approved && + event.type === "gamenight" && + event.performed_at && + !event.reached_minimum_player_count ? ( - - ) : null} - {can_approve && !event.pending && !event.performed_at ? ( - - ) : null} - {can_approve && - !event.pending && - event.performed_at && - event.type === "rotw" && - !event.answered_at ? ( - - ) : null} - {can_approve && - event.approved && - event.type === "gamenight" && - event.performed_at && - !event.reached_minimum_player_count ? ( - - ) : null} - - - Status:{" "} - {event.pending - ? "Pending" - : event.approved - ? "Approved" - : "Denied"} - - - - - ); - })} + ) : null} + + + Status:{" "} + {event.pending + ? "Pending" + : event.approved + ? "Approved" + : "Denied"} + + + + + ); + }) + .filter((e) => e)} + + { + setShowOld(true); + setEventData([...eventData]); + }} + > + Show old events + + + Book an Event