);
}
-export default Navbar
\ No newline at end of file
+
+
diff --git a/react/src/components/schedule/ScheduledDrug.jsx b/react/src/components/schedule/ScheduledDrug.jsx
index 75fd3ee..7bce5a5 100644
--- a/react/src/components/schedule/ScheduledDrug.jsx
+++ b/react/src/components/schedule/ScheduledDrug.jsx
@@ -1,26 +1,36 @@
+import React, {Component} from "react";
import { useState } from 'react';
-class ScheduledDrug extends React.Component {
- constructor(props) {
- super(props);
- this.uid = "";
- }
- componentDidMount() {
- this.props.firebase.auth().onAuthStateChanged((user) => {
- if (user) {
- this.uid = user.uid;
- }
- });
+class ScheduledDrug extends Component{
+
+ render() {
+ // this is just an example of what this could look like and i hope we make it look better asp
+ return (
+
+
+
{this.props.CHEMICAL}
+
{"Take " + this.props.DOSAGE + " of this medicine in the " + this.props.TIME}
+
+
+
+
+ );
}
- // need a mapping function to return all prescriptions
+
+}
+ScheduledDrug.defaultProps = {
+CHEMICAL: "Wellbutruin",
+TIME: "Morning",
+DOSAGE: "75mg",
+DISEASE: "Being too hot",
+FILLTIME: "Abc",
+REFILLTIME: " Idk if we fr need these",
+QUANTITY: " 30 pills",
+INFO: "stop being anxious",
+
- render (
- return(
-
{this.uid }
- )
-
- );
}
-export default ScheduledDrug;
\ No newline at end of file
+
+export {ScheduledDrug};
diff --git a/react/src/config/firebaseconfig.js b/react/src/config/firebaseconfig.js
index c812a1a..2d0189f 100644
--- a/react/src/config/firebaseconfig.js
+++ b/react/src/config/firebaseconfig.js
@@ -1,16 +1,6 @@
-import { useEffect, useState } from "react";
import { initializeApp } from "firebase/app";
import { getAuth } from "firebase/auth";
-import { getFirestore } from "firebase/firestore";
-import { useState, useEffect } from "react";
-import { ref, onValue } from "firebase/database";
-import {
- deleteObject,
- getDownloadURL,
- getStorage,
- ref as sRef,
- uploadBytes,
-} from "firebase/storage";
+import { getDatabase } from "firebase/database";
const firebaseConfig = {
apiKey: "AIzaSyDWQwGfrwlkyAZuwBatkhzQJVH5IPnFv7A",
@@ -24,79 +14,5 @@ const firebaseConfig = {
};
export const app = initializeApp(firebaseConfig);
-
+export const database = getDatabase(app);
export const auth = getAuth(app);
-
-const database = getFirestore(app);
-
-
-// Get data from a specific path in the entire database
-export const useDbData = (path) => {
- const [data, setData] = useState();
- const [error, setError] = useState(null);
-
- useEffect(
- () =>
- onValue( // reference error with on value
- ref(database, path),
- (snapshot) => {
- setData(snapshot.val());
- },
- (error) => {
- setError(error);
- }
- ),
- [path]
- );
-
- return [data, error];
-};
-
-// Add new user to the user table in the database
-export const addNewUser = (newUser, uid) => {
- set(ref(database, "users/" + uid), newUser);
-};
-
-
-// Image upload and delete functions
-
-export const uploadFile = async (file) => {
- let fileLink = `images/${file.name}`;
- let downloadURL = "";
- let isSuccessful = false;
- const imageReference = sRef(storage, fileLink);
-
- try {
- await uploadBytes(imageReference, file);
- downloadURL = await getDownloadURL(imageReference);
- console.log("File upload successful");
- isSuccessful = true;
- } catch (err) {
- console.log("Error: " + err);
- }
-
- return [isSuccessful, downloadURL];
-};
-
-export const deleteFile = async (url) => {
- let fileRef = sRef(storage, url);
- try {
- let deleteResult = await deleteObject(fileRef);
- console.log(deleteResult);
- } catch (error) {
- console.log(error);
- }
-};
-
-export const getImageLinkOfExistingImage = async (imageFileName) => {
- let fileLink = `images/${imageFileName}`;
- let imageLink = "";
- const imageReference = sRef(storage, fileLink);
- try {
- imageLink = await getDownloadURL(imageReference);
- } catch (err) {
- console.log(err);
- }
-
- return imageLink;
-};
\ No newline at end of file
diff --git a/react/src/index.css b/react/src/index.css
index 9ef50f5..55123c8 100644
--- a/react/src/index.css
+++ b/react/src/index.css
@@ -1,6 +1,17 @@
-@tailwind base;
+@import "tailwindcss/base";
+
+@import "tailwindcss/components";
+
+@import "tailwindcss/utilities";
+
+:root{
+ background-color: rgb(203 213 225);
+}
+/*@tailwind base;
@tailwind components;
@tailwind utilities;
+
+/*
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
diff --git a/react/src/pages/About.jsx b/react/src/pages/About.jsx
index 44dc002..b768719 100644
--- a/react/src/pages/About.jsx
+++ b/react/src/pages/About.jsx
@@ -1,5 +1,5 @@
import { useState } from 'react';
-import Navbar from '../components/Navbar';
+import {Navbar} from '../components/Navbar';
const About = () => {
diff --git a/react/src/pages/Assistant.jsx b/react/src/pages/Assistant.jsx
index 97b2e8f..e07ac8b 100644
--- a/react/src/pages/Assistant.jsx
+++ b/react/src/pages/Assistant.jsx
@@ -1,5 +1,5 @@
import { useState } from 'react';
-import Navbar from '../components/Navbar';
+import {Navbar} from "../Components/Navbar";
const Assistant = () => {
const [count, setCount] = useState(0);
diff --git a/react/src/pages/Home.jsx b/react/src/pages/Home.jsx
index f9d9dc8..363f07b 100644
--- a/react/src/pages/Home.jsx
+++ b/react/src/pages/Home.jsx
@@ -1,11 +1,13 @@
import { useState } from 'react';
-import Navbar from '../components/Navbar';
+import {Navbar} from '../components/Navbar';
import { initializeApp } from "firebase/app";
import { GoogleAuthProvider, signInWithPopup, getAuth } from "firebase/auth";
-import { auth, app, addNewUser } from "../config/firebaseconfig"
+import { auth, app } from "../config/firebaseconfig"
import { Link, redirect, Navigate } from 'react-router-dom';
+import { getDatabase, ref, set, off, child, get } from 'firebase/database';
-const Home = (allUsers) => {
+
+const Home = () => {
// this is basically the landing page
// don't need the nav bar if people aren't logged in that's going to cause problems
// const userCred = await signInWithPopup(auth, new GoogleAuthProvider());
@@ -16,7 +18,7 @@ const Home = (allUsers) => {
Hi! Welcome to "Explainer MD"
-
+
@@ -27,13 +29,13 @@ const Redirect = async => {
}
-const SignIn = (allUsers) => {
+const SignIn = async => {
var test = "test";
var object = {"something":"test"}
console.log(object)
console.log(object.something)
console.log(JSON.stringify(object))
-//const [user, setUser] = useState(0)
+// const [user, setUser] = useState(0)
const provider = new GoogleAuthProvider();
signInWithPopup(auth, provider)
@@ -41,37 +43,47 @@ const SignIn = (allUsers) => {
// This gives you a Google Access Token. You can use it to access the Google API.
const credential = GoogleAuthProvider.credentialFromResult(result);
const token = credential.accessToken;
+ const db = getDatabase();
// The signed-in user info.
+ // user. anything is undefined, that's the current problem
const user = result.user; // is this the user id?? ?
+ const userId = user.uid;
console.log(JSON.stringify(user));
- if (user && allUsers && allUsers["allUsers"]) {
- if (!allUsers["allUsers"][user.uid]) {
- const newUser = {
- displayName: user.displayName,
- email: user.email,
- photoURL: user.photoURL,
- };
-
- addNewUser(newUser, user.uid);
+ console.log(JSON.stringify(user.displayName));
+ console.log(JSON.stringify(user));
+ const dbRef = ref(db);
+ get(child(dbRef, `users/${userId}`)).then((snapshot) => {
+ if (snapshot.exists()) {
+ console.log("def");
+ console.log(snapshot.val());
+ window.location.href = "http://localhost:5173/schedule";
+ } else {
+ console.log("abc");
+ set(ref(db, 'users/' + userId), {
+
+ username: user.displayName,
+
+ });
+ window.location.href = "http://localhost:5173/schedule";
+
}
- }
- window.location.href = "http://localhost:5173/schedule";
+ }).catch((error) => {
+ console.log(error);
+ });
+
+
+
- // IdP data available using getAdditionalUserInfo(result)
- return 1
- /* .then( () => {
- redirect("./schedule")
- }) */
+ return 0
-
- // ...
}).catch((error) => {
+ console.log("there is an error here ");
// Handle Errors here.
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
- const email = error.customData.email;
+ // const email = error.customData.email;
// The AuthCredential type that was used.
const credential = GoogleAuthProvider.credentialFromError(error);
// ...
diff --git a/react/src/pages/Profile.jsx b/react/src/pages/Profile.jsx
index 24eb670..f869235 100644
--- a/react/src/pages/Profile.jsx
+++ b/react/src/pages/Profile.jsx
@@ -3,7 +3,7 @@ import Tabs from 'react-bootstrap/Tabs';
import Tab from 'react-bootstrap/Tab';
import Schedule from '../pages/Schedule';
import { Link } from 'react-router-dom';
-import Navbar from '../components/Navbar';
+import {Navbar} from "../Components/Navbar";
const Profile = () => {
@@ -17,7 +17,7 @@ const Profile = () => {
Profile page
-
+
);
}
diff --git a/react/src/pages/Schedule.jsx b/react/src/pages/Schedule.jsx
index 8541808..291f328 100644
--- a/react/src/pages/Schedule.jsx
+++ b/react/src/pages/Schedule.jsx
@@ -1,14 +1,50 @@
import { useState } from 'react';
-import Navbar from '../components/Navbar';
+import {Navbar} from "../Components/Navbar";
+import { ScheduledDrug } from '../Components/schedule/ScheduledDrug';
+import { GoogleAuthProvider, signInWithPopup, getAuth, onAuthStateChanged } from "firebase/auth";
+import { auth, app } from "../config/firebaseconfig"
+import { Link, redirect, Navigate } from 'react-router-dom';
+import { getDatabase, ref, set, off, child, get } from 'firebase/database';
-const Schedule = () => {
+
+
+const Schedule = ({user = ""}) => {
const [count, setCount] = useState(0);
const [selectedImage, setSelectedImage] = useState(null);
+ const [userdata, setuserdata] = useState("null")
+
+ console.log("hi here we are ")
+ console.log(JSON.stringify(user));
+ const userid = JSON.stringify(user);
+
+ const h1styles = "text-black text-4xl text-center text-bold";
+ const db = getDatabase();
+ const dbRef = ref(db);
+ // this currently causes a
+ get(child(dbRef, `users/${user}`)).then((snapshot) => {
+ if (snapshot.exists()) {
+ console.log("def");
+ console.log(snapshot.val());
+ setuserdata(snapshot.val());
+
+
+
+ }
+ }).catch((error) => {
+ console.log(error);
+ });
+
+
+
return (