Add show old switch

This commit is contained in:
Regalijan 2024-04-01 18:19:58 -04:00
parent ed331a6a56
commit c968384827
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -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,7 +342,10 @@ export default function () {
</ModalContent>
</Modal>
<VStack spacing="8">
{eventData.map((event) => {
{eventData
.map((event) => {
if (!showOld && event.day < new Date().getUTCDate()) return;
const eventCreatorName = members.find(
(member) => member.id === event.created_by,
)?.name;
@ -421,6 +428,7 @@ export default function () {
) : null}
{can_approve &&
!event.pending &&
event.approved &&
event.performed_at &&
event.type === "rotw" &&
!event.answered_at ? (
@ -465,9 +473,23 @@ export default function () {
</CardFooter>
</Card>
);
})}
})
.filter((e) => e)}
</VStack>
<VStack alignItems="start" gap="8px" my="16px">
<FormControl>
<FormLabel
htmlFor="show-old-events"
mb="0"
onChange={() => {
setShowOld(true);
setEventData([...eventData]);
}}
>
Show old events
</FormLabel>
<Switch id="show-old-events" />
</FormControl>
<Link color="#646cff" href="/book-event" mt="16px" target="_blank">
Book an Event
</Link>