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

Fixed assignment not complete-able #328

Merged
merged 3 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 7 additions & 7 deletions app/content/assignments/players.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

function Index() {
const navigation = useNavigation();
const { drillId, assignedTime } = useLocalSearchParams();
const { drillId, mergeTime } = useLocalSearchParams();
const {
data: drillInfo,
isLoading: drillInfoIsLoading,
Expand Down Expand Up @@ -58,7 +58,7 @@
getLocalizedDate({
time: assignment.assignedTime,
rounded: true,
}).getTime() == assignedTime && assignment.drillId === drillId;
}).getTime() == mergeTime && assignment.drillId === drillId;
setAssignmentList(
Object.values(userInfo)
.filter((user) => user.assigned_data.some(critera))
Expand All @@ -79,7 +79,7 @@
}, [
userInfo,
getLocalizedDate,
assignedTime,
mergeTime,
drillId,
assignmentList.length,
navigation,
Expand All @@ -95,7 +95,7 @@
}, [assignmentList]);

const [loadingDelete, setLoadingDelete] = useState(false);
const handleDelete = useCallback(

Check warning on line 98 in app/content/assignments/players.js

View workflow job for this annotation

GitHub Actions / prettier-check

React Hook useCallback received a function whose dependencies are unknown. Pass an inline function instead
once(async () => {
setLoadingDelete(true);
try {
Expand All @@ -122,10 +122,10 @@
getLocalizedDate({
time: assignment.assignedTime,
rounded: true,
}).getTime() != assignedTime,
}).getTime() != mergeTime,
);
console.log("Updated Assignment List: ", updatedAssignmentList);
console.log("current assignedTime: ", assignedTime);
console.log("current mergeTime: ", mergeTime);
playerList.push({
uid: assignment.uid,
assigned_data: updatedAssignmentList,
Expand Down Expand Up @@ -156,7 +156,7 @@
}
}),
[
assignedTime,
mergeTime,
assignmentList,
currentTeamId,
getLocalizedDate,
Expand Down Expand Up @@ -200,7 +200,7 @@
if (docSnap.exists()) {
const assignedData = docSnap.data().assigned_data;
const updatedAssignedData = assignedData.map((a) => {
if (a.assignedTime == assignedTime && a.drillId === drillId) {
if (a.assignedTime == mergeTime && a.drillId === drillId) {
return { ...a, completed: false };
}
return a;
Expand Down
14 changes: 8 additions & 6 deletions app/segments/drill/[id]/submission/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ export default function Index() {
content={"All inputs will be lost."}
visible={leaveDialogVisible}
onHide={hideLeaveDialog}
buttons={["Cancel", "Leave Drill"]}
buttonsFunctions={[
hideLeaveDialog,
() => {
hideLeaveDialog();
navigation.dispatch(exitAction);
buttons={[
{ children: "Cancel", pressHandler: hideLeaveDialog },
{
children: "Leave Drill",
pressHandler: () => {
hideLeaveDialog();
navigation.dispatch(exitAction);
},
},
]}
/>
Expand Down
8 changes: 5 additions & 3 deletions app/segments/drill/[id]/submission/input.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { KeyboardAvoiderScrollView } from "@good-react-native/keyboard-avoider";
import {
BottomSheetModalProvider,
BottomSheetScrollView,
Expand All @@ -16,7 +17,6 @@
} from "firebase/firestore";
import { useCallback, useEffect, useRef, useState } from "react";
import { Platform, StyleSheet, View, useWindowDimensions } from "react-native";
import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
import { Appbar, Button, Divider, Text } from "react-native-paper";
import { SafeAreaView } from "react-native-safe-area-context";
import { once } from "underscore";
Expand Down Expand Up @@ -60,6 +60,8 @@

if (docSnap.exists()) {
const assignedData = docSnap.data()["assigned_data"];
console.log("assignedData", assignedData);
console.log("assignedTime", assignedTime);
const updatedAssignedData = assignedData.map((assignment) => {
if (
assignment.assignedTime == assignedTime &&
Expand Down Expand Up @@ -848,7 +850,7 @@
}
};

const handleSubmit = useCallback(

Check warning on line 853 in app/segments/drill/[id]/submission/input.js

View workflow job for this annotation

GitHub Actions / prettier-check

React Hook useCallback received a function whose dependencies are unknown. Pass an inline function instead
once(async () => {
setSubmitLoading(true);
const outputData = createOutputData(
Expand Down Expand Up @@ -927,7 +929,7 @@
}
/>

<KeyboardAwareScrollView>
<KeyboardAvoiderScrollView>
{/* Shot Number / Total shots */}
<View style={styles.shotNumContainer}>
<Text style={styles.shotNumber}>
Expand Down Expand Up @@ -1021,7 +1023,7 @@
<DrillDescription drillInfo={drillInfo} />
</BottomSheetView>
</BottomSheetWrapper>
</KeyboardAwareScrollView>
</KeyboardAvoiderScrollView>
{/* Navigation */}
<View style={styles.navigationContainer}>
<Text
Expand Down
11 changes: 6 additions & 5 deletions components/assignmentList.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@

if (!alreadyAddedData[mergeTime][drillId]) {
alreadyAddedData[mergeTime][drillId] = {
assignedTime: mergeTime,
assignedTime,
mergeTime,
drillId,
players: [],
};
Expand All @@ -70,7 +71,7 @@
// Group the assigned drills by date
const groupedData = useMemo(() => {
return assigned_data.reduce((acc, curr) => {
const time = curr.assignedTime;
const time = curr.mergeTime;

if (!acc[time]) {
acc[time] = [];
Expand All @@ -90,7 +91,7 @@
return Object.keys(groupedData).sort((a, b) => b - a);
}, [groupedData]);

const cardPressHandler = useCallback(

Check warning on line 94 in components/assignmentList.js

View workflow job for this annotation

GitHub Actions / prettier-check

React Hook useCallback received a function whose dependencies are unknown. Pass an inline function instead
debounce(
(assignment) => {
if (singleUser) {
Expand All @@ -117,7 +118,7 @@
pathname: "content/assignments/players",
params: {
drillId: assignment.drillId,
assignedTime: assignment.assignedTime,
mergeTime: assignment.mergeTime,
},
});
}
Expand Down Expand Up @@ -204,7 +205,7 @@
title: date,
data: groupedData[date],
}))}
keyExtractor={(item) => `${item.assignedTime}-${item.drillId}`}
keyExtractor={(item) => `${item.mergeTime}-${item.drillId}`}
ListHeaderComponent={children}
renderItem={({ item: assignment }) => {
const assignmentCompleted = singleUser
Expand All @@ -216,7 +217,7 @@
});
return (
<TouchableOpacity
key={`${assignment.assignedTime}-${assignment.drillId}`}
key={`${assignment.mergeTime}-${assignment.drillId}`}
onPress={() => cardPressHandler(assignment)}
disabled={disabled}
>
Expand Down
Loading