Skip to content

Commit

Permalink
刪除活動功能調整
Browse files Browse the repository at this point in the history
  • Loading branch information
1989ONCE committed Sep 12, 2022
1 parent f465287 commit aa86b95
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
11 changes: 11 additions & 0 deletions controller/Active.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,16 @@ async function getAllAttendees(docID) {
}
return info;
}
async function deleteEverySingleAttendee(docID) {
const db = firebase.firestore();
const activesRef = db.collection('attendees');
const querySnapshot = await activesRef.get();
querySnapshot.forEach(async (student) => {
await activesRef.doc(student.id).collection('attendedEvent').doc(docID).delete();
await activesRef.doc(student.id).collection('hostedEvent').doc(docID).delete();
});
console.log('delete successfully!');
}

async function removeAttendee(docID, studentID) { // remove attendee
const db = firebase.firestore();
Expand Down Expand Up @@ -792,6 +802,7 @@ export default {
getHangOutActive,
getEventActive,
deleteOneActive,
deleteEverySingleAttendee,
getOneActive,
fuseSearchName,
sentMessage,
Expand Down
10 changes: 5 additions & 5 deletions screens/Event/activityList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ function list({ navigation }) {
<Box style={{ marginHorizontal: Dimensions.get('window').width * 0.0592 }}>
<Box style={styles.more}>
<HStack>
<Text style={{ marginRight: Dimensions.get('window').width * 0.62 }}>近期揪人</Text>
<Text style={{ textDecorationLine: 'underline' }} onPress={() => { navigation.navigate('moreHang'); }}>查看更多</Text>
<Text style={{ color: '#28527a', fontSize: 18, marginRight: Dimensions.get('window').width * 0.57 }}>近期揪人</Text>
<Text style={{ color: '#28527a' }} onPress={() => { navigation.navigate('moreHang'); }}>顯示更多</Text>
</HStack>
</Box>
<Divider style={{ marginTop: 5 }} bg="#BFBFBF" /* my=margin-top and margin-bottom */ />
Expand Down Expand Up @@ -154,11 +154,11 @@ function list({ navigation }) {
</View>
</ScrollView>
</View>
<Box style={{ marginHorizontal: Dimensions.get('window').width * 0.0592 }}>
<Box style={{ marginHorizontal: Dimensions.get('window').width * 0.06 }}>
<Box style={styles.more}>
<HStack>
<Text style={{ marginRight: Dimensions.get('window').width * 0.62 }}>近期活動</Text>
<Text style={{ textDecorationLine: 'underline' }} onPress={() => { navigation.navigate('more'); }}>查看更多</Text>
<Text style={{ color: '#28527a', fontSize: 18, marginRight: Dimensions.get('window').width * 0.57 }}>熱門活動</Text>
<Text style={{ color: '#28527a' }} onPress={() => { navigation.navigate('more'); }}>顯示更多</Text>
</HStack>
</Box>
<Divider style={{ marginTop: 5 }} bg="#BFBFBF" /* my=margin-top and margin-bottom */ />
Expand Down
11 changes: 7 additions & 4 deletions screens/Event/manage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,18 @@ function manage({ route, navigation }) {
</Box>
<Box
style={{ marginTop: 10 }}
onPress={() => {
ActiveController.removeAttendee(passedID, item.studentID);
}}
>
<Text
style={{
color: '#ffffff', backgroundColor: '#ef4444', padding: 10, borderRadius: 4, marginLeft: 10, marginTop: Dimensions.get('window').width * 0.009,
}}
onPress={() => {
setShowDialog1(false);
ActiveController.deleteOneActive(passedID);
ActiveController.deleteEverySingleAttendee(passedID);
}}
>
移除
刪除

</Text>
</Box>
Expand Down Expand Up @@ -433,6 +435,7 @@ function manage({ route, navigation }) {
<Box
style={{ marginTop: 10 }}
onPress={() => {
setShowDialog2(false);
ActiveController.removeAttendee(passedID, item.studentID);
}}
>
Expand Down
2 changes: 1 addition & 1 deletion screens/Event/style_folder/Styles_activityList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default StyleSheet.create({
marginTop: -3,
},
more: {
height: 27,
height: 35,
paddingTop: 10,
},
pic: {
Expand Down

0 comments on commit aa86b95

Please sign in to comment.