diff --git a/.github/workflows/jsdoc.yaml b/.github/workflows/jsdoc.yaml deleted file mode 100644 index 840df6e..0000000 --- a/.github/workflows/jsdoc.yaml +++ /dev/null @@ -1,27 +0,0 @@ -name: JSDoc to GH Pages - -on: - push: - branches: - - main - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v2 - - - name: Build - uses: andstor/jsdoc-action@v1 - with: - source_dir: ./frontend-next - output_dir: ./jsdoc - recurse: true - template: minami - - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./jsdoc diff --git a/frontend-next/src/app/app/page.js b/frontend-next/src/app/app/page.js index 1ac9d45..b45788a 100644 --- a/frontend-next/src/app/app/page.js +++ b/frontend-next/src/app/app/page.js @@ -7,7 +7,7 @@ import Drawer from '@mui/material/Drawer'; // Firebase Imports import { auth, database } from "../../../firebase-config"; -import { ref, get, set } from "firebase/database"; +import { ref, onValue, set } from "firebase/database"; import { useAuthState } from "react-firebase-hooks/auth" // Component Imports @@ -43,10 +43,10 @@ function Home() { // Authentication Verification / Redirection if Profile Data not Filled out useEffect(() => { if (authUser && authLoading === false) { - get(ref(database, `users/${authUser.uid}`)).then((userData) => { + onValue(ref(database, `users/${authUser.uid}`), (userData) => { userData = userData.val(); if (userData) { - setUser({...userData}); + setUser(userData); } else { window.location.href = "/onboarding"; } diff --git a/frontend-next/src/app/chat/page.js b/frontend-next/src/app/chat/page.js index 1aa692b..6f79da2 100644 --- a/frontend-next/src/app/chat/page.js +++ b/frontend-next/src/app/chat/page.js @@ -39,7 +39,7 @@ function Chat() { // Authentication Verification / Redirection if Profile Data not Filled out useEffect(() => { if (authUser && authLoading === false && !user) { - get(ref(database, `users/${authUser.uid}`)).then((userData) => { + onValue(ref(database, `users/${authUser.uid}`),(userData) => { userData = userData.val(); if (userData) { setUser(userData); @@ -91,7 +91,7 @@ function Chat() { })*/ // Room Object Load - get(ref(database, `/rooms/${path}`)).then((roomData) => { + onValue(ref(database, `/rooms/${path}`), (roomData) => { roomData = roomData.val(); setChatRoomObj(roomData) if (!doneLoading) { diff --git a/frontend-next/src/app/dm/page.js b/frontend-next/src/app/dm/page.js index f339609..57ccd3c 100644 --- a/frontend-next/src/app/dm/page.js +++ b/frontend-next/src/app/dm/page.js @@ -5,7 +5,7 @@ import { useState, useEffect } from "react"; // Firebase Imports import { auth, database } from "../../../firebase-config"; -import { ref, onValue, set, onDisconnect, get, onChildAdded, onChildRemoved} from "firebase/database"; +import { ref, onValue, set, onDisconnect} from "firebase/database"; import { useAuthState } from "react-firebase-hooks/auth" // Component Imports @@ -40,7 +40,7 @@ function Chat() { // Authentication Verification / Redirection if Profile Data not Filled out useEffect(() => { if (authUser && authLoading === false) { - get(ref(database, `users/${authUser.uid}`)).then((userData) => { + onValue(ref(database, `users/${authUser.uid}`), (userData) => { userData = userData.val(); if (userData) { setUser(userData); @@ -58,10 +58,11 @@ function Chat() { if (user) { const searchParams = new URLSearchParams(document.location.search); var path = searchParams.get("dm") - if (path.includes(user.uid)) + if (path.includes(user.uid)) { setIsUserAuthed(true) - else + } else { location.href = "/app" + } /*// Send entered message var payload = { body: "entered", @@ -95,7 +96,7 @@ function Chat() { })*/ // Room Object Load - get(ref(database, `/dms/${path}`)).then((roomData) => { + onValue(ref(database, `/dms/${path}`), (roomData) => { roomData = roomData.val(); setChatRoomObj(roomData) if (!doneLoading) { diff --git a/frontend-next/src/app/onboarding/page.js b/frontend-next/src/app/onboarding/page.js index 9ab96fa..2f7f4d9 100644 --- a/frontend-next/src/app/onboarding/page.js +++ b/frontend-next/src/app/onboarding/page.js @@ -6,27 +6,9 @@ import { useRouter } from "next/navigation"; // Firebase Imports import { ref, set } from "firebase/database"; -import { auth, database } from "../../../firebase-config"; +import { auth, database, storage } from "../../../firebase-config"; import { onAuthStateChanged } from "firebase/auth"; - -/** - * Creates user data in Firebase DB - * @param {JSON} data - User data to be stored in Firebase DB ( from form ) - * @return {Boolean} - True if user data is stored, False if user data is not stored - */ -function createUser(data) { - onAuthStateChanged(auth, (user) => { - if (user.uid) { - data.uid = user.uid; - data.defined = true; - data.email = user.email; - set(ref(database, `users/${user.uid}`), data); - return true; - } else { - return false; - } - }); -} +import { ref as sRef, getDownloadURL } from "firebase/storage"; /** * Onboarding Page @@ -37,8 +19,24 @@ function Onboarding() { var { register, handleSubmit } = useForm(); function Onboard(data) { - createUser(data); - router.push("/app"); + onAuthStateChanged(auth, (user) => { + if (user.uid) { + data.uid = user.uid; + data.defined = true; + data.invisibleStatus = false; + data.bio = " "; + data.interests = " , , " + getDownloadURL(sRef(storage, `/default.png`)).then((url) => { + data.pfp = url; + data.email = user.email; + set(ref(database, `users/${user.uid}`), data); + router.push("/app"); + }) + + } else { + return false; + } + }); } return (