Made pull up menu only operable if studying

This commit is contained in:
Keannu Christian Bernasol 2023-09-30 17:14:59 +08:00
parent 4e1a73f6ed
commit 4a909a9236
2 changed files with 56 additions and 49 deletions

View file

@ -311,6 +311,7 @@ export async function GetStudyGroupListFiltered() {
return instance return instance
.get("/api/v1/study_groups/near/", config) .get("/api/v1/study_groups/near/", config)
.then((response) => { .then((response) => {
console.log("DEBUGGG", response.data);
return [true, response.data]; return [true, response.data];
}) })
.catch((error) => { .catch((error) => {

View file

@ -241,7 +241,6 @@ export default function Home() {
return data; return data;
}, },
onSuccess: (data: StudentStatusListReturnType) => { onSuccess: (data: StudentStatusListReturnType) => {
console.log("DEBUGGG", data[1]);
if (data[1] && location) { if (data[1] && location) {
// Filter to only include students studying solo // Filter to only include students studying solo
let data_filtered = data[1].filter( let data_filtered = data[1].filter(
@ -379,7 +378,7 @@ export default function Home() {
Student: {student_status.user} Student: {student_status.user}
</Text> </Text>
<Text style={styles.text_white_tiny_bold}> <Text style={styles.text_white_tiny_bold}>
Studying Subject: {student_status.subject} {`Studying ${student_status.subject}`}
</Text> </Text>
</View>, </View>,
{ {
@ -425,14 +424,18 @@ export default function Home() {
}} }}
> >
<Text style={styles.text_white_tiny_bold}> <Text style={styles.text_white_tiny_bold}>
Subject: {studygroup.subject} Study Group: {studygroup.name}
</Text> </Text>
<Text style={styles.text_white_tiny_bold}> <Text style={styles.text_white_tiny_bold}>
Name: {studygroup.name} {`Studying ${studygroup.subject}`}
</Text> </Text>
<Text style={styles.text_white_tiny_bold}> <Text style={styles.text_white_tiny_bold}>
Students Studying:{" "} {`${studygroup.students.length} ${
{studygroup.students.length} studygroup.students.length > 1
? "students"
: "student"
} studying`}
</Text> </Text>
{student_status?.study_group != {student_status?.study_group !=
studygroup.name ? ( studygroup.name ? (
@ -522,14 +525,17 @@ export default function Home() {
}} }}
> >
<Text style={styles.text_white_tiny_bold}> <Text style={styles.text_white_tiny_bold}>
Subject: {studygroup.subject} Study Group: {studygroup.name}
</Text> </Text>
<Text style={styles.text_white_tiny_bold}> <Text style={styles.text_white_tiny_bold}>
Name: {studygroup.name} {`Studying ${studygroup.subject}`}
</Text> </Text>
<Text style={styles.text_white_tiny_bold}> <Text style={styles.text_white_tiny_bold}>
Students Studying:{" "} {`${studygroup.students.length} ${
{studygroup.students.length} studygroup.students.length > 1
? "students"
: "student"
} studying`}
</Text> </Text>
{student_status?.study_group != {student_status?.study_group !=
studygroup.name ? ( studygroup.name ? (
@ -714,7 +720,7 @@ export default function Home() {
setModalOpen(true); setModalOpen(true);
}} }}
> >
<CaretUpIcon size={32} /> {studying ? <CaretUpIcon size={32} /> : <></>}
</Pressable> </Pressable>
</View> </View>
@ -725,11 +731,10 @@ export default function Home() {
return <MapRendererFar location={location.coords} dist={dist} />; return <MapRendererFar location={location.coords} dist={dist} />;
} }
} else { } else {
requestLocation();
return ( return (
<> <>
<Text style={styles.text_white_medium}>{feedback}</Text> <Text style={styles.text_white_medium}>{feedback}</Text>
<Button onPress={requestLocation}> <Button onPress={() => requestLocation()}>
<Text style={styles.text_white_medium}>Allow Access</Text> <Text style={styles.text_white_medium}>Allow Access</Text>
</Button> </Button>
</> </>
@ -740,7 +745,7 @@ export default function Home() {
<View style={styles.background}> <View style={styles.background}>
<Modal <Modal
coverScreen={false} coverScreen={false}
isVisible={modalOpen} isVisible={modalOpen && studying}
style={{ opacity: 0.85 }} style={{ opacity: 0.85 }}
hasBackdrop={false} hasBackdrop={false}
> >
@ -784,7 +789,10 @@ export default function Home() {
Student: {student_status.user} Student: {student_status.user}
</Text> </Text>
<Text style={styles.text_white_tiny_bold}> <Text style={styles.text_white_tiny_bold}>
Studying Subject: {student_status.subject} {`Studying ${student_status.subject}`}
</Text>
<Text style={styles.text_white_tiny_bold}>
{`${Math.round(student_status.distance * 1000)}m away`}
</Text> </Text>
</View> </View>
); );
@ -794,42 +802,40 @@ export default function Home() {
<></> <></>
)} )}
{modalByGroup ? ( {modalByGroup ? (
study_groups_global.map( study_groups.map((studygroup: StudyGroupType, index: number) => {
(studygroup: StudyGroupType, index: number) => { return (
return ( <View
<View key={index}
key={index} style={{
style={{ alignContent: "center",
alignContent: "center", alignSelf: "center",
alignSelf: "center", justifyContent: "center",
justifyContent: "center", backgroundColor: colors.secondary_3,
backgroundColor: colors.secondary_3, borderColor: colors.primary_2,
borderColor: colors.primary_2, borderWidth: 1,
borderWidth: 1, borderRadius: 16,
borderRadius: 16, width: 256,
width: 256, }}
}} >
> <Text style={styles.text_white_tiny_bold}>
Group Name: {studygroup.name}
</Text>
<Text style={styles.text_white_tiny_bold}>
{`Studying ${studygroup.subject}`}
</Text>
<Text style={styles.text_white_tiny_bold}>
Students Studying: {studygroup.students.length}
</Text>
{student_status?.study_group != studygroup.name ? (
<Text style={styles.text_white_tiny_bold}> <Text style={styles.text_white_tiny_bold}>
Subject: {studygroup.subject} {`${Math.round(studygroup.distance * 1000)}m away`}
</Text> </Text>
<Text style={styles.text_white_tiny_bold}> ) : (
Group Name: {studygroup.name} <></>
</Text> )}
<Text style={styles.text_white_tiny_bold}> </View>
Students Studying: {studygroup.students.length} );
</Text> })
{student_status?.study_group != studygroup.name ? (
<Text style={styles.text_white_tiny_bold}>
Study nearby to join
</Text>
) : (
<></>
)}
</View>
);
}
)
) : ( ) : (
<></> <></>
)} )}