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

closes #103, #104, #106, Add features #107

Merged
merged 3 commits into from
Apr 6, 2024
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
4 changes: 0 additions & 4 deletions controller/Active.js
Original file line number Diff line number Diff line change
Expand Up @@ -844,20 +844,16 @@ async function removeAttendee (docID, studentUid) { // remove attendee

async function addUser (uid, newUserInfo) {
const db = getFirestore(app)
const attendeeRef = query(collection(db, 'attendees'))
const memberInfo = newUserInfo
const imageAddress = `avatar/${imagePos(newUserInfo.avatar)}`
const storageRef = ref(storage, imageAddress)
const response = await fetch(newUserInfo.avatar)
const blob = await response.blob()
const uploadTask = await uploadBytes(storageRef, blob)
memberInfo.avatar = await getDownloadURL(uploadTask.ref)
console.log(memberInfo)

setDoc(doc(db, 'attendees', `${uid}`), memberInfo, { merge: true })
.then(console.log('succeed'))
const result = await getDocs(attendeeRef)
result.forEach((doc1) => console.log(doc1.data()))
}

/**
Expand Down
2 changes: 1 addition & 1 deletion controller/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ async function getCalender () {
async function getTutorial () {
const app = getApp()
const db = getFirestore(app)
const tutorialRef = query(collection(db, 'NCU-APP corner'), orderBy('upload', 'desc'))
const tutorialRef = query(collection(db, 'ncuappcorner'), orderBy('upload', 'desc'))
const querySnapshot = await getDocs(tutorialRef)

const result = []
Expand Down
19 changes: 16 additions & 3 deletions controller/Setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
/* eslint-disable no-await-in-loop */
import { getApp } from 'firebase/app'
import {
getFirestore, collection, query, getDoc, getDocs, addDoc,
setDoc, doc, orderBy, where, deleteDoc, deleteField, updateDoc
getFirestore, query, getDoc, doc, deleteDoc, updateDoc
} from 'firebase/firestore'
import {
getStorage,
Expand Down Expand Up @@ -72,7 +71,21 @@ async function updateInfo (uid, newUserInfo) {
})
}

async function deleteUserInfo(uid) {
const db = getFirestore(app)

// delete user info in the database
await deleteDoc(doc(db, 'attendees', `${uid}`))
.then(console.log('delete user info succeed'))
.catch((error) => {
console.log(error)
})

}


export default {
changeAvatar,
updateInfo
updateInfo,
deleteUserInfo
}
Loading