diff --git a/src/components/Admin/AdminIdentify/Identify/Form/Firebase Querys/BringAdminCode.js b/src/components/Admin/AdminIdentify/Identify/Form/Firebase Querys/BringAdminCode.js index 5199c08..5ad572f 100644 --- a/src/components/Admin/AdminIdentify/Identify/Form/Firebase Querys/BringAdminCode.js +++ b/src/components/Admin/AdminIdentify/Identify/Form/Firebase Querys/BringAdminCode.js @@ -6,7 +6,7 @@ const BringAdminCode = async () => { try { const db = getFirestore(firestore) - const data = await collection(db, 'adminCodes') + const data = await collection(db, 'users') const result = await getDocs(data) return await result.docs.map(doc => doc.data()) diff --git a/src/components/Admin/AdminIdentify/Identify/Form/Firebase Querys/RegisterNewUser.js b/src/components/Admin/AdminIdentify/Identify/Form/Firebase Querys/RegisterNewUser.js index f363ddd..d8f55df 100644 --- a/src/components/Admin/AdminIdentify/Identify/Form/Firebase Querys/RegisterNewUser.js +++ b/src/components/Admin/AdminIdentify/Identify/Form/Firebase Querys/RegisterNewUser.js @@ -1,14 +1,24 @@ import { firestore } from '../../../../../../Firebase/Firebase_Config' -import {getAuth, createUserWithEmailAndPassword} from 'firebase/auth' +import {getAuth, createUserWithEmailAndPassword, } from 'firebase/auth' +import { getFirestore, setDoc, doc } from 'firebase/firestore' -const RegisterNewUser = async (email, password, setMessage) => { +const RegisterNewUser = async (name, email, password, setMessage, position, refferCode) => { const auth = getAuth() try { - const response = await createUserWithEmailAndPassword(auth, email, password) - console.log(response) + const responseUserCreate = await createUserWithEmailAndPassword(auth, email, password) + console.log(responseUserCreate) + + const db = getFirestore(firestore) + + await setDoc(doc(db, 'users', email), { + + name: name, + position: position, + refferCode: refferCode + }) } catch (error) { setMessage('There has been an error registering the user. Please try again later') diff --git a/src/components/Admin/AdminIdentify/Identify/Form/Form.jsx b/src/components/Admin/AdminIdentify/Identify/Form/Form.jsx index 8861d64..bc7a1d4 100644 --- a/src/components/Admin/AdminIdentify/Identify/Form/Form.jsx +++ b/src/components/Admin/AdminIdentify/Identify/Form/Form.jsx @@ -8,6 +8,7 @@ const Form = () => { const [option, setOption] = useState('login') + const [name, setName] = useState('') const [email, setEmail] = useState('') const [password, setPassword] = useState('') const [confirmPassword, setConfirmPassword] = useState('') @@ -88,11 +89,19 @@ const Form = () => {