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

sort participant list in manage screen #105

Merged
merged 2 commits into from
Dec 8, 2023
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
16 changes: 10 additions & 6 deletions controller/Active.js
Original file line number Diff line number Diff line change
Expand Up @@ -732,23 +732,27 @@ async function deleteOneActive (deleteDocId) {

async function getAllAttendees (docID) {
const db = getFirestore(app)
const infoRef = query(collection(db, 'attendees'))
const activesDoc = doc(db, `activities/${docID}`)

const querySnapshot = await getDocs(infoRef)
const activesSnapshot = await getDoc(activesDoc)
const IDlist = activesSnapshot.data().participant
let info = []

for (let j = 0; j < IDlist.length; j += 1) {
const infoDoc = doc(db, `attendees/${IDlist[j]}`)
const querySnapshot2 = await getDoc(infoDoc)
const querySnapshot = await getDoc(infoDoc)
const signUpTime = await getDoc(doc(db, `attendees/${IDlist[j]}/attendedEvent/${docID}`))
info.push({
uid: querySnapshot2.id,
...querySnapshot2.data()
uid: querySnapshot.id,
signupTimestamp: signUpTime.data().signUpTime,
signUpTime: toDateString(signUpTime.data().signUpTime.toDate()),
...querySnapshot.data()
})
}
return info
console.log(info)
// 按照報名時間排序 - 由先報名的 到 後報名的
var sortedInfo = info.sort((a, b) => { return a.signupTimestamp - b.signupTimestamp })
return sortedInfo
}

/**
Expand Down
Loading