From 0878f5a342d5179391c671655ce9f29854e5eb77 Mon Sep 17 00:00:00 2001 From: Frank Nguyen <41023671+FrankreedX@users.noreply.github.com> Date: Tue, 20 Aug 2024 14:43:26 +0700 Subject: [PATCH] Fixed assignment not complete-able (#328) * changed dialog component to new inputs * keyboard avoiding in input is now a lot smoother * added mergeTime in addition to assignedTime to make clear which one is rounded --- app/content/assignments/players.js | 14 +++++++------- app/segments/drill/[id]/submission/input.js | 2 ++ components/assignmentList.js | 11 ++++++----- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/app/content/assignments/players.js b/app/content/assignments/players.js index 3f2ee7a4..098ce252 100644 --- a/app/content/assignments/players.js +++ b/app/content/assignments/players.js @@ -23,7 +23,7 @@ import { db } from "~/firebaseConfig"; function Index() { const navigation = useNavigation(); - const { drillId, assignedTime } = useLocalSearchParams(); + const { drillId, mergeTime } = useLocalSearchParams(); const { data: drillInfo, isLoading: drillInfoIsLoading, @@ -58,7 +58,7 @@ function Index() { 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)) @@ -79,7 +79,7 @@ function Index() { }, [ userInfo, getLocalizedDate, - assignedTime, + mergeTime, drillId, assignmentList.length, navigation, @@ -122,10 +122,10 @@ function Index() { 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, @@ -156,7 +156,7 @@ function Index() { } }), [ - assignedTime, + mergeTime, assignmentList, currentTeamId, getLocalizedDate, @@ -200,7 +200,7 @@ function Index() { 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; diff --git a/app/segments/drill/[id]/submission/input.js b/app/segments/drill/[id]/submission/input.js index 57cae818..20183751 100644 --- a/app/segments/drill/[id]/submission/input.js +++ b/app/segments/drill/[id]/submission/input.js @@ -60,6 +60,8 @@ async function completeAssigned( 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 && diff --git a/components/assignmentList.js b/components/assignmentList.js index 63eb2678..49ee8bb6 100644 --- a/components/assignmentList.js +++ b/components/assignmentList.js @@ -43,7 +43,8 @@ const AssignmentsList = ({ if (!alreadyAddedData[mergeTime][drillId]) { alreadyAddedData[mergeTime][drillId] = { - assignedTime: mergeTime, + assignedTime, + mergeTime, drillId, players: [], }; @@ -70,7 +71,7 @@ const AssignmentsList = ({ // 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] = []; @@ -117,7 +118,7 @@ const AssignmentsList = ({ pathname: "content/assignments/players", params: { drillId: assignment.drillId, - assignedTime: assignment.assignedTime, + mergeTime: assignment.mergeTime, }, }); } @@ -204,7 +205,7 @@ const AssignmentsList = ({ 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 @@ -216,7 +217,7 @@ const AssignmentsList = ({ }); return ( cardPressHandler(assignment)} disabled={disabled} >