diff --git a/components/eventList/EventList.tsx b/components/eventList/EventList.tsx index 63606f3..39cfb4b 100644 --- a/components/eventList/EventList.tsx +++ b/components/eventList/EventList.tsx @@ -1,46 +1,21 @@ -import React, { useEffect } from "react"; -import { - Text, - Dimensions, - FlatList, - StyleSheet, - View, - Pressable, -} from "react-native"; +import React from "react"; +import { Text, Dimensions, FlatList, StyleSheet, View } from "react-native"; -import { Event, getEvent } from "api/Events"; +import { Event } from "api/Events"; import Colors from "constants/Colors"; import { EventListItem } from "./EventListItem"; import { API } from "api/API"; -import { ArkadText } from "components/StyledText"; -import { MaterialIcons } from "@expo/vector-icons"; -import { FontAwesome } from "@expo/vector-icons"; -import AntDesign from "@expo/vector-icons/AntDesign"; -import Entypo from "@expo/vector-icons/Entypo"; -import RBSheet from "react-native-raw-bottom-sheet"; -import { ArkadButton } from "components/Buttons"; -import { is } from "date-fns/locale"; -import { getTicketForEvent, removeTicket, Ticket } from "api/Tickets"; -import Toast from "react-native-toast-message"; -import { useNavigation } from "@react-navigation/native"; -import QRCode from "react-native-qrcode-svg"; type EventListProps = { events: Event[] | null; onPress: (id: number) => void; - showTickets: boolean; }; const { width, height } = Dimensions.get("window"); -export function EventList({ events, onPress, showTickets }: EventListProps) { - const [isYesButtonDisabled, setYesButtonDisabled] = React.useState(true); - const refRBSheet = React.useRef([]); - const [reload, setReload] = React.useState(false); // State variable to trigger re-render - const [chosenTicket, selectedTicket] = React.useState(); - +export function EventList({ events, onPress }: EventListProps) { if (events?.length == 0) { - return No upcoming events; + return No upcoming events =(; } const getTicketsForEvent = async (event: Event) => { @@ -50,318 +25,34 @@ export function EventList({ events, onPress, showTickets }: EventListProps) { return null; }; - const oddEvent = (index: number) => { - return index % 2 !== 0; - }; - - // Sort the events so that "Career Room" comes first - const sortedEvents = events?.sort((a, b) => { - if (a.name === "Career Room") return -1; - if (b.name === "Career Room") return 1; - return 0; - }); - - const handleCrossPress = () => { - setYesButtonDisabled(true); - refRBSheet.current[0]?.open(); - setTimeout(() => { - setYesButtonDisabled(false); - }, 2000); - }; - - async function deregister(event: Event): Promise { - if (event?.id == undefined) { - return; - } - - const ticket: Ticket | null = await getTicketForEvent(event); - if (ticket == null) { - Toast.show({ - type: "error", - text1: "You are not booked to the event: " + event?.name, - visibilityTime: 5000, - }); - return; - } - - const success = await removeTicket(ticket.id); - console.log("Success: ", success); - if (success) { - refRBSheet.current?.close(); - Toast.show({ - type: "success", - text1: "Successfully unregistered from event: " + event?.name, - visibilityTime: 5000, - }); - setReload(!reload); // Update the state variable to trigger re-render - } - } - - const handleQRPress = async (event: Event) => { - refRBSheet.current[1]?.open(); - const ticket = getTicketForEvent(event); - selectedTicket(await ticket); - }; - - useEffect(() => { - null; - }, [reload]); - return ( id.toString()} - renderItem={({ item: event, index }) => { + renderItem={({ item: event }) => { // Get the ticket information for the current event const ticket_eventid = getTicketsForEvent(event); return ( - - - onPress(event.id)} - ticket_eventid={ticket_eventid} - odd={oddEvent(index)} - /> - - - - - - - - - - {event.capacity === event.ticketCount && ( - - )} - - - - {/* Extra 40% section for orange and light blue boxes */} - {showTickets && ( - - - handleQRPress(event)}> - - - - - - {" "} - - - (refRBSheet.current[1] = ref)} - useNativeDriver={true} - height={height * 0.6} - customStyles={{ - draggableIcon: { - backgroundColor: "transparent", - }, - container: { - backgroundColor: Colors.arkadNavy, - }, - }} - customModalProps={{ - animationType: "fade", - statusBarTranslucent: false, - }} - customAvoidingViewProps={{ - enabled: false, - }} - > - - - - - - - - { - refRBSheet.current[1]?.close(); - selectedTicket(null); - }} - style={{ - width: "75%", - backgroundColor: Colors.arkadTurkos, - paddingBottom: "2%", - }} - > - - - - - - (refRBSheet.current[0] = ref)} - useNativeDriver={true} - height={height * 0.3} - customStyles={{ - draggableIcon: { - backgroundColor: "transparent", - }, - container: { - backgroundColor: Colors.arkadNavy, - }, - }} - customModalProps={{ - animationType: "fade", - statusBarTranslucent: false, - }} - customAvoidingViewProps={{ - enabled: false, - }} - > - - - - {isYesButtonDisabled && ( - null} - style={{ - backgroundColor: Colors.gray, - width: "45%", - }} - > - - - )} - {!isYesButtonDisabled && ( - deregister(event)} - style={{ - backgroundColor: Colors.arkadTurkos, - width: "45%", - }} - > - - - )} - refRBSheet.current[0]?.close()} - style={{ width: "45%" }} - > - - - - - - - - )} + + onPress(event.id)} + ticket_eventid={ticket_eventid} + /> ); }} /> ); } - const styles = StyleSheet.create({ eventBox: { width: width * 0.95, - height: height * 0.3, + height: height * 0.24, backgroundColor: Colors.arkadNavy, - padding: 10, // Adjust padding to align the content - flexDirection: "column", // Default to column layout when showTickets is false - }, - eventBoxWithTickets: { - flexDirection: "row", // Use row layout when showTickets is true - }, - eventItemContainer: { - flex: 1.0, - }, - ticketInfoContainer: { - flex: 0.4, // Take up 40% of the width - justifyContent: "space-between", // Evenly space the boxes - paddingLeft: 5, // Add some padding between the event info and the boxes - }, - QRBox: { - flex: 1, - backgroundColor: Colors.arkadTurkos, - borderColor: Colors.arkadTurkos, - justifyContent: "center", - alignItems: "center", - marginTop: 10, - marginHorizontal: 10, - padding: 16, - borderRadius: 16, - borderWidth: 4, - }, - unregisterBox: { - flex: 1, - backgroundColor: Colors.arkadOrange, - borderColor: Colors.arkadOrange, - justifyContent: "center", - alignItems: "center", - marginTop: 10, - marginHorizontal: 10, - padding: 16, - borderRadius: 16, - borderWidth: 4, }, text: { paddingTop: 40, @@ -369,37 +60,4 @@ const styles = StyleSheet.create({ fontSize: 32, color: Colors.white, }, - eventText: { - paddingLeft: 10, - fontSize: 20, - textAlign: "left", - fontFamily: "main-font-bold", - color: Colors.white, - paddingTop: 10, // Space between event box and event name - }, - infoRow: { - paddingLeft: 10, - flexDirection: "row", - alignItems: "center", - }, - infoText: { - fontSize: 16, - textAlign: "left", - fontFamily: "main-font-bold", - paddingLeft: 10, // Adjust padding to align text properly - }, - qrModalContainer: { - borderRadius: 5, - borderWidth: 4, - padding: 16, - backgroundColor: Colors.white, - borderColor: Colors.arkadTurkos, - }, - qrContainer: {}, - centeredView: { - flex: 1, - justifyContent: "center", - alignItems: "center", - backgroundColor: "transparent", - }, }); diff --git a/components/eventList/EventListItem.tsx b/components/eventList/EventListItem.tsx index ef770e9..fadb489 100644 --- a/components/eventList/EventListItem.tsx +++ b/components/eventList/EventListItem.tsx @@ -19,7 +19,6 @@ type ListedEventItemProps = { itemStyle: ViewStyle; onPress: () => void; ticket_eventid: Promise; - odd: boolean; }; export const EventListItem = ({ @@ -27,7 +26,6 @@ export const EventListItem = ({ itemStyle, onPress, ticket_eventid, - odd, }: ListedEventItemProps) => { const [backgroundColor, setBackgroundColor] = useState<{ backgroundColor: string; @@ -52,37 +50,44 @@ export const EventListItem = ({ }, [ticket_eventid, event.id, event.capacity, event.ticketCount]); return ( - - + + + + + {/* {event.type === 0 && ( + + + + )} */} + + + + {/* Color of box changes depending on status */} + + + + ); }; const styles = StyleSheet.create({ container: { - borderColor: Colors.arkadTurkos, - flex: 1, - justifyContent: "flex-start", - marginTop: 10, - marginHorizontal: 10, - backgroundColor: Colors.arkadTurkos, - padding: 16, - borderRadius: 16, - borderWidth: 4, - }, - containerOdd: { borderColor: Colors.arkadOrange, flex: 1, justifyContent: "flex-start", marginTop: 10, marginHorizontal: 10, - backgroundColor: Colors.arkadOrange, + backgroundColor: Colors.white, padding: 16, borderRadius: 16, borderWidth: 4, diff --git a/components/profileScreen/BookedEventList.tsx b/components/profileScreen/BookedEventList.tsx index e9d5d62..4adae4a 100644 --- a/components/profileScreen/BookedEventList.tsx +++ b/components/profileScreen/BookedEventList.tsx @@ -41,7 +41,6 @@ export const BookedEventList = ({ itemStyle={{ width: windowWidth * 0.6 }} onPress={() => onPress(event.id)} ticket_eventid={ticket_eventid} - odd={false} /> ); diff --git a/package.json b/package.json index fc91500..65fed9f 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "@expo/json-file": "8.2.3", "@expo/vector-icons": "^13.0.0", "@expo/webpack-config": "^18.0.1", - "@gorhom/bottom-sheet": "^4", "@react-native-community/masked-view": "0.1.11", "@react-native-firebase/app": "^18.4.0", "@react-native-firebase/messaging": "^18.4.0", @@ -58,7 +57,6 @@ "react-native-keyboard-aware-scroll-view": "^0.9.5", "react-native-pager-view": "6.1.2", "react-native-qrcode-svg": "^6.1.1", - "react-native-raw-bottom-sheet": "^3.0.0", "react-native-reanimated": "~2.14.4", "react-native-safe-area-context": "4.5.0", "react-native-screens": "~3.20.0", @@ -67,7 +65,6 @@ "react-native-toast-message": "^2.1.6", "react-native-version-check": "^3.4.7", "react-native-web": "~0.18.11", - "reanimated-bottom-sheet": "^1.0.0-alpha.22", "sharp-cli": "^2.1.0", "type-check": "^0.4.0", "webpack-dev-server": "~4.13.1", diff --git a/screens/event/EventDetailsScreen.tsx b/screens/event/EventDetailsScreen.tsx index 6fab980..246773b 100644 --- a/screens/event/EventDetailsScreen.tsx +++ b/screens/event/EventDetailsScreen.tsx @@ -94,7 +94,7 @@ export default function EventDetailsScreen(id: number) { const stopSellingDate = subDays(eventTime, 2); const today = new Date(); return today > stopSellingDate; - }; + } const getEvent = async () => { const event = await API.events.getEvent(id); @@ -157,7 +157,7 @@ export default function EventDetailsScreen(id: number) { temp_ticket = await API.tickets.createTicket(ticketRequest); if (typeof temp_ticket !== "object") { setLoading(false); - return; + return } setTicket(temp_ticket); } @@ -167,11 +167,11 @@ export default function EventDetailsScreen(id: number) { const dateTime = eventTime.split(" "); alert( "Registered to " + - event?.name + - " " + - dateTime[0] + - "\nTakeaway at " + - selectedTime + event?.name + + " " + + dateTime[0] + + "\nTakeaway at " + + selectedTime ); } else { alert("Registered to " + event?.name + " " + event?.date); @@ -343,16 +343,16 @@ export default function EventDetailsScreen(id: number) { "You have booked takeaway at: " + (ticket.takeAwayTime ? (() => { - const timeParts = ticket.takeAwayTime - ?.toString() - .split("T")[1] - .split(":"); - const hours = (parseInt(timeParts[0]) + 2) - .toString() - .padStart(2, "0"); - const minutes = timeParts[1]; - return hours + ":" + minutes; - })() + const timeParts = ticket.takeAwayTime + ?.toString() + .split("T")[1] + .split(":"); + const hours = (parseInt(timeParts[0]) + 2) + .toString() + .padStart(2, "0"); + const minutes = timeParts[1]; + return hours + ":" + minutes; + })() : "") } style={styles.title} diff --git a/screens/event/EventListScreen.tsx b/screens/event/EventListScreen.tsx index fa366a9..bc98a69 100644 --- a/screens/event/EventListScreen.tsx +++ b/screens/event/EventListScreen.tsx @@ -1,10 +1,5 @@ import * as React from "react"; -import { TouchableOpacity, StyleSheet, Dimensions } from "react-native"; -import Animated, { - useSharedValue, - useAnimatedStyle, - withTiming, -} from "react-native-reanimated"; +import { StyleSheet } from "react-native"; import { Text, View } from "components/Themed"; import { StackNavigationProp } from "@react-navigation/stack"; @@ -20,9 +15,6 @@ import { useFocusEffect } from "@react-navigation/native"; import { useCallback } from "react"; import Toast from "react-native-toast-message"; import Colors from "constants/Colors"; -import { TicketType } from "api/Tickets"; - -const { width } = Dimensions.get("window"); type EventsNavigation = { navigation: StackNavigationProp; @@ -36,18 +28,8 @@ export default function EventListScreen({ navigation }: EventsNavigation) { const [upcomingEvents, setUpcomingEvents] = React.useState( null ); - const [showAllEvents, setShowAllEvents] = React.useState(true); - const [showAllTickets, setShowAllTickets] = React.useState(false); + const [showAllEvents, setShowAllEvents] = React.useState(false); const [QRMode, setQRMode] = React.useState(true); - const [eventTickets, setEventTickets] = React.useState(null); - - async function getRegisteredEvents() { - const bookedEvents = await API.events.getBookedNotScannedEvents(); - - setEventTickets( - bookedEvents.filter((event) => event.type == TicketType.CompanyEvent) - ); - } const getEvents = async () => { setLoading(true); @@ -76,13 +58,7 @@ export default function EventListScreen({ navigation }: EventsNavigation) { }; function switchEvents() { - setShowAllEvents(true); - setShowAllTickets(false); - } - - function switchTickets() { - setShowAllEvents(false); - setShowAllTickets(true); + setShowAllEvents(!showAllEvents); } function switchQRMode() { @@ -111,7 +87,6 @@ export default function EventListScreen({ navigation }: EventsNavigation) { useFocusEffect( useCallback(() => { getEvents(); - getRegisteredEvents(); }, []) ); @@ -119,78 +94,17 @@ export default function EventListScreen({ navigation }: EventsNavigation) { return ; } - const TwoButtonSlider = ({ - onEventsPress, - onTicketsPress, - }: { - onEventsPress: () => void; - onTicketsPress: () => void; - }) => { - const [active, setActive] = React.useState("Events"); - const translateX = useSharedValue(0); - - const switchToEvents = () => { - setActive("Events"); - translateX.value = withTiming(0, { duration: 250 }, () => {}); - onEventsPress(); - }; - - const switchToTickets = () => { - setActive("Your Tickets"); - translateX.value = withTiming(width * 0.38, { duration: 250 }, () => {}); - onTicketsPress(); - }; - - const animatedStyle = useAnimatedStyle(() => { - return { - transform: [{ translateX: translateX.value }], - }; - }); - - return ( - - - - Events - - - - - Your Tickets - - - - - ); - }; - return ( - - {/* */} + {/* Admin button for QR Mode */} {role === Role.Administrator && ( )} - @@ -203,34 +117,4 @@ const styles = StyleSheet.create({ alignItems: "center", backgroundColor: Colors.arkadNavy, }, - buttonsContainer: { - flexDirection: "row", - width: "80%", - height: 50, - borderRadius: 25, - borderWidth: 1, - borderColor: Colors.arkadTurkos, - overflow: "hidden", - position: "relative", - marginVertical: 20, - }, - button: { - flex: 1, - justifyContent: "center", - alignItems: "center", - zIndex: 1, - }, - activeText: { - color: Colors.black, - }, - inactiveText: { - color: Colors.white, - }, - slider: { - position: "absolute", - width: "50%", - height: "100%", - backgroundColor: Colors.arkadTurkos, - borderRadius: 25, - }, });