I want users to be able to join a
specific group by clicking on a "Join Group" button located at the particular group's screen. I've created a member model in firestore where I wrote the below code but it does'nt work.
What I have tried:
//Adding a member model
export function addMember (addComplete, member) {
const user = firebase.auth().currentUser;
let member_id = firebase.auth().currentUser.uid
const {currentUser} = firebase.auth()
firebase.firestore()
.collection('members')
.add({
member: member_id,
email: currentUser.email,
createdAt: firebase.firestore.Timestamp.fromDate(new Date()),
}).then((snapshot) => snapshot.get()
).then((memberData) => addComplete(memberData.data()))
.catch((error) =>console.log(error));
}
Basically, anytime I clicked on the "Join Group" button, the current user is being added to all the groups instead of a single group.