From 9db7440bd6fa82d1a57d2ef7c1d57a367238716d Mon Sep 17 00:00:00 2001 From: EyadHeg Date: Sat, 14 Dec 2024 01:22:38 +0200 Subject: [PATCH] Update --- package-lock.json | 83 +++++++++++++++++---------------- package.json | 3 +- src/components/Singup/index.jsx | 26 ++++++++--- src/firebaseConfig.js | 18 ++++--- 4 files changed, 77 insertions(+), 53 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0215785..04fc8ff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,8 @@ "@testing-library/user-event": "^13.5.0", "axios": "^1.7.8", "chart.js": "^4.4.7", - "firebase": "^11.0.2", + "client": "file:", + "firebase": "^11.1.0", "font-awesome": "^4.7.0", "openai": "^4.75.0", "react": "^18.3.1", @@ -2540,9 +2541,9 @@ "license": "Apache-2.0" }, "node_modules/@firebase/app": { - "version": "0.10.16", - "resolved": "https://registry.npmjs.org/@firebase/app/-/app-0.10.16.tgz", - "integrity": "sha512-SUati2qH48gvVGnSsqMkZr1Iq7No52a3tJQ4itboSTM89Erezmw3v1RsfVymrDze9+KiOLmBpvLNKSvheITFjg==", + "version": "0.10.17", + "resolved": "https://registry.npmjs.org/@firebase/app/-/app-0.10.17.tgz", + "integrity": "sha512-53sIYyAnYEPIZdaxuyq5OST7j4KBc2pqmktz+tEb1BIUSbXh8Gp4k/o6qzLelLpm4ngrBz7SRN0PZJqNRAyPog==", "license": "Apache-2.0", "dependencies": { "@firebase/component": "0.6.11", @@ -2606,12 +2607,12 @@ "license": "Apache-2.0" }, "node_modules/@firebase/app-compat": { - "version": "0.2.46", - "resolved": "https://registry.npmjs.org/@firebase/app-compat/-/app-compat-0.2.46.tgz", - "integrity": "sha512-9hSHWE5LMqtKIm13CnH5OZeMPbkVV3y5vgNZ5EMFHcG2ceRrncyNjG9No5XfWQw8JponZdGs4HlE4aMD/jxcFA==", + "version": "0.2.47", + "resolved": "https://registry.npmjs.org/@firebase/app-compat/-/app-compat-0.2.47.tgz", + "integrity": "sha512-TdEWGDp6kSwuO1mxiM2Fe39eLWygfyzqTZcoU3aPV0viqqphPCbBBnVjPbFJErZ4+yaS7uCWXEbFEP9m5/COKA==", "license": "Apache-2.0", "dependencies": { - "@firebase/app": "0.10.16", + "@firebase/app": "0.10.17", "@firebase/component": "0.6.11", "@firebase/logger": "0.4.4", "@firebase/util": "1.10.2", @@ -2700,9 +2701,9 @@ } }, "node_modules/@firebase/data-connect": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/@firebase/data-connect/-/data-connect-0.1.2.tgz", - "integrity": "sha512-Bcf29mntFCt5V7aceMe36wnkHrG7cwbMlUVbDHOlh2foQKx9VtSXEONw9r6FtL1sFobHVYOM5L6umX35f59m5g==", + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@firebase/data-connect/-/data-connect-0.1.3.tgz", + "integrity": "sha512-FbAQpWNHownJx1VTCQI4ydbWGOZmSWXoFlirQn3ItHqsLJYSywqxSgDafzvyooifFh3J/2WqaM8y9hInnPcsTw==", "license": "Apache-2.0", "dependencies": { "@firebase/auth-interop-types": "0.2.4", @@ -2811,9 +2812,9 @@ } }, "node_modules/@firebase/functions": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/@firebase/functions/-/functions-0.11.10.tgz", - "integrity": "sha512-TP+Dzebazhw6+GduBdWn1kOJRFH84G2z+BW3pNVfkpFRkc//+uT1Uw2+dLpMGSSBRG7FrcDG91vcPnOFCzr15w==", + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@firebase/functions/-/functions-0.12.0.tgz", + "integrity": "sha512-plTtzY/nT0jOgHzT0vB9qch4FpHFOhCnR8HhYBqqdArG6GOQMIruKZbiTyLybO8bcaaNgQ6kSm9yohGUwxHcIw==", "license": "Apache-2.0", "dependencies": { "@firebase/app-check-interop-types": "0.3.3", @@ -2831,13 +2832,13 @@ } }, "node_modules/@firebase/functions-compat": { - "version": "0.3.16", - "resolved": "https://registry.npmjs.org/@firebase/functions-compat/-/functions-compat-0.3.16.tgz", - "integrity": "sha512-FL7EXehiiBisNIR7mlb0i+moyWKLVfcEJgh/Wq6ZV6BdrCObpCTz7w5EvuRIEFX5e9cNL2oWInKg8S5X4HtINg==", + "version": "0.3.17", + "resolved": "https://registry.npmjs.org/@firebase/functions-compat/-/functions-compat-0.3.17.tgz", + "integrity": "sha512-oj2XV8YsJYutyPCRYUfbN6swmfrL6zar0/qtqZsKT7P7btOiYRl+lD6fxtQaT+pKE5YgOBGZW//kLPZfY0jWhw==", "license": "Apache-2.0", "dependencies": { "@firebase/component": "0.6.11", - "@firebase/functions": "0.11.10", + "@firebase/functions": "0.12.0", "@firebase/functions-types": "0.6.3", "@firebase/util": "1.10.2", "tslib": "^2.1.0" @@ -2908,9 +2909,9 @@ } }, "node_modules/@firebase/messaging": { - "version": "0.12.14", - "resolved": "https://registry.npmjs.org/@firebase/messaging/-/messaging-0.12.14.tgz", - "integrity": "sha512-cSGP34jJswFvME8tdMDkvJvW6T1jEekyMSyq84AMBZ0KEpJbDWuC9n4wKT2lxUm1jaL651iZnn6g51yCl77ICg==", + "version": "0.12.15", + "resolved": "https://registry.npmjs.org/@firebase/messaging/-/messaging-0.12.15.tgz", + "integrity": "sha512-Bz+qvWNEwEWAbYtG4An8hgcNco6NWNoNLuLbGVwPL2fAoCF1zz+dcaBp+iTR2+K199JyRyDT9yDPAXhNHNDaKQ==", "license": "Apache-2.0", "dependencies": { "@firebase/component": "0.6.11", @@ -2925,13 +2926,13 @@ } }, "node_modules/@firebase/messaging-compat": { - "version": "0.2.14", - "resolved": "https://registry.npmjs.org/@firebase/messaging-compat/-/messaging-compat-0.2.14.tgz", - "integrity": "sha512-r9weK8jTEA2aGiwy0IbMQPnzuJ0DHkOQaMxGJOlU2QZ1a7fh6RHpNtaoM+LKnn6u1NQgmAOWYNr9vezVQEm9zw==", + "version": "0.2.15", + "resolved": "https://registry.npmjs.org/@firebase/messaging-compat/-/messaging-compat-0.2.15.tgz", + "integrity": "sha512-mEKKASRvRWq1aBNHgioGsOYR2c5nBZpO7k90K794zjKe0WkGNf0k7PLs5SlCf8FKnzumEkhTAp/SjYxovuxa8A==", "license": "Apache-2.0", "dependencies": { "@firebase/component": "0.6.11", - "@firebase/messaging": "0.12.14", + "@firebase/messaging": "0.12.15", "@firebase/util": "1.10.2", "tslib": "^2.1.0" }, @@ -3082,9 +3083,9 @@ } }, "node_modules/@firebase/vertexai": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@firebase/vertexai/-/vertexai-1.0.1.tgz", - "integrity": "sha512-f48MGSofhaS05ebpN7zMIv4tBqYf19pXr5/4njKtNZVLbjxUswDma0SuFDoO+IwgbdkhFxgtNctM+C1zfI/O1Q==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@firebase/vertexai/-/vertexai-1.0.2.tgz", + "integrity": "sha512-4dC9m2nD0tkfKJT5v+i27tELrmUePjFXW3CDAxhVHUEv647B2R7kqpGQnyPkNEeaXkCr76THe7GGg35EWn4lDw==", "license": "Apache-2.0", "dependencies": { "@firebase/app-check-interop-types": "0.3.3", @@ -6775,6 +6776,10 @@ "node": ">=0.10.0" } }, + "node_modules/client": { + "resolved": "", + "link": true + }, "node_modules/cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", @@ -9392,31 +9397,31 @@ } }, "node_modules/firebase": { - "version": "11.0.2", - "resolved": "https://registry.npmjs.org/firebase/-/firebase-11.0.2.tgz", - "integrity": "sha512-w4T8BSJpzdZA25QRch5ahLsgB6uRvg1LEic4BaC5rTD1YygroI1AXp+W+rbMnr8d8EjfAv6t4k8doULIjc1P8Q==", + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/firebase/-/firebase-11.1.0.tgz", + "integrity": "sha512-3OoNW3vBXmBLYJvcwbPCwfluptbDVp2zZYjrfHPVFAXfPgmyy/LWjidt+Sw2WNvRelsG0v++WN2Wor6J3OwDRg==", "license": "Apache-2.0", "dependencies": { "@firebase/analytics": "0.10.10", "@firebase/analytics-compat": "0.2.16", - "@firebase/app": "0.10.16", + "@firebase/app": "0.10.17", "@firebase/app-check": "0.8.10", "@firebase/app-check-compat": "0.3.17", - "@firebase/app-compat": "0.2.46", + "@firebase/app-compat": "0.2.47", "@firebase/app-types": "0.9.3", "@firebase/auth": "1.8.1", "@firebase/auth-compat": "0.5.16", - "@firebase/data-connect": "0.1.2", + "@firebase/data-connect": "0.1.3", "@firebase/database": "1.0.10", "@firebase/database-compat": "2.0.1", "@firebase/firestore": "4.7.5", "@firebase/firestore-compat": "0.3.40", - "@firebase/functions": "0.11.10", - "@firebase/functions-compat": "0.3.16", + "@firebase/functions": "0.12.0", + "@firebase/functions-compat": "0.3.17", "@firebase/installations": "0.6.11", "@firebase/installations-compat": "0.2.11", - "@firebase/messaging": "0.12.14", - "@firebase/messaging-compat": "0.2.14", + "@firebase/messaging": "0.12.15", + "@firebase/messaging-compat": "0.2.15", "@firebase/performance": "0.6.11", "@firebase/performance-compat": "0.2.11", "@firebase/remote-config": "0.4.11", @@ -9424,7 +9429,7 @@ "@firebase/storage": "0.13.4", "@firebase/storage-compat": "0.3.14", "@firebase/util": "1.10.2", - "@firebase/vertexai": "1.0.1" + "@firebase/vertexai": "1.0.2" } }, "node_modules/flat-cache": { diff --git a/package.json b/package.json index 9c9dd81..b2cc8a9 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "@testing-library/user-event": "^13.5.0", "axios": "^1.7.8", "chart.js": "^4.4.7", - "firebase": "^11.0.2", + "client": "file:", + "firebase": "^11.1.0", "font-awesome": "^4.7.0", "openai": "^4.75.0", "react": "^18.3.1", diff --git a/src/components/Singup/index.jsx b/src/components/Singup/index.jsx index 65b1df6..35d10a2 100644 --- a/src/components/Singup/index.jsx +++ b/src/components/Singup/index.jsx @@ -1,8 +1,9 @@ import { useState } from "react"; import { Link, useNavigate } from "react-router-dom"; -import { createUserWithEmailAndPassword, updateProfile } from "firebase/auth"; // استيراد updateProfile +import { createUserWithEmailAndPassword, updateProfile } from "firebase/auth"; +import { ref, set } from "firebase/database"; // Import Realtime Database functions import styles from "./styles.module.css"; -import { auth } from "../../firebaseConfig"; // استيراد firebase auth +import { auth, realTimeDb } from "../../firebaseConfig"; // Import realTimeDb const Signup = () => { const [data, setData] = useState({ @@ -30,13 +31,26 @@ const Signup = () => { return; } try { - // استخدام Firebase Auth لإنشاء حساب جديد + // Create the user with Firebase Auth const userCredential = await createUserWithEmailAndPassword(auth, data.email, data.password); const user = userCredential.user; - // تحديث اسم المستخدم + // Update the user's profile with the full name await updateProfile(user, { displayName: data.fullName }); - + + // Store user data in Firebase Realtime Database + const userRef = ref(realTimeDb, 'Users/' + user.uid); // Use the user's UID as the unique key + await set(userRef, { + fullName: data.fullName, + email: data.email, + age: data.age, + weight: data.weight, + gender: data.gender, + height: data.height, + healthConditions: data.healthConditions, + }); + + // Navigate to the login page after successful signup navigate("/login"); } catch (error) { setError(error.message); @@ -154,4 +168,4 @@ const Signup = () => { ); }; -export default Signup; \ No newline at end of file +export default Signup; diff --git a/src/firebaseConfig.js b/src/firebaseConfig.js index 387a560..30c7207 100644 --- a/src/firebaseConfig.js +++ b/src/firebaseConfig.js @@ -1,24 +1,28 @@ -import { initializeApp } from "firebase/app"; +import { initializeApp } from "firebase/app"; // Initialize Firebase app first import { getAuth, GoogleAuthProvider, FacebookAuthProvider } from "firebase/auth"; -import { getFirestore } from "firebase/firestore"; // استيراد Firestore +import { getFirestore } from "firebase/firestore"; +import { getDatabase } from "firebase/database"; // For Realtime Database +// Firebase configuration object const firebaseConfig = { apiKey: "AIzaSyDc1iS4NX2um7sqJuYRSll9Il_7V6g6LsE", authDomain: "graduatinproject.firebaseapp.com", projectId: "graduatinproject", - storageBucket: "graduatinproject.appspot.com", // تأكد من صحة الـ storageBucket + storageBucket: "graduatinproject.appspot.com", messagingSenderId: "361149223809", appId: "1:361149223809:web:58467e248f81422f97ce80", measurementId: "G-NRG6TMTB8Q", + databaseURL: "https://graduatinproject-default-rtdb.europe-west1.firebasedatabase.app", // Add this line }; -// Initialize Firebase +// Initialize Firebase app const app = initializeApp(firebaseConfig); -// Get Firebase services +// Now initialize Firebase services (auth, firestore, etc.) const auth = getAuth(app); const googleProvider = new GoogleAuthProvider(); const facebookProvider = new FacebookAuthProvider(); -const db = getFirestore(app); // تهيئة Firestore +const db = getFirestore(app); // Firestore +const realTimeDb = getDatabase(app); // Realtime Database -export { auth, googleProvider, facebookProvider, db }; // تصدير auth و db و المزودين +export { auth, googleProvider, facebookProvider, db, realTimeDb };