Solved a bug related to the Batch Create User

This commit is contained in:
Tiago Ribeiro
2024-09-02 14:28:38 +01:00
parent b6c3754b40
commit 7c0e7ef53e

View File

@@ -122,7 +122,7 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
} }
if (!!corporate) { if (!!corporate) {
const corporateQ = query(collection(db, "users"), where("email", "==", corporate)); const corporateQ = query(collection(db, "users"), where("email", "==", corporate.trim().toLowerCase()));
const corporateSnapshot = await getDocs(corporateQ); const corporateSnapshot = await getDocs(corporateQ);
if (!corporateSnapshot.empty) { if (!corporateSnapshot.empty) {
@@ -146,6 +146,16 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
participants: [...participants, userId], participants: [...participants, userId],
}); });
} }
} else {
const defaultGroup: Group = {
admin: corporateUser.id,
id: v4(),
name: type === "student" ? "Students" : "Teachers",
participants: [userId],
disableEditing: true,
};
await setDoc(doc(db, "groups", defaultGroup.id), defaultGroup);
} }
} }
} }