forked from sudhay23/firebase-gdsc-ctf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
42 lines (37 loc) · 1.22 KB
/
script.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
const firebaseConfig = {
apiKey: "AIzaSyA4SQqCf3U2vvTr_Bkbfl3bHZnGNxr1SMI",
authDomain: "inductionio-event.firebaseapp.com",
projectId: "inductionio-event",
storageBucket: "inductionio-event.appspot.com",
messagingSenderId: "101950700286",
appId: "1:101950700286:web:96dd44a34780fe43c143af",
measurementId: "G-4DYMK46ZVJ",
};
// Init app
firebase.initializeApp(firebaseConfig);
const firestore = firebase.firestore();
const reviewForm = document.querySelector("form");
const successMessage = document.querySelector(".success-message");
// Submitting the form
reviewForm.addEventListener("submit", (e) => {
e.preventDefault();
successMessage.classList.remove("show");
let name = document.getElementById("nameInput").value;
let productName = document.getElementById("productNameInput").value;
let feedback = document.getElementById("feedbackInput").value;
firestore
.collection("Reviews")
.doc()
.set({
name,
productName,
feedback,
})
.then(() => {
successMessage.classList.add("show");
reviewForm.reset();
})
.catch((err) => {
console.error(err);
});
});