-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathprofile.html
More file actions
141 lines (123 loc) · 4.57 KB
/
Copy pathprofile.html
File metadata and controls
141 lines (123 loc) · 4.57 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Your Profile - SkillForge</title>
<link rel="stylesheet" href="style.css" />
<style>
.profile-container {
padding: 2rem;
max-width: 600px;
margin: auto;
background-color: #f7f7f7;
border-radius: 12px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}
.profile-container h2 {
text-align: center;
margin-bottom: 20px;
}
.profile-details,
.exhibitions {
margin-bottom: 20px;
}
.exhibitions ul {
list-style: none;
padding: 0;
}
.exhibitions li {
padding: 8px;
background: #fff;
margin-bottom: 10px;
border-radius: 6px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}
</style>
</head>
<body>
<div class="profile-container">
<h2>Your Profile</h2>
<div class="profile-details" id="profile-details">
<!-- Profile details will go here -->
</div>
<div class="exhibitions">
<h3>Registered Exhibitions</h3>
<ul id="exhibition-list">
<!-- Registered exhibitions will be listed here -->
</ul>
</div>
</div>
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.9.0/firebase-app.js";
import {
getAuth,
onAuthStateChanged,
setPersistence,
browserLocalPersistence
} from "https://www.gstatic.com/firebasejs/10.9.0/firebase-auth.js";
import {
getFirestore,
doc,
getDoc,
collection,
query,
where,
getDocs
} from "https://www.gstatic.com/firebasejs/10.9.0/firebase-firestore.js";
const firebaseConfig = {
apiKey: "AIzaSyCYQBMwKw3StqGIJ1OP0Qnk9c0UmnatnQk",
authDomain: "skillforge-8e5b3.firebaseapp.com",
projectId: "skillforge-8e5b3",
storageBucket: "skillforge-8e5b3.appspot.com",
messagingSenderId: "126378296654",
appId: "1:126378296654:web:d3f0f7abb3fa444caf0a1f",
measurementId: "G-E6X2VQV0TN"
};
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const db = getFirestore(app);
// Ensure auth state is persistent
setPersistence(auth, browserLocalPersistence).then(() => {
onAuthStateChanged(auth, async (user) => {
if (!user) {
alert("No user logged in. Please sign in.");
window.location.href = "auth.html";
return;
}
const uid = user.uid;
const userDocRef = doc(db, "users", uid); // Assuming you store user info in a "users" collection
const userSnap = await getDoc(userDocRef);
if (userSnap.exists()) {
const data = userSnap.data();
document.getElementById("profile-details").innerHTML = `
<p><strong>Name:</strong> ${data.name || "N/A"}</p>
<p><strong>Location:</strong> ${data.location || "N/A"}</p>
<p><strong>GI Tag:</strong> ${data.giTag || "N/A"}</p>
`;
} else {
document.getElementById("profile-details").innerHTML = "<p>No profile data found.</p>";
}
// Fetch exhibitions registered by this user
const q = query(
collection(db, "exhibition_registrations"),
where("email", "==", user.email)
);
console.log("Signed in as:", user.email, "UID:", user.uid);
const querySnapshot = await getDocs(q);
const list = document.getElementById("exhibition-list");
if (querySnapshot.empty) {
list.innerHTML = "<li>No exhibitions registered yet.</li>";
} else {
querySnapshot.forEach((doc) => {
const data = doc.data();
const li = document.createElement("li");
li.textContent = `${data.artworkTitle} - ₹${data.price}`;
list.appendChild(li);
});
}
});
});
</script>
</body>
</html>