Skip to content

Commit

Permalink
Completed transition to using the API client! Also reformatted files
Browse files Browse the repository at this point in the history
  • Loading branch information
malee31 committed Jan 1, 2025
1 parent 6165330 commit 83208d5
Show file tree
Hide file tree
Showing 15 changed files with 308 additions and 309 deletions.
2 changes: 1 addition & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ GET /user - Public user data (Auth header)
Response:
- (200) User object is returned. Not in a `user` key

Errors:
Errors:
- 404 `user_not_found` when the user with the corresponding auth header does not exist

POST /user - Add user (Admin auth header)
Expand Down
174 changes: 87 additions & 87 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,89 +1,89 @@
{
"expo": {
"name": "CardinalHours App",
"description": "Team4159 CardinalBotics Sign-In App",
"slug": "ReactNative-CardinalBoticsApp",
"privacy": "unlisted",
"version": "4.1.0",
"platforms": [
"ios",
"android",
"web"
],
"icon": "./assets/icon.png",
"orientation": "portrait",
"primaryColor": "#7D1120",
"backgroundColor": "#FFFFFF",
"splash": {
"image": "./assets/favicon.png",
"resizeMode": "contain",
"backgroundColor": "#7D1120",
"userInterfaceStyle": "automatic"
},
"notification": {
"icon": "./assets/icon.png",
"color": "#000000",
"iosDisplayInForeground": false,
"androidCollapsedTitle": "collapse"
},
"updates": {
"fallbackToCacheTimeout": 15000,
"url": "https://u.expo.dev/9ce752ec-a876-496e-b880-d911e7fd678e"
},
"assetBundlePatterns": [
"**/*"
],
"android": {
"package": "com.team4159.cardinalboticsapp",
"versionCode": 5,
"adaptiveIcon": {
"foregroundImage": "./assets/adaptable_icon_foreground.png",
"backgroundColor": "#7D1120"
},
"icon": "./assets/maskable_icon.png"
},
"androidStatusBar": {
"barStyle": "dark-content",
"hidden": true,
"translucent": true
},
"androidNavigationBar": {
"barStyle": "dark-content"
},
"ios": {
"bundleIdentifier": "com.team4159.cardinalboticsapp",
"supportsTablet": true,
"buildNumber": "4.1.0"
},
"web": {
"bundler": "metro",
"favicon": "./assets/favicon.png",
"name": "CardinalHours Web",
"shortName": "CardinalHours",
"startUrl": "/ReactNativeCardinalBoticsApp/",
"scope": "/ReactNativeCardinalBoticsApp/",
"lang": "en-US",
"themeColor": "#FFFFFF",
"description": "Team4159 CardinalBotics Sign-In Web App",
"orientation": "portrait",
"backgroundColor": "#FFFFFF",
"splash": {
"image": "./assets/favicon.png",
"resizeMode": "contain",
"backgroundColor": "#7D1120",
"userInterfaceStyle": "automatic"
}
},
"extra": {
"eas": {
"projectId": "9ce752ec-a876-496e-b880-d911e7fd678e"
}
},
"runtimeVersion": {
"policy": "appVersion"
},
"experiments": {
"baseUrl": "/ReactNativeCardinalBoticsApp"
}
}
"expo": {
"name": "CardinalHours App",
"description": "Team4159 CardinalBotics Sign-In App",
"slug": "ReactNative-CardinalBoticsApp",
"privacy": "unlisted",
"version": "4.1.0",
"platforms": [
"ios",
"android",
"web"
],
"icon": "./assets/icon.png",
"orientation": "portrait",
"primaryColor": "#7D1120",
"backgroundColor": "#FFFFFF",
"splash": {
"image": "./assets/favicon.png",
"resizeMode": "contain",
"backgroundColor": "#7D1120",
"userInterfaceStyle": "automatic"
},
"notification": {
"icon": "./assets/icon.png",
"color": "#000000",
"iosDisplayInForeground": false,
"androidCollapsedTitle": "collapse"
},
"updates": {
"fallbackToCacheTimeout": 15000,
"url": "https://u.expo.dev/9ce752ec-a876-496e-b880-d911e7fd678e"
},
"assetBundlePatterns": [
"**/*"
],
"android": {
"package": "com.team4159.cardinalboticsapp",
"versionCode": 5,
"adaptiveIcon": {
"foregroundImage": "./assets/adaptable_icon_foreground.png",
"backgroundColor": "#7D1120"
},
"icon": "./assets/maskable_icon.png"
},
"androidStatusBar": {
"barStyle": "dark-content",
"hidden": true,
"translucent": true
},
"androidNavigationBar": {
"barStyle": "dark-content"
},
"ios": {
"bundleIdentifier": "com.team4159.cardinalboticsapp",
"supportsTablet": true,
"buildNumber": "4.1.0"
},
"web": {
"bundler": "metro",
"favicon": "./assets/favicon.png",
"name": "CardinalHours Web",
"shortName": "CardinalHours",
"startUrl": "/ReactNativeCardinalBoticsApp/",
"scope": "/ReactNativeCardinalBoticsApp/",
"lang": "en-US",
"themeColor": "#FFFFFF",
"description": "Team4159 CardinalBotics Sign-In Web App",
"orientation": "portrait",
"backgroundColor": "#FFFFFF",
"splash": {
"image": "./assets/favicon.png",
"resizeMode": "contain",
"backgroundColor": "#7D1120",
"userInterfaceStyle": "automatic"
}
},
"extra": {
"eas": {
"projectId": "9ce752ec-a876-496e-b880-d911e7fd678e"
}
},
"runtimeVersion": {
"policy": "appVersion"
},
"experiments": {
"baseUrl": "/ReactNativeCardinalBoticsApp"
}
}
}
50 changes: 25 additions & 25 deletions assets/web-privacy-policy.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta httpequiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1.00001,viewport-fit=cover">
<meta content="IE=edge" httpequiv="X-UA-Compatible">
<meta content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1.00001,viewport-fit=cover" name="viewport">
<title>Privacy Policy</title>
<meta name="theme-color" content="#FFFFFF">
<meta name="description" content="Team4159 CardinalBotics Sign-In App Privacy Policy">
<link rel="manifest" href="/ReactNativeCardinalBoticsApp/manifest.json">
<link rel="icon" type="image/png" sizes="16x16" href="/ReactNativeCardinalBoticsApp/favicon-16.png">
<link rel="icon" type="image/png" sizes="32x32" href="/ReactNativeCardinalBoticsApp/favicon-32.png">
<link rel="shortcut icon" href="/ReactNativeCardinalBoticsApp/favicon.ico">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<link rel="apple-touch-icon" sizes="180x180" href="/ReactNativeCardinalBoticsApp/pwa/apple-touch-icon/apple-touch-icon-180.png">
<link rel="apple-touch-startup-image" media="screen and (device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="/ReactNativeCardinalBoticsApp/pwa/apple-touch-startup-image/apple-touch-startup-image-640x1136.png">
<link rel="apple-touch-startup-image" media="screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)" href="/ReactNativeCardinalBoticsApp/pwa/apple-touch-startup-image/apple-touch-startup-image-1242x2688.png">
<link rel="apple-touch-startup-image" media="screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="/ReactNativeCardinalBoticsApp/pwa/apple-touch-startup-image/apple-touch-startup-image-828x1792.png">
<link rel="apple-touch-startup-image" media="screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)" href="/ReactNativeCardinalBoticsApp/pwa/apple-touch-startup-image/apple-touch-startup-image-1125x2436.png">
<link rel="apple-touch-startup-image" media="screen and (device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)" href="/ReactNativeCardinalBoticsApp/pwa/apple-touch-startup-image/apple-touch-startup-image-1242x2208.png">
<link rel="apple-touch-startup-image" media="screen and (device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="/ReactNativeCardinalBoticsApp/pwa/apple-touch-startup-image/apple-touch-startup-image-750x1334.png">
<link rel="apple-touch-startup-image" media="screen and (device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="/ReactNativeCardinalBoticsApp/pwa/apple-touch-startup-image/apple-touch-startup-image-2048x2732.png">
<link rel="apple-touch-startup-image" media="screen and (device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="/ReactNativeCardinalBoticsApp/pwa/apple-touch-startup-image/apple-touch-startup-image-1668x2388.png">
<link rel="apple-touch-startup-image" media="screen and (device-width: 834px) and (device-height: 1112px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="/ReactNativeCardinalBoticsApp/pwa/apple-touch-startup-image/apple-touch-startup-image-1668x2224.png">
<link rel="apple-touch-startup-image" media="screen and (device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="/ReactNativeCardinalBoticsApp/pwa/apple-touch-startup-image/apple-touch-startup-image-1536x2048.png">
<meta content="#FFFFFF" name="theme-color">
<meta content="Team4159 CardinalBotics Sign-In App Privacy Policy" name="description">
<link href="/ReactNativeCardinalBoticsApp/manifest.json" rel="manifest">
<link href="/ReactNativeCardinalBoticsApp/favicon-16.png" rel="icon" sizes="16x16" type="image/png">
<link href="/ReactNativeCardinalBoticsApp/favicon-32.png" rel="icon" sizes="32x32" type="image/png">
<link href="/ReactNativeCardinalBoticsApp/favicon.ico" rel="shortcut icon">
<meta content="yes" name="mobile-web-app-capable">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="yes" name="apple-touch-fullscreen">
<link href="/ReactNativeCardinalBoticsApp/pwa/apple-touch-icon/apple-touch-icon-180.png" rel="apple-touch-icon" sizes="180x180">
<link href="/ReactNativeCardinalBoticsApp/pwa/apple-touch-startup-image/apple-touch-startup-image-640x1136.png" media="screen and (device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" rel="apple-touch-startup-image">
<link href="/ReactNativeCardinalBoticsApp/pwa/apple-touch-startup-image/apple-touch-startup-image-1242x2688.png" media="screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)" rel="apple-touch-startup-image">
<link href="/ReactNativeCardinalBoticsApp/pwa/apple-touch-startup-image/apple-touch-startup-image-828x1792.png" media="screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" rel="apple-touch-startup-image">
<link href="/ReactNativeCardinalBoticsApp/pwa/apple-touch-startup-image/apple-touch-startup-image-1125x2436.png" media="screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)" rel="apple-touch-startup-image">
<link href="/ReactNativeCardinalBoticsApp/pwa/apple-touch-startup-image/apple-touch-startup-image-1242x2208.png" media="screen and (device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)" rel="apple-touch-startup-image">
<link href="/ReactNativeCardinalBoticsApp/pwa/apple-touch-startup-image/apple-touch-startup-image-750x1334.png" media="screen and (device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" rel="apple-touch-startup-image">
<link href="/ReactNativeCardinalBoticsApp/pwa/apple-touch-startup-image/apple-touch-startup-image-2048x2732.png" media="screen and (device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" rel="apple-touch-startup-image">
<link href="/ReactNativeCardinalBoticsApp/pwa/apple-touch-startup-image/apple-touch-startup-image-1668x2388.png" media="screen and (device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" rel="apple-touch-startup-image">
<link href="/ReactNativeCardinalBoticsApp/pwa/apple-touch-startup-image/apple-touch-startup-image-1668x2224.png" media="screen and (device-width: 834px) and (device-height: 1112px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" rel="apple-touch-startup-image">
<link href="/ReactNativeCardinalBoticsApp/pwa/apple-touch-startup-image/apple-touch-startup-image-1536x2048.png" media="screen and (device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" rel="apple-touch-startup-image">

<style>
[data-custom-class="body"], [data-custom-class="body"] * {
Expand Down Expand Up @@ -169,7 +169,7 @@
Visit our website

at
<span class="question"><a href="https://designedbymarvin.com/ReactNativeCardinalBoticsApp/" target="_blank" data-custom-class="link">https://designedbymarvin.com/ReactNativeCardinalBoticsApp/</a></span>
<span class="question"><a data-custom-class="link" href="https://designedbymarvin.com/ReactNativeCardinalBoticsApp/" target="_blank">https://designedbymarvin.com/ReactNativeCardinalBoticsApp/</a></span>
<span style="font-size: 15px;">
<span style="color: rgb(89, 89, 89);">
<span data-custom-class="body_text">
Expand Down Expand Up @@ -395,7 +395,7 @@
<strong>How do you exercise your rights?</strong> The easiest way to exercise your rights is by filling out our data subject request form available

here:
<span class="question"><a href="https://www.team4159.org/contact-us/" target="_blank" data-custom-class="link">https://www.team4159.org/contact-us/</a></span>
<span class="question"><a data-custom-class="link" href="https://www.team4159.org/contact-us/" target="_blank">https://www.team4159.org/contact-us/</a></span>
<span class="else-block"></span>
, or by contacting us. We will consider and act upon any request in accordance with applicable data protection laws.
</span>
Expand Down Expand Up @@ -2590,7 +2590,7 @@
</span>
<span data-custom-class="body_text">
visit:
<span class="question"><a href="https://www.team4159.org/contact-us/" target="_blank" data-custom-class="link">https://www.team4159.org/contact-us/</a></span>
<span class="question"><a data-custom-class="link" href="https://www.team4159.org/contact-us/" target="_blank">https://www.team4159.org/contact-us/</a></span>
<span class="else-block"></span>
</span>
</span>
Expand Down
2 changes: 1 addition & 1 deletion components/pages/Admin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useRef, useState } from "react";
import { StyleSheet, View, Text, Keyboard } from "react-native";
import { Keyboard, StyleSheet, Text, View } from "react-native";
import { Button, TextInput } from "react-native-paper";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { MobileScreen, MobileScreenScrollable } from "../parts/StyledParts/ScreenWrappers";
Expand Down
5 changes: 3 additions & 2 deletions components/pages/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@ export default function Home({ navigation }) {
const showLoading = loading || !userWritable.userInfo.loaded;

useEffect(() => {
if(userWritable.userInfo.loaded && !userWritable.userInfo.apiKey) {
if(userWritable.userInfo.loaded && !userWritable.userInfo.loggedIn) {
navigation.navigate("Login");
}
}, [userWritable.userInfo.loaded]);

const toggleSignIn = () => {
if(!userWritable.userInfo.apiKey) {
if(!userWritable.userInfo.loggedIn) {
navigation.navigate("Login");
return;
}

setLoading(true);
if(!userWritable.userInfo.signedIn) {
signIn()
Expand Down
3 changes: 2 additions & 1 deletion components/pages/Leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default function Leaderboard({ navigation }) {
);
}

// TODO: Automatically resync current user's status on refresh and sign in/out
useEffect(() => {
const update = () => {
getLeaderboard()
Expand All @@ -74,7 +75,7 @@ export default function Leaderboard({ navigation }) {
// TODO: Sync more accurately using websockets
const timer = setInterval(update, 30 * 1000); // 30-second interval
return () => clearInterval(timer);
}, [userWritable.userInfo.apiKey]);
}, [userWritable.userInfo.signedIn]);

if(leaderboardData) {
content = (
Expand Down
2 changes: 1 addition & 1 deletion components/pages/Login.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from "react";
import { View, StyleSheet, Keyboard } from "react-native";
import { Keyboard, StyleSheet, View } from "react-native";
import { Button, TextInput } from "react-native-paper";
import Screen from "../parts/StyledParts/ScreenWrappers";
import LargeLogo from "../parts/StyledParts/LargeLogo";
Expand Down
3 changes: 0 additions & 3 deletions components/parts/ContextProviders/UserInfoProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,8 @@ export function UserInfoProvider({ children }) {
}

const { user } = await client.request("GET", "/user/status");

// Update the following: loggedIn, name, apiKey (deprecated)
updatedData.loggedIn = true;
updatedData.name = `${user.first_name} ${user.last_name}`;
updatedData.apiKey = client.apiKey; // TODO: Remove after transitioning all fetch() to client.request()

// Gets signed in status and time
const clockedIn = (user.session && !user.session.endTime) ? user.session.startTime : 0;
Expand Down
4 changes: 2 additions & 2 deletions components/parts/StyledParts/ScreenWrappers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { PanResponder, Platform, StyleSheet, ScrollView, View } from "react-native";
import { PanResponder, Platform, ScrollView, StyleSheet, View } from "react-native";
import MenuButton from "./MenuButton";
import config from "../../../config.json";
import { useNavigation } from "@react-navigation/native";
Expand Down Expand Up @@ -135,7 +135,7 @@ export function MobileScreenScrollable({ children, centered = false, disablePadd
);
}

function MobileView({children, style, centered = false, ...extraProps}) {
function MobileView({ children, style, centered = false, ...extraProps }) {
let mobileViewStyles = screenWrapperStyles.mobileScreen;
if(centered) {
mobileViewStyles = [mobileViewStyles, screenWrapperStyles.mobileCenter];
Expand Down
14 changes: 7 additions & 7 deletions components/parts/utils/serverClientWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,14 @@ export function signOut() {
}

export function getLeaderboard() {
return fetch(`${SERVER_URL}${endpoints.getData}`)
.then(res => res.json())
return client.request("GET", endpoints.getData, { auth: false })
.then(data => {
if(!data.ok) {
console.log("Failed to fetch all users' basic data:");
console.error(err);
return [];
}

// Sorted by sign in status, total time, then username
return data.users
.sort((a, b) => {
Expand Down Expand Up @@ -124,10 +129,5 @@ export function getLeaderboard() {

return 0;
});
})
.catch(err => {
console.log("Failed to fetch all users' basic data:");
console.error(err);
return [];
});
}
Loading

0 comments on commit 83208d5

Please sign in to comment.