Skip to content

Commit

Permalink
closes #103, #104, #106, Merge pull request #107 from 1989ONCE/main
Browse files Browse the repository at this point in the history
closes #103, #104, #106, Add features
  • Loading branch information
1989ONCE authored Apr 6, 2024
2 parents 7abc5e9 + 3201be4 commit 5465cf1
Show file tree
Hide file tree
Showing 18 changed files with 1,156 additions and 126 deletions.
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

0 comments on commit 5465cf1

Please sign in to comment.