diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..23a5a5c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,67 @@ +{ + "name": "PageTurners", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "fetch": "^1.1.0" + } + }, + "node_modules/biskviit": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/biskviit/-/biskviit-1.0.1.tgz", + "integrity": "sha512-VGCXdHbdbpEkFgtjkeoBN8vRlbj1ZRX2/mxhE8asCCRalUx2nBzOomLJv8Aw/nRt5+ccDb+tPKidg4XxcfGW4w==", + "license": "MIT", + "dependencies": { + "psl": "^1.1.7" + }, + "engines": { + "node": ">=1.0.0" + } + }, + "node_modules/encoding": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", + "integrity": "sha512-bl1LAgiQc4ZWr++pNYUdRe/alecaHFeHxIJ/pNciqGdKXghaTCOwKkbKp6ye7pKZGu/GcaSXFk8PBVhgs+dJdA==", + "license": "MIT", + "dependencies": { + "iconv-lite": "~0.4.13" + } + }, + "node_modules/fetch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fetch/-/fetch-1.1.0.tgz", + "integrity": "sha512-5O8TwrGzoNblBG/jtK4NFuZwNCkZX6s5GfRNOaGtm+QGJEuNakSC/i2RW0R93KX6E0jVjNXm6O3CRN4Ql3K+yA==", + "license": "MIT", + "dependencies": { + "biskviit": "1.0.1", + "encoding": "0.1.12" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/psl": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", + "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==", + "license": "MIT" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..5747974 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "fetch": "^1.1.0" + } +} diff --git a/public/scripts/clubhome.js b/public/scripts/clubhome.js new file mode 100644 index 0000000..1ce9a68 --- /dev/null +++ b/public/scripts/clubhome.js @@ -0,0 +1,72 @@ +import { initializeApp } from "https://www.gstatic.com/firebasejs/10.13.2/firebase-app.js"; + import { getAnalytics } from "https://www.gstatic.com/firebasejs/10.13.2/firebase-analytics.js"; + import { getFirestore, collection, getDoc, getDocs, doc, query, where } from 'https://www.gstatic.com/firebasejs/10.13.2/firebase-firestore.js'; + import { getAuth, + createUserWithEmailAndPassword, +signOut, +signInWithEmailAndPassword, +onAuthStateChanged + } + +from "https://www.gstatic.com/firebasejs/10.13.2/firebase-auth.js"; + // TODO: Add SDKs for Firebase products that you want to use + // https://firebase.google.com/docs/web/setup#available-libraries + + // Your web app's Firebase configuration + // For Firebase JS SDK v7.20.0 and later, measurementId is optional + const firebaseConfig = { + apiKey: "AIzaSyAt-SInlPaL2FzwtXrRltIEiV5l8k5HMjg", + authDomain: "pageturners-a831a.firebaseapp.com", + projectId: "pageturners-a831a", + storageBucket: "pageturners-a831a.appspot.com", + messagingSenderId: "304224952392", + appId: "1:304224952392:web:f33dbc84b481e39a44787d", + measurementId: "G-C6DKQSJ1R8" + }; + + // Initialize Firebase + const app = initializeApp(firebaseConfig); + const analytics = getAnalytics(app); + const auth = getAuth(); + const db = getFirestore(app); + + const queryParams = new URLSearchParams(window.location.search); + + const name = queryParams.get("name"); + + + async function getClubDocFromQParams(queryParams) + { + const q = query(collection(db, "BookClubs"), where("BookClubName", "==", queryParams.get("name"))); + const qsnap = await getDocs(q); + + + const docData = qsnap.docs[0].data(); + console.log(docData) + console.log(docData["BookClubName"]); + return docData; + } + + async function getEmailFromUID(uid) + { + const q = query(collection(db, "Users"), where("uid", "==", uid)); + const qsnap = await getDocs(q); + + return qsnap.docs[0].data()["email"]; + } + + let docData = await getClubDocFromQParams(queryParams); + + document.getElementById("clubName").textContent = docData["BookClubName"] + document.getElementById("clubDescription").textContent = docData["clubDescription"] + + for (const uid of docData["ClubUsers"]) + { + const newLI = document.createElement("li"); + newLI.textContent = await getEmailFromUID(uid); + + const parentUL = document.getElementById("members"); + parentUL.appendChild(newLI); + } + + diff --git a/public/scripts/createClub.js b/public/scripts/createClub.js index 5293ec7..9b6882b 100644 --- a/public/scripts/createClub.js +++ b/public/scripts/createClub.js @@ -24,7 +24,7 @@ auth.onAuthStateChanged(function(user){ clubCreateForm.addEventListener('submit', async function(e){ e.preventDefault(); - const clubName = clubCreateForm["clubName"].value; + const clubName = clubCreateForm["clubname"].value; let bookClubsRef = collection(db, "BookClubs"); const q = query(bookClubsRef, where("BookClubName", "==", clubName)); @@ -35,7 +35,8 @@ auth.onAuthStateChanged(function(user){ if (qsnap.empty){ await addDoc(collection(db,"BookClubs"), { BookClubName: clubName, - ClubUsers: [user.uid] + ClubUsers: [user.uid], + clubDescription: "no description" }, clubName) window.location.href = "./dashboard.html"; diff --git a/public/webpages/html/club.html b/public/webpages/html/club.html index c668eec..cac1318 100644 --- a/public/webpages/html/club.html +++ b/public/webpages/html/club.html @@ -123,17 +123,16 @@