Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Handling + Helper Text #94

Merged
merged 76 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
fedb1f9
Added handling for non numbers and empty values
Gehrkej Apr 4, 2024
2b0dd66
Added comments for future work
Gehrkej Apr 4, 2024
372f353
Frankreed/unify result screens (#96)
FrankreedX Apr 5, 2024
89eb868
Planscreen player (#131)
ajpert Apr 9, 2024
fca02c8
added hard coded helper text
Gehrkej Apr 9, 2024
fb0a1b7
helperText is now pulled from database
Gehrkej Apr 9, 2024
f785c64
Added handling for non numbers and empty values
Gehrkej Apr 4, 2024
abee82a
Added comments for future work
Gehrkej Apr 4, 2024
5753c59
added hard coded helper text
Gehrkej Apr 9, 2024
42b1f87
helperText is now pulled from database
Gehrkej Apr 9, 2024
8b7799c
Merge branch 'Gehrkej/Attempt-Input-Error-Handling' of https://github…
Gehrkej Apr 9, 2024
0403d02
added error handling for submit drill button
Gehrkej Apr 9, 2024
b1b8b0f
adjusted uploadAttempt function after rebase
Gehrkej Apr 9, 2024
4ae5dc1
updated SID to be 1-20
Gehrkej Apr 9, 2024
35d792a
added error handling for submit drill button
Gehrkej Apr 9, 2024
d8c57e7
adjusted uploadAttempt function after rebase
Gehrkej Apr 9, 2024
c6434e1
updated SID to be 1-20
Gehrkej Apr 9, 2024
4f8460f
Merge branch 'Gehrkej/Attempt-Input-Error-Handling' of https://github…
Gehrkej Apr 9, 2024
fedb1e8
Inital changes requested from frank in PR
Gehrkej Apr 9, 2024
5f7b293
Converted error banners to error dialogs
Gehrkej Apr 9, 2024
89ca85d
Frankreed/Bar chart is 60fps consistent now (#129)
FrankreedX Apr 9, 2024
6fe6d2c
Minor cosmetic fixes (#138)
FrankreedX Apr 10, 2024
f93ca2e
Database updated and codebase uses title instead of drillType (#134)
hannacol Apr 10, 2024
fce84f7
Reworking Drill Screens to be Componentized (#140)
hannacol Apr 11, 2024
45e4f4d
ErrorDialog Component Created and Styled
Gehrkej Apr 11, 2024
06b7d6e
Added styling to Leave Dialog
Gehrkej Apr 11, 2024
89c7b6b
Swapped order of action buttons in leave drill dialog
Gehrkej Apr 11, 2024
45a8476
Created submitVisable varible
Gehrkej Apr 11, 2024
874cf3b
Added handling for non numbers and empty values
Gehrkej Apr 4, 2024
9f5882a
Added comments for future work
Gehrkej Apr 4, 2024
47f579f
added hard coded helper text
Gehrkej Apr 9, 2024
4fdb13c
helperText is now pulled from database
Gehrkej Apr 9, 2024
1a671c4
added error handling for submit drill button
Gehrkej Apr 9, 2024
b3cd112
adjusted uploadAttempt function after rebase
Gehrkej Apr 9, 2024
2d871dd
updated SID to be 1-20
Gehrkej Apr 9, 2024
6a2cc13
Added handling for non numbers and empty values
Gehrkej Apr 4, 2024
cf3dfaa
added error handling for submit drill button
Gehrkej Apr 9, 2024
cc861c2
Inital changes requested from frank in PR
Gehrkej Apr 9, 2024
c2da920
Converted error banners to error dialogs
Gehrkej Apr 9, 2024
7e3977c
ErrorDialog Component Created and Styled
Gehrkej Apr 11, 2024
de9c360
Added styling to Leave Dialog
Gehrkej Apr 11, 2024
4fcbec7
Swapped order of action buttons in leave drill dialog
Gehrkej Apr 11, 2024
693b1aa
Created submitVisable varible
Gehrkej Apr 11, 2024
b4d6c46
added header import back
Gehrkej Apr 12, 2024
80b81a6
Merge branch 'Gehrkej/Attempt-Input-Error-Handling' of https://github…
Gehrkej Apr 12, 2024
566bd43
fix weird stuff with rebase
Gehrkej Apr 12, 2024
9fcc274
more weird rebase things
Gehrkej Apr 12, 2024
21eafc0
Restart Drill functionality working (#136)
Gehrkej Apr 12, 2024
4871c48
fixed duplicate sid
Gehrkej Apr 12, 2024
cd246a4
All dialogs using DialogComponent
Gehrkej Apr 12, 2024
8193b1e
Added handling for non numbers and empty values
Gehrkej Apr 4, 2024
c7c6a9f
Added comments for future work
Gehrkej Apr 4, 2024
6c69edb
added hard coded helper text
Gehrkej Apr 9, 2024
dc091dd
helperText is now pulled from database
Gehrkej Apr 9, 2024
ba5071c
added error handling for submit drill button
Gehrkej Apr 9, 2024
89aa3de
adjusted uploadAttempt function after rebase
Gehrkej Apr 9, 2024
f867101
updated SID to be 1-20
Gehrkej Apr 9, 2024
89a03c2
Added handling for non numbers and empty values
Gehrkej Apr 4, 2024
5e86ebc
added error handling for submit drill button
Gehrkej Apr 9, 2024
d1431bd
Inital changes requested from frank in PR
Gehrkej Apr 9, 2024
809afe6
Converted error banners to error dialogs
Gehrkej Apr 9, 2024
9a41997
ErrorDialog Component Created and Styled
Gehrkej Apr 11, 2024
dd8ddec
Added styling to Leave Dialog
Gehrkej Apr 11, 2024
feb7381
Swapped order of action buttons in leave drill dialog
Gehrkej Apr 11, 2024
d43d60f
Created submitVisable varible
Gehrkej Apr 11, 2024
d5d664a
added header import back
Gehrkej Apr 12, 2024
be48349
Added handling for non numbers and empty values
Gehrkej Apr 4, 2024
99064a1
Added comments for future work
Gehrkej Apr 4, 2024
7f00fd8
adjusted uploadAttempt function after rebase
Gehrkej Apr 9, 2024
3853a5b
Added handling for non numbers and empty values
Gehrkej Apr 4, 2024
e309748
ErrorDialog Component Created and Styled
Gehrkej Apr 11, 2024
e06e379
All dialogs using DialogComponent
Gehrkej Apr 12, 2024
a691911
Merge branch 'Gehrkej/Attempt-Input-Error-Handling' of https://github…
Gehrkej Apr 12, 2024
51508ac
Fixed uploadAttempt header comment
Gehrkej Apr 12, 2024
ad2d6e7
changed == to ===, and added one missing import, remove unused import…
FrankreedX Apr 12, 2024
31fd102
fixed faulty getUnique
FrankreedX Apr 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
- name: Install Prettier
run: yarn add prettier --dev
- name: Check code formatting
run: yarn pretty --check
run: yarn pretty:check
28 changes: 15 additions & 13 deletions Utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,13 @@ export function numTrunc(value, pad = false) {
}
}

export function refToID(ref) {
return ref["_key"] ? ref["_key"]["path"]["segments"].at(-1) : "bad ref";
}

export function getUnique(array, field) {
const uniqueMap = new Map();
array.forEach((element) => {
const keyValue = element[field];
if (!uniqueMap.has(keyValue)) {
uniqueMap.set(keyValue, element);
}
export function getUnique(array, drills) {
const unique = [];
drills.forEach((drillInfo) => {
const idx = array.findIndex((item) => item["did"] === drillInfo["did"]);
if (idx >= 0) unique.push(drillInfo);
});
return Array.from(uniqueMap.values());
return unique;
}

export function calculateAverageProxToHole(drillSubmissions) {
Expand Down Expand Up @@ -164,8 +158,16 @@ export function lookUpExpectedPutts(proxHole) {
}

export function getIconByKey(key) {
const icons = [{ carry: "arrow-up" }, { sideLanding: "arrow-left-right" }];
const icons = [
{ carry: "arrow-up" },
{ sideLanding: "arrow-left-right" },
{ strokes: "golf-tee" },
];

const iconObject = icons.find((icon) => icon[key]);
return iconObject ? iconObject[key] : null;
}

export const getCombinedDrillTitle = (drillInfo) => {
return `${drillInfo.prettyDrillType} | ${drillInfo.subType}`;
};
37 changes: 37 additions & 0 deletions add_user_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import random
import time
import math
import firebase_admin
from firebase_admin import firestore

app = firebase_admin.initialize_app()
db = firestore.client()

# Define the assigned_data array
assigned_data = [
{"drillId": "YtCsaxzscFScnpZYmnKI", "assignedTime": "1712600157", "completed": False},
{"drillId": "YtCsaxzscFScnpZYmnKI", "assignedTime": "1712531560", "completed": False},
{"drillId": "SpvYyY94HaulVH2zmVyM", "assignedTime": "1712531460", "completed": False},
{"drillId": "SpvYyY94HaulVH2zmVyM", "assignedTime": "1712531360", "completed": True},
{"drillId": "SpvYyY94HaulVH2zmVyM", "assignedTime": "1712531260", "completed": False},
{"drillId": "SpvYyY94HaulVH2zmVyM", "assignedTime": "1712470455", "completed": False},
{"drillId": "SpvYyY94HaulVH2zmVyM", "assignedTime": "1712470355", "completed": True},
{"drillId": "SpvYyY94HaulVH2zmVyM", "assignedTime": "1712470255", "completed": False},
{"drillId": "SpvYyY94HaulVH2zmVyM", "assignedTime": "1712384055", "completed": False},
{"drillId": "SpvYyY94HaulVH2zmVyM", "assignedTime": "1709709255", "completed": False},
{"drillId": "SpvYyY94HaulVH2zmVyM", "assignedTime": "1709622855", "completed": False},
]

# Get a reference to the user collection
users_collection = db.collection("teams").document("1").collection("users")


print(users_collection.stream())


# Loop through each document in the collection and update the assigned_data field
for doc in users_collection.stream():
print(doc)
doc_ref = users_collection.document(doc.id)
doc_ref.update({'assigned_data': assigned_data})
print(f"Document {doc.id} updated successfully.")
2 changes: 1 addition & 1 deletion app/(auth)/signin.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function SignIn() {
email,
password,
);
console.log(userCredential.user);
// console.log(userCredential.user);
} catch (e) {
alert(e);
console.log(e);
Expand Down
3 changes: 2 additions & 1 deletion app/(auth)/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ export default function SignUp() {
// hardcoded "player" role for now, add role selection to profile settings in future PR
role: "player",
uid: userRef,
assigned_data: [],
});

setCurrentUserId(userCredential.user.uid);

console.log(userCredential.user);
// console.log(userCredential.user);
} catch (e) {
alert(e);
console.log(e);
Expand Down
3 changes: 0 additions & 3 deletions app/content/_layout.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { Tabs } from "expo-router";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import { currentAuthContext } from "~/context/Auth";

export default () => {
const { currentUserId } = currentAuthContext();
console.log("user", currentUserId);
return (
<Tabs options={{ headerShown: false }}>
<Tabs.Screen
Expand Down
190 changes: 14 additions & 176 deletions app/content/drill/[id]/attempts/[attempt].js
Original file line number Diff line number Diff line change
@@ -1,190 +1,28 @@
import { useLocalSearchParams } from "expo-router";
import {
ScrollView,
StyleSheet,
Text,
View,
useWindowDimensions,
} from "react-native";
import { useLocalSearchParams, useNavigation } from "expo-router";
import { StyleSheet } from "react-native";
import { Appbar } from "react-native-paper";
import { SafeAreaView } from "react-native-safe-area-context";
import ScatterChart from "react-native-scatter-chart";
import { numTrunc } from "~/Utility";
import ErrorComponent from "~/components/errorComponent";
import Loading from "~/components/loading";
import ShotAccordion from "~/components/shotAccordion";
import { useAttempts } from "~/hooks/useAttempts";
import { useDrillInfo } from "~/hooks/useDrillInfo";
import ResultScreen from "../../../../../components/resultScreen";

function Result() {
export default function Result() {
const drillId = useLocalSearchParams()["id"];
const attemptId = useLocalSearchParams()["attempt"];
const { width } = useWindowDimensions();

const {
data: drillInfo,
isLoading: drillInfoIsLoading,
error: drillInfoError,
} = useDrillInfo(drillId);

const {
data: attempt,
isLoading: attemptIsLoading,
error: attemptError,
} = useAttempts({ attemptId });

if (drillInfoIsLoading || attemptIsLoading) {
return <Loading />;
}

if (drillInfoError || attemptError) {
return <ErrorComponent message={[drillInfoError, attemptError]} />;
}

let dots = [];
if (
drillInfo["outputs"].includes("sideLanding") &&
drillInfo["outputs"].includes("carryDiff")
) {
dots = attempt["shots"].map((value, index) => [
value["sideLanding"],
value["carryDiff"],
]);
}
const navigation = useNavigation();

return (
<>
<SafeAreaView style={{ flex: 1 }} edges={["right", "top", "left"]}>
<ScrollView contentContainerStyle={styles.container}>
<Text style={styles.sectionTitle}>Drill Results</Text>

{Object.keys(drillInfo).length > 0 &&
Object.keys(drillInfo["aggOutputs"]).map((output) => (
<View
style={{
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
}}
key={output}
>
<Text>{output}</Text>
<Text>{numTrunc(attempt[output])}</Text>
</View>
))}

{dots.length > 0 && (
<View style={styles.chartSection}>
<Text style={styles.sectionTitle}>Shot Tendency</Text>
<View style={{ ...styles.chartContainer, width: width * 0.8 }}>
<ScatterChart
style={styles.chart}
backgroundColor="#ffffff"
data={[
{
color: "blue",
unit: "%",
values: dots,
},
]}
horizontalLinesAt={[0]}
verticalLinesAt={[0]}
minY={-10}
maxY={10}
minX={-35}
maxX={35}
chartWidth={width * 0.8}
/>
</View>
</View>
)}

{attempt["shots"] &&
attempt["shots"].map((shot) => (
<ShotAccordion
key={shot["sid"]}
shot={shot}
drillInfo={drillInfo}
total={numTrunc(attempt["shots"].length)}
/>
))}
</ScrollView>
</SafeAreaView>
</>
<SafeAreaView style={{ flex: 1 }} edges={["right", "top", "left"]}>
<Appbar.Header style={{ backgroundColor: "FFF" }} statusBarHeight={0}>
<Appbar.BackAction onPress={navigation.goBack} color={"#F24E1E"} />
<Appbar.Content title="Drill Results" titleStyle={styles.title} />
</Appbar.Header>
<ResultScreen drillId={drillId} attemptId={attemptId} />
</SafeAreaView>
);
}

export default Result;

const styles = StyleSheet.create({
container: {
padding: 20,
paddingBottom: 0,
},
header: {
flexDirection: "row",
justifyContent: "space-between",
marginBottom: 20,
},
headerText: {
title: {
fontSize: 18,
fontWeight: "bold",
},
sectionTitle: {
fontSize: 26,
fontWeight: "bold",
marginBottom: 10,
alignSelf: "center",
},
dataSection: {
alignItems: "center",
justifyContent: "center",
marginBottom: 20,
padding: 15,
backgroundColor: "#f5f5f5",
borderRadius: 10,
width: "60%",
alignSelf: "center",
},
dataTitle: {
fontSize: 16,
fontWeight: "bold",
marginBottom: 10,
},

dataRow: {
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
marginBottom: 5,
},

dataLabel: {
fontSize: 14,
},

dataValue: {
fontSize: 14,
fontWeight: "bold",
},

chartSection: {
marginBottom: 30,
alignItems: "center",
},
chartContainer: {},
chart: {
backgroundColor: "#ffffff",
position: "absolute",
left: 0,
right: 0,
top: 0,
bottom: 0,
alignSelf: "center",
height: 350,
},

restartButton: {
margin: 10,
alignItems: "center",
},
});
Loading
Loading