diff --git a/App.tsx b/App.tsx index 31d9fc8..dc9983e 100644 --- a/App.tsx +++ b/App.tsx @@ -68,7 +68,6 @@ const App = (props) => { const searchParams = new URL(event.url).searchParams; const token = searchParams.get('token'); if (token) { - dispatch(setToken(token)) const decoded = decodeToken(token); console.log("token", token, "decoded token", decoded); console.log(decoded.roles); @@ -83,6 +82,7 @@ const App = (props) => { setDeepLinkHandled(false); } else { console.log('dispatched') + dispatch(setToken(token)); dispatch(setRoles(decoded.roles)); setDeepLinkHandled(true); } diff --git a/api/postCheckIn.tsx b/api/postCheckIn.tsx index 52cc76d..9ed3d2e 100644 --- a/api/postCheckIn.tsx +++ b/api/postCheckIn.tsx @@ -3,7 +3,7 @@ import axios from "axios"; export const postCheckIn = async(token, eventId, qrCode) => { const payload = { eventId, qrCode } try { - const response = await axios.post('https://api.reflectionsprojections.org/staff/scan/', payload, { + const response = await axios.post('https://api.reflectionsprojections.org/scan/staff/', payload, { headers: { Authorization: token } diff --git a/navigation/Navigation.tsx b/navigation/Navigation.tsx index 1cd5fee..e50a2e7 100644 --- a/navigation/Navigation.tsx +++ b/navigation/Navigation.tsx @@ -64,7 +64,7 @@ const AppNavigator: React.FC = () => { case "AdminScanner": return ( diff --git a/screens/Login.tsx b/screens/Login.tsx index 00698df..e21d690 100644 --- a/screens/Login.tsx +++ b/screens/Login.tsx @@ -12,6 +12,7 @@ import { NavigationProp, ParamListBase } from "@react-navigation/native"; import { useAppSelector } from "../redux/hooks"; import { RootState } from "../redux/store"; import Colors from "../constants/Colors"; +import { useState } from "react"; import ScreenImage from "../assets/SVGs/login/LoginScreen.svg"; @@ -27,28 +28,32 @@ const { width, height } = Dimensions.get("window"); const Login: React.FC = ({ navigation }) => { const token = useAppSelector((state: RootState) => state.token); const roles = useAppSelector((state: RootState) => state.roles); + const [loggedIn, setLoggedIn] = useState(false); useEffect(() => { if (token && roles.includes('USER')) { - navigation.navigate("Main"); + setLoggedIn(true); } - }, [token, navigation]); + }, [token, roles, navigation]); const handleLoginPress = () => { - WebBrowser.openAuthSessionAsync( - `${authUrl}?redirect_uri=${redirectURL}`, - redirectURL - ) - .then((result) => { - if (result.type === "success") { - console.log("opening url for log in ") - Linking.openURL(result.url); - } - }) - .catch((err) => { - console.error("Failed to open URL:", err.message); - alert("Failed to open URL"); - }); + if(loggedIn) { + navigation.navigate("Main"); + } else { + WebBrowser.openAuthSessionAsync( + `${authUrl}?redirect_uri=${redirectURL}`, + redirectURL + ) + .then((result) => { + if (result.type === "success") { + Linking.openURL(result.url); + } + }) + .catch((err) => { + console.error("Failed to open URL:", err.message); + alert("Failed to open URL"); + }); + } }; return ( diff --git a/screens/Profile.tsx b/screens/Profile.tsx index ef96c4b..2d21880 100644 --- a/screens/Profile.tsx +++ b/screens/Profile.tsx @@ -128,7 +128,7 @@ const Profile: React.FC = () => { - {attendee && qrcode && + {(attendee && qrcode) ? ( {foodWave == 1 ? ( @@ -145,7 +145,12 @@ const Profile: React.FC = () => { {attendee.name} - } + ): + ( + + Please register on the R|P Website! + + )} ); }; diff --git a/screens/Shop.tsx b/screens/Shop.tsx index 9eebba2..be1faee 100644 --- a/screens/Shop.tsx +++ b/screens/Shop.tsx @@ -47,7 +47,7 @@ const Shop: React.FC = () => { Your Points: x{userPoints} @@ -119,6 +119,7 @@ const styles = StyleSheet.create({ alignItems: "center", justifyContent: "center", marginBottom: 20, + }, points: { fontSize: 17, @@ -132,10 +133,16 @@ const styles = StyleSheet.create({ fontFamily: "PressStart2P_400Regular", color: Colors.YELLOW, }, + tokenImage2: { + width: 30, + height: 30, + marginRight: 5, + }, tokenImage: { width: 30, height: 30, marginRight: 5, + marginLeft: 10 }, photoContainer: { flex: 1,