-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreategroup.js
61 lines (39 loc) · 1.47 KB
/
creategroup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const firebaseConfig = {
apiKey: "AIzaSyCRKhILK71bGnVztKmfJc7YjQeJ_IBWoUA",
authDomain: "event-planner-96e0c.firebaseapp.com",
projectId: "event-planner-96e0c",
storageBucket: "event-planner-96e0c.appspot.com",
messagingSenderId: "987785968697",
appId: "1:987785968697:web:435b4162f3f87b947761e8"
};
// Initialize Firebase
const app = firebase.initializeApp(firebaseConfig);
const auth = firebase.auth();
const db = firebase.firestore();
db.settings({ timestampsInSnapshots : true});
//create group form
const submit = document.querySelector(".creategroup-button");
const groupform = document.querySelector(".create-group-form");
groupform.addEventListener('submit', (e) => {
e.preventDefault();
const username = document.querySelector("#username");
const eventtype = document.querySelector("#event-type");
const eventcelebrator = document.querySelector("#event-celebrator");
const password = document.querySelector("#password");
const date = document.querySelector("#date");
const id = Date.now()
// Saving the data to the database
db.collection('Group-Form').doc('_'+id).set( {
username: username.value,
eventtype: eventtype.value,
eventcelebrator: eventcelebrator.value,
groupId: '_'+id,
password: password.value,
date: date.value,
}).then(() => {
groupform.reset();
window.location.assign('groupsinfo.html');
}).catch(err => {
console.log(err);
});
});