Basically I am wanting to create a new collection on a document creation if that said collection does not exist.
Here is the structure I have
-Company (Collection)
--Company Name (Doc)
---CompanyInfo (Doc)
---Users (Collection)
----Users (Docs)
This is working if I create the collection manually in firebase, but I want these to somehow create automatically when a company signs up
Here is my full code: https://pastebin.com/JeCAM3Fx
const handleCreate = (e) => {
e.preventDefault();
createUserWithEmailAndPassword(auth, email, password)
.then((userInfo) => {
setDoc(doc(db, `company/${company}/users`, userInfo.uid), {
firstName,
lastName,
email,
phone,
address,
country,
state,
company,
position,
});
console.log("You are registerd!");
})
.catch((error) => {
console.log(error.message);
});
};
I get the error cannot find indexOf() when trying to signup
I am using NextJS and Firebase 9