-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirebase.js
More file actions
38 lines (35 loc) · 1.35 KB
/
firebase.js
File metadata and controls
38 lines (35 loc) · 1.35 KB
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
// Firebase CDN se imports
import { initializeApp } from "https://www.gstatic.com/firebasejs/11.0.1/firebase-app.js";
import { getAnalytics } from "https://www.gstatic.com/firebasejs/11.0.1/firebase-analytics.js";
import { getFirestore, collection, addDoc } from "https://www.gstatic.com/firebasejs/11.0.1/firebase-firestore.js";
// ✅ Tumhara Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyD92frz37hrVxgDtPVHnh_x9lMpYZhjxkA",
authDomain: "my-portfolio-a634f.firebaseapp.com",
projectId: "my-portfolio-a634f",
storageBucket: "my-portfolio-a634f.firebasestorage.app",
messagingSenderId: "800825516478",
appId: "1:800825516478:web:472d424e30df4271c859ef",
measurementId: "G-1F75TFLP9R"
};
// ✅ Firebase initialize
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
const db = getFirestore(app);
// ✅ Message save karne ka function
export async function saveMessage(name, email, phone, subject, message) {
try {
await addDoc(collection(db, "messages"), {
name: name,
email: email,
phone: phone,
subject: subject,
message: message,
timestamp: new Date() // ⏱ save time for record
});
alert("Thanks For Contacting Me! I will get back to you soon.");
} catch (error) {
console.error("Try again plzzz ", error);
alert("Failed to Contact. Please try again.");
}
}