From 4a909a9236f0ce57e014e768776fae860b538626 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Sat, 30 Sep 2023 17:14:59 +0800 Subject: [PATCH] Made pull up menu only operable if studying --- src/components/Api/Api.tsx | 1 + src/routes/Home/Home.tsx | 104 ++++++++++++++++++++----------------- 2 files changed, 56 insertions(+), 49 deletions(-) diff --git a/src/components/Api/Api.tsx b/src/components/Api/Api.tsx index b6362d7..0eaad7d 100644 --- a/src/components/Api/Api.tsx +++ b/src/components/Api/Api.tsx @@ -311,6 +311,7 @@ export async function GetStudyGroupListFiltered() { return instance .get("/api/v1/study_groups/near/", config) .then((response) => { + console.log("DEBUGGG", response.data); return [true, response.data]; }) .catch((error) => { diff --git a/src/routes/Home/Home.tsx b/src/routes/Home/Home.tsx index 464bb1c..0cdb133 100644 --- a/src/routes/Home/Home.tsx +++ b/src/routes/Home/Home.tsx @@ -241,7 +241,6 @@ export default function Home() { return data; }, onSuccess: (data: StudentStatusListReturnType) => { - console.log("DEBUGGG", data[1]); if (data[1] && location) { // Filter to only include students studying solo let data_filtered = data[1].filter( @@ -379,7 +378,7 @@ export default function Home() { Student: {student_status.user} - Studying Subject: {student_status.subject} + {`Studying ${student_status.subject}`} , { @@ -425,14 +424,18 @@ export default function Home() { }} > - Subject: {studygroup.subject} + Study Group: {studygroup.name} - Name: {studygroup.name} + {`Studying ${studygroup.subject}`} + - Students Studying:{" "} - {studygroup.students.length} + {`${studygroup.students.length} ${ + studygroup.students.length > 1 + ? "students" + : "student" + } studying`} {student_status?.study_group != studygroup.name ? ( @@ -522,14 +525,17 @@ export default function Home() { }} > - Subject: {studygroup.subject} + Study Group: {studygroup.name} - Name: {studygroup.name} + {`Studying ${studygroup.subject}`} - Students Studying:{" "} - {studygroup.students.length} + {`${studygroup.students.length} ${ + studygroup.students.length > 1 + ? "students" + : "student" + } studying`} {student_status?.study_group != studygroup.name ? ( @@ -714,7 +720,7 @@ export default function Home() { setModalOpen(true); }} > - + {studying ? : <>} @@ -725,11 +731,10 @@ export default function Home() { return ; } } else { - requestLocation(); return ( <> {feedback} - @@ -740,7 +745,7 @@ export default function Home() { @@ -784,7 +789,10 @@ export default function Home() { Student: {student_status.user} - Studying Subject: {student_status.subject} + {`Studying ${student_status.subject}`} + + + {`${Math.round(student_status.distance * 1000)}m away`} ); @@ -794,42 +802,40 @@ export default function Home() { <> )} {modalByGroup ? ( - study_groups_global.map( - (studygroup: StudyGroupType, index: number) => { - return ( - + study_groups.map((studygroup: StudyGroupType, index: number) => { + return ( + + + Group Name: {studygroup.name} + + + {`Studying ${studygroup.subject}`} + + + Students Studying: {studygroup.students.length} + + {student_status?.study_group != studygroup.name ? ( - Subject: {studygroup.subject} + {`${Math.round(studygroup.distance * 1000)}m away`} - - Group Name: {studygroup.name} - - - Students Studying: {studygroup.students.length} - - {student_status?.study_group != studygroup.name ? ( - - Study nearby to join - - ) : ( - <> - )} - - ); - } - ) + ) : ( + <> + )} + + ); + }) ) : ( <> )}