From 032bf13d5a3321ea59fe018ec1445ddc71509ce4 Mon Sep 17 00:00:00 2001 From: Aryan Bhardwaj Date: Wed, 11 Sep 2024 16:36:27 -0500 Subject: [PATCH 1/5] modified formatTime function for UTC --- App.tsx | 3 ++- navigation/DayEvent.tsx | 20 +++++++++++--------- yarn.lock | 21 +++++++++++++++++++++ 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/App.tsx b/App.tsx index 6019b4b..31d9fc8 100644 --- a/App.tsx +++ b/App.tsx @@ -19,7 +19,7 @@ import { State } from "react-native-gesture-handler"; import Toast, { ErrorToast } from "react-native-toast-message"; const prefix = Linking.createURL("/"); -console.log(prefix); +// console.log(prefix); type RootStackParamList = { Login: undefined, @@ -70,6 +70,7 @@ const App = (props) => { if (token) { dispatch(setToken(token)) const decoded = decodeToken(token); + console.log("token", token, "decoded token", decoded); console.log(decoded.roles); if(!decoded.roles.includes('USER')) { diff --git a/navigation/DayEvent.tsx b/navigation/DayEvent.tsx index 10c38a8..3286d0c 100644 --- a/navigation/DayEvent.tsx +++ b/navigation/DayEvent.tsx @@ -4,16 +4,18 @@ import EventCard from "../Components/EventCard"; import Colors from "../constants/Colors"; export const formatTime = (timestamp) => { - const date = new Date(timestamp); // Create a Date object from the timestamp string - let hours = date.getUTCHours(); - let minutes = date.getUTCMinutes(); - const ampm = hours >= 12 ? "PM" : "AM"; // Determine if it's AM or PM + const date = new Date(timestamp); - hours = hours % 12; - hours = hours ? hours : 12; // Handle midnight (0 hours) - let minuteStr = minutes < 10 ? "0" + minutes : minutes; // Add leading zero for single digit minutes + // Format the time for 'America/Chicago' (Central Time) using the Intl API + const options = { + hour: "numeric", + minute: "numeric", + hour12: true, + timeZone: "America/Chicago", + }; + + const formattedTime = new Intl.DateTimeFormat("en-US", options).format(date); - const formattedTime = hours + ":" + minuteStr + ampm; // Concatenate hours, minutes, and AM/PM return formattedTime; }; @@ -29,7 +31,7 @@ const DayEvent = ({ day, events }) => { key={event.id} name={event.name} time={formatTime(event.startTime)} - location={"location"} + location={event.location} description={event.description} points={event.points} /> diff --git a/yarn.lock b/yarn.lock index 203f51e..e4ca4c9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11637,6 +11637,15 @@ expo@latest: languageName: node linkType: hard +"react-icons@npm:^5.3.0": + version: 5.3.0 + resolution: "react-icons@npm:5.3.0" + peerDependencies: + react: "*" + checksum: 3aa5f50e05aafc6d31e0d995fe0d98560069aa88717b24ce8aaa082a7e7b20ca95e1e19d847ed6e52d658a5a30e15826af20d7554bf993a743edd55586db62e3 + languageName: node + linkType: hard + "react-is@npm:^16.12.0 || ^17.0.0 || ^18.0.0, react-is@npm:^18.0.0": version: 18.3.1 resolution: "react-is@npm:18.3.1" @@ -11824,6 +11833,16 @@ expo@latest: languageName: node linkType: hard +"react-native-toast-message@npm:^2.2.0": + version: 2.2.0 + resolution: "react-native-toast-message@npm:2.2.0" + peerDependencies: + react: "*" + react-native: "*" + checksum: b286b8d5ca0f21737c2e0a8e9c2d6dab2c06a3895335aa541c69eeb42d526cc6f3951069e59d8d346d3e6cafb8feaa450c35b0efe7c3d51ff81351d1477e71eb + languageName: node + linkType: hard + "react-native-webview@npm:^13.12.0": version: 13.12.0 resolution: "react-native-webview@npm:13.12.0" @@ -12403,6 +12422,7 @@ expo@latest: jwt-decode: ^4.0.0 lucide-react-native: ^0.381.0 react: 18.2.0 + react-icons: ^5.3.0 react-native: 0.74.2 react-native-gesture-handler: ^2.16.0 react-native-modal: ^13.0.1 @@ -12416,6 +12436,7 @@ expo@latest: react-native-svg-transformer: ^1.5.0 react-native-svg-uri: ^0.0.1 react-native-tab-view: ^3.5.2 + react-native-toast-message: ^2.2.0 react-native-webview: ^13.12.0 react-navigation: ^5.0.0 react-redux: ^9.1.2 From e8c66d0e0cec5e6711b18cd3629a05965f4c9fba Mon Sep 17 00:00:00 2001 From: Aryan Bhardwaj Date: Wed, 11 Sep 2024 21:51:08 -0500 Subject: [PATCH 2/5] fixed spacing for event cards --- Components/CurrentEventCard.tsx | 10 +++++----- components/EventCard.tsx | 9 +++++++-- components/EventModal.tsx | 13 +++++-------- screens/Login.tsx | 2 ++ 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Components/CurrentEventCard.tsx b/Components/CurrentEventCard.tsx index 8ef55b7..70352f2 100644 --- a/Components/CurrentEventCard.tsx +++ b/Components/CurrentEventCard.tsx @@ -15,7 +15,7 @@ import { } from "@expo-google-fonts/kufam"; import CustomModal from "./CustomModal"; // Import the custom modal -// import AppLoading from "expo-app-loading"; +import AppLoading from "expo-app-loading"; import Colors from "../constants/Colors"; import { formatTime } from "../navigation/DayEvent"; @@ -41,9 +41,9 @@ const CurrentEventCard = ({ Kufam_700Bold_Italic, }); - // if (!fontsLoaded) { - // return ; - // } + if (!fontsLoaded) { + return ; + } // Get the current time const currentTime = new Date(); @@ -138,7 +138,7 @@ const styles = StyleSheet.create({ infoItem: { flexDirection: "row", alignItems: "center", - marginHorizontal: 8, + marginRight: 10, }, infoText: { color: Colors.DARK_BLUE, diff --git a/components/EventCard.tsx b/components/EventCard.tsx index a4f21dd..4d1ff2c 100644 --- a/components/EventCard.tsx +++ b/components/EventCard.tsx @@ -47,7 +47,7 @@ const EventCard = ({ name, time, location, description, points }) => { - + {location} @@ -103,6 +103,7 @@ const styles = StyleSheet.create({ marginLeft: 15, marginTop: 30, maxWidth: 320, + // backgroundColor: 'green' }, name: { fontSize: 20, @@ -110,12 +111,16 @@ const styles = StyleSheet.create({ fontFamily: "Kufam_700Bold", }, info: { + flex: 1, flexDirection: "row", + // backgroundColor: 'red', + flexWrap: 'wrap' }, infoItem: { flexDirection: "row", alignItems: "center", - marginHorizontal: 8, + marginRight: 10, + // backgroundColor: 'purple' }, infoText: { color: Colors.DARK_BLUE, diff --git a/components/EventModal.tsx b/components/EventModal.tsx index 2bec949..6c3395e 100644 --- a/components/EventModal.tsx +++ b/components/EventModal.tsx @@ -28,11 +28,6 @@ const EventModal = ({ title, location, time, points, description }) => { {time} - {/* - - {points} pts - - */} = ({ navigation }) => { }, [token, navigation]); const handleLoginPress = () => { + navigation.navigate("Main"); WebBrowser.openAuthSessionAsync( `${authUrl}?redirect_uri=${redirectURL}`, redirectURL ) .then((result) => { if (result.type === "success") { + console.log("opening url for log in ") Linking.openURL(result.url); } }) From 453a26bc448bc14a07abe58e5f51b759cbc2fc44 Mon Sep 17 00:00:00 2001 From: Aryan Bhardwaj Date: Wed, 11 Sep 2024 21:59:05 -0500 Subject: [PATCH 3/5] modified margins for event cards --- Components/CurrentEventCard.tsx | 1 + components/EventCard.tsx | 3 ++- components/EventModal.tsx | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Components/CurrentEventCard.tsx b/Components/CurrentEventCard.tsx index 70352f2..c875551 100644 --- a/Components/CurrentEventCard.tsx +++ b/Components/CurrentEventCard.tsx @@ -134,6 +134,7 @@ const styles = StyleSheet.create({ }, info: { flexDirection: "row", + marginTop: 2 }, infoItem: { flexDirection: "row", diff --git a/components/EventCard.tsx b/components/EventCard.tsx index 4d1ff2c..20dedd7 100644 --- a/components/EventCard.tsx +++ b/components/EventCard.tsx @@ -114,7 +114,8 @@ const styles = StyleSheet.create({ flex: 1, flexDirection: "row", // backgroundColor: 'red', - flexWrap: 'wrap' + flexWrap: 'wrap', + marginTop: 2 }, infoItem: { flexDirection: "row", diff --git a/components/EventModal.tsx b/components/EventModal.tsx index 6c3395e..9e8facb 100644 --- a/components/EventModal.tsx +++ b/components/EventModal.tsx @@ -73,7 +73,7 @@ const styles = StyleSheet.create({ infoItem: { flexDirection: "row", alignItems: "center", - marginTop: 10, + marginTop: 5, marginRight: 8, // backgroundColor: 'red' }, From 11ace420423bf6a5105d1b7395be3f646d254d26 Mon Sep 17 00:00:00 2001 From: Aryan Bhardwaj Date: Wed, 11 Sep 2024 23:01:47 -0500 Subject: [PATCH 4/5] fixed atrium location --- Components/CurrentEventCard.tsx | 6 +++--- navigation/DayEvent.tsx | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Components/CurrentEventCard.tsx b/Components/CurrentEventCard.tsx index c875551..322e914 100644 --- a/Components/CurrentEventCard.tsx +++ b/Components/CurrentEventCard.tsx @@ -18,7 +18,7 @@ import CustomModal from "./CustomModal"; // Import the custom modal import AppLoading from "expo-app-loading"; import Colors from "../constants/Colors"; -import { formatTime } from "../navigation/DayEvent"; +import { formatTime, formatLocation } from "../navigation/DayEvent"; import EvilIcons from "@expo/vector-icons/EvilIcons"; @@ -70,7 +70,7 @@ const CurrentEventCard = ({ - {location} + {formatLocation(location)} @@ -98,7 +98,7 @@ const CurrentEventCard = ({ visible={showModal} onClose={() => setShowModal(false)} title={name} - location={location} + location={formatLocation(location)} time={formatTime(start)} points={points} description={description} diff --git a/navigation/DayEvent.tsx b/navigation/DayEvent.tsx index 3286d0c..c5b7e7e 100644 --- a/navigation/DayEvent.tsx +++ b/navigation/DayEvent.tsx @@ -19,6 +19,14 @@ export const formatTime = (timestamp) => { return formattedTime; }; +export const formatLocation = (location) => { + if (location.includes("Atrium")) { + const locationWords = location.split(' '); + return `${locationWords[1]} ${locationWords[2]}` + } + return location +} + const DayEvent = ({ day, events }) => { return ( @@ -31,7 +39,7 @@ const DayEvent = ({ day, events }) => { key={event.id} name={event.name} time={formatTime(event.startTime)} - location={event.location} + location={formatLocation(event.location)} description={event.description} points={event.points} /> From 653978a7f670b9328fa927fd686c132812fd03ba Mon Sep 17 00:00:00 2001 From: Aryan Bhardwaj Date: Wed, 11 Sep 2024 23:36:47 -0500 Subject: [PATCH 5/5] ready for merge --- screens/Login.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/screens/Login.tsx b/screens/Login.tsx index d1f7746..00698df 100644 --- a/screens/Login.tsx +++ b/screens/Login.tsx @@ -35,7 +35,6 @@ const Login: React.FC = ({ navigation }) => { }, [token, navigation]); const handleLoginPress = () => { - navigation.navigate("Main"); WebBrowser.openAuthSessionAsync( `${authUrl}?redirect_uri=${redirectURL}`, redirectURL