-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.html
More file actions
438 lines (392 loc) · 18.8 KB
/
Copy pathprofile.html
File metadata and controls
438 lines (392 loc) · 18.8 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HBazaar - My Profile</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap"
rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link rel="stylesheet" href="css/style.css">
<style>
.profile-container {
display: grid;
grid-template-columns: 250px 1fr;
gap: 2rem;
min-height: 80vh;
margin-top: 2rem;
}
@media (max-width: 768px) {
.profile-container {
grid-template-columns: 1fr;
}
}
.profile-sidebar {
background: var(--glass-bg);
backdrop-filter: blur(20px);
border: 1px solid var(--glass-border);
border-radius: var(--radius-lg);
padding: 1.5rem;
height: fit-content;
}
.profile-menu-item {
display: block;
padding: 1rem;
color: var(--text-secondary);
text-decoration: none;
border-radius: var(--radius-sm);
transition: all 0.3s;
margin-bottom: 0.5rem;
cursor: pointer;
}
.profile-menu-item:hover,
.profile-menu-item.active {
background: rgba(255, 255, 255, 0.05);
color: var(--text-primary);
}
.profile-menu-item.active {
border-left: 3px solid var(--accent-primary);
}
.profile-content {
background: var(--glass-bg);
backdrop-filter: blur(20px);
border: 1px solid var(--glass-border);
border-radius: var(--radius-lg);
padding: 2rem;
}
.profile-section {
display: none;
}
.profile-section.active {
display: block;
animation: fadeIn 0.4s ease;
}
.form-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1.5rem;
}
@media (max-width: 600px) {
.form-grid {
grid-template-columns: 1fr;
}
}
.form-group {
margin-bottom: 1.5rem;
}
.form-group label {
display: block;
margin-bottom: 0.5rem;
color: var(--text-secondary);
}
.form-group input {
width: 100%;
padding: 12px;
background: rgba(0, 0, 0, 0.3);
border: 1px solid var(--glass-border);
border-radius: var(--radius-sm);
color: var(--text-primary);
}
.section-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 2rem;
border-bottom: 1px solid var(--glass-border);
padding-bottom: 1rem;
}
</style>
</head>
<body>
<div class="background-globes">
<div class="globe globe-1"></div>
<div class="globe globe-2"></div>
</div>
<!-- Mobile Navigation Overlay -->
<div class="mobile-nav-overlay" id="mobileNavOverlay">
<div class="mobile-nav-drawer">
<div class="mobile-nav-header">
<div class="mobile-nav-title">Menu</div>
<button class="close-menu-btn" id="closeMenuBtn"><i class="fa-solid fa-times"></i></button>
</div>
<nav class="mobile-links">
<a href="index.html" class="mobile-link"><i class="fa-solid fa-home"></i> Home</a>
<a href="shop.html" class="mobile-link"><i class="fa-solid fa-store"></i> Shop</a>
<a href="profile.html" class="mobile-link active"><i class="fa-solid fa-user"></i> Profile</a>
<a href="orders.html" class="mobile-link"><i class="fa-solid fa-box"></i> Orders</a>
</nav>
</div>
</div>
<div class="app-container">
<!-- Header -->
<header class="glass-header">
<a href="index.html" class="logo" style="text-decoration: none;">
<i class="fa-solid fa-shapes"></i>
<span>HBazaar</span>
</a>
<!-- Desktop Nav -->
<nav class="desktop-nav">
<a href="index.html" class="nav-link">Home</a>
<a href="shop.html" class="nav-link">Shop</a>
<a href="orders.html" class="nav-link">Orders</a>
<!-- Cart/Profile injected by app.js -->
<div class="cart-btn" id="cartBtn">
<i class="fa-solid fa-shopping-cart"></i>
<span class="cart-badge hidden" id="cartBadge">0</span>
</div>
</nav>
<!-- Mobile Actions -->
<div style="display: flex; align-items: center; gap: 15px;" class="mobile-only-actions">
<div class="cart-btn" style="display: none;" id="mobileCartBtn">
<i class="fa-solid fa-shopping-cart"></i>
</div>
<button class="mobile-menu-btn" id="mobileMenuBtn">
<i class="fa-solid fa-bars"></i>
</button>
</div>
<style>
@media (max-width: 768px) {
#mobileCartBtn {
display: block !important;
}
}
</style>
</header>
<!-- Main Content -->
<main class="profile-container">
<aside class="profile-sidebar">
<div style="text-align: center; margin-bottom: 2rem;">
<div
style="width: 80px; height: 80px; background: var(--accent-primary); border-radius: 50%; margin: 0 auto 1rem; display: flex; align-items: center; justify-content: center; font-size: 2rem;">
<i class="fa-solid fa-user"></i>
</div>
<h3 id="sidebarName">User</h3>
<p id="sidebarEmail" style="font-size: 0.9rem; color: var(--text-secondary);">user@example.com</p>
</div>
<div class="profile-menu-item active" data-target="personal-info">
<i class="fa-solid fa-id-card"></i> Personal Info
</div>
<div class="profile-menu-item" data-target="address-book">
<i class="fa-solid fa-map-marker-alt"></i> Address Book
</div>
<a href="orders.html" class="profile-menu-item">
<i class="fa-solid fa-box-open"></i> My Orders
</a>
<div class="profile-menu-item" id="logoutBtn"
style="color: #ff4081; margin-top: 1rem; border: 1px solid rgba(255, 64, 129, 0.2);">
<i class="fa-solid fa-sign-out-alt"></i> Logout
</div>
</aside>
<section class="profile-content">
<!-- Personal Info Section -->
<div id="personal-info" class="profile-section active">
<div class="section-header">
<h2>Personal Information</h2>
<button class="premium-btn" id="saveProfileBtn">Save Changes</button>
</div>
<form id="profileForm">
<div class="form-grid">
<div class="form-group">
<label>Full Name</label>
<input type="text" id="profName" placeholder="Your Name">
</div>
<div class="form-group">
<label>Phone Number</label>
<input type="tel" id="profPhone" placeholder="+91 99999 99999">
</div>
</div>
<div class="form-group">
<label>Email Address</label>
<input type="email" id="profEmail" placeholder="email@example.com" disabled
style="opacity: 0.7; cursor: not-allowed;">
<small style="color: var(--text-secondary);">Email cannot be changed.</small>
</div>
</form>
</div>
<!-- Address Book Section -->
<div id="address-book" class="profile-section">
<div class="section-header">
<h2>Address Book</h2>
<button class="premium-btn" id="addNewAddressBtn" style="font-size:0.9rem;">+ Add New</button>
</div>
<div id="addressList"
style="display:grid; grid-template-columns:repeat(auto-fill, minmax(280px, 1fr)); gap:1rem; margin-bottom:2rem;">
<!-- Addresses injected here -->
</div>
<div id="newAddressForm"
style="display:none; background:rgba(0,0,0,0.2); padding:1.5rem; border-radius:10px; border:1px solid var(--glass-border);">
<h3 style="margin-bottom:1rem;">Add New Address</h3>
<form id="addAddressForm">
<div class="form-group">
<label>Address Label (e.g. Home, Office)</label>
<input type="text" id="addrLabel" placeholder="Home">
</div>
<div class="form-group">
<label>Street Address</label>
<input type="text" id="addrStreet" placeholder="123, Main Street, Apt 4B">
</div>
<div class="form-grid">
<div class="form-group">
<label>City</label>
<input type="text" id="addrCity" placeholder="Mumbai">
</div>
<div class="form-group">
<label>State</label>
<input type="text" id="addrState" placeholder="Maharashtra">
</div>
</div>
<div class="form-grid">
<div class="form-group">
<label>ZIP Code</label>
<input type="text" id="addrZip" placeholder="400001">
</div>
<div class="form-group">
<label>Country</label>
<input type="text" value="India" disabled>
</div>
</div>
<div style="display:flex; gap:10px;">
<button type="button" id="cancelAddressBtn" class="premium-btn"
style="background:transparent; border:1px solid var(--glass-border);">Cancel</button>
<button type="submit" class="premium-btn">Save Address</button>
</div>
</form>
</div>
</div>
</section>
</main>
</div>
<!-- Cart Modal (Reused) -->
<div class="cart-modal-overlay" id="cartModal">
<div class="cart-sidebar">
<div class="cart-header">
<h2>Your Bag</h2>
<button id="closeCartBtn"
style="background:none; border:none; color:white; font-size:1.5rem; cursor:pointer;"><i
class="fa-solid fa-times"></i></button>
</div>
<div class="cart-items" id="cartItems"></div>
<div class="cart-footer">
<div
style="display:flex; justify-content:space-between; font-size:1.2rem; font-weight:700; margin-bottom:1rem;">
<span>Total</span>
<span id="cartTotal">₹0.00</span>
</div>
<button class="checkout-btn" id="checkoutBtn">Checkout <i class="fa-solid fa-lock"
style="font-size:0.9rem; margin-left:8px; opacity:0.7;"></i></button>
</div>
</div>
</div>
<script src="js/db.js"></script>
<script src="js/app.js"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
const user = DB.getCurrentUser();
if (!user) {
window.location.href = 'login.html';
return;
}
// Populate Sidebar
document.getElementById('sidebarName').textContent = user.name || 'User';
document.getElementById('sidebarEmail').textContent = user.email;
// Populate Forms
document.getElementById('profName').value = user.name || '';
document.getElementById('profEmail').value = user.email || '';
document.getElementById('profPhone').value = user.phone || '';
if (user.address) {
// Migration support: if old single address exists, maybe show it or migration logic?
// For now, let's just rely on the new array.
}
renderAddresses();
function renderAddresses() {
const list = document.getElementById('addressList');
list.innerHTML = '';
const addresses = user.addresses || [];
if (addresses.length === 0) {
list.innerHTML = '<div style="color:var(--text-secondary); grid-column:1/-1; text-align:center; padding:2rem;">No addresses saved yet.</div>';
}
addresses.forEach(addr => {
const card = document.createElement('div');
card.className = 'glass-panel'; // reusing glass panel style if defined or just inline
card.style.background = 'rgba(255,255,255,0.05)';
card.style.padding = '1rem';
card.style.borderRadius = '10px';
card.style.position = 'relative';
card.innerHTML = `
<div style="font-weight:700; color:var(--accent-secondary); margin-bottom:5px;">${addr.label || 'Address'}</div>
<div style="font-size:0.9rem; line-height:1.4; color:var(--text-secondary);">
${addr.street}<br>
${addr.city}, ${addr.state} - ${addr.zip}
</div>
<button class="delete-addr-btn" data-id="${addr.id}" style="position:absolute; top:10px; right:10px; background:none; border:none; color:#ff4081; cursor:pointer;"><i class="fa-solid fa-trash"></i></button>
`;
card.querySelector('.delete-addr-btn').addEventListener('click', () => {
if (confirm('Delete this address?')) {
DB.removeAddress(user.id, addr.id);
window.location.reload();
}
});
list.appendChild(card);
});
}
// Tab Switching
const tabs = document.querySelectorAll('.profile-menu-item[data-target]');
const sections = document.querySelectorAll('.profile-section');
tabs.forEach(tab => {
tab.addEventListener('click', () => {
// Update Active Tab
document.querySelectorAll('.profile-menu-item').forEach(t => t.classList.remove('active'));
tab.classList.add('active');
// Show Section
const targetId = tab.dataset.target;
sections.forEach(s => s.classList.remove('active'));
document.getElementById(targetId).classList.add('active');
});
});
// Save Profile Code
document.getElementById('saveProfileBtn').addEventListener('click', () => {
const name = document.getElementById('profName').value;
const phone = document.getElementById('profPhone').value;
const result = DB.updateUser(user.id, { name, phone });
if (result.success) {
alert('Profile updated successfully!');
document.getElementById('sidebarName').textContent = name;
} else {
alert('Error updating profile');
}
});
// Add New Address UI
const newAddrForm = document.getElementById('newAddressForm');
document.getElementById('addNewAddressBtn').addEventListener('click', () => {
newAddrForm.style.display = 'block';
document.getElementById('addNewAddressBtn').style.display = 'none';
});
document.getElementById('cancelAddressBtn').addEventListener('click', () => {
newAddrForm.style.display = 'none';
document.getElementById('addNewAddressBtn').style.display = 'block';
});
document.getElementById('addAddressForm').addEventListener('submit', (e) => {
e.preventDefault();
const address = {
label: document.getElementById('addrLabel').value,
street: document.getElementById('addrStreet').value,
city: document.getElementById('addrCity').value,
state: document.getElementById('addrState').value,
zip: document.getElementById('addrZip').value
};
const result = DB.addAddress(user.id, address);
if (result.success) {
alert('Address added!');
window.location.reload();
}
});
// Logout
document.getElementById('logoutBtn').addEventListener('click', () => {
DB.logout();
});
});
</script>
</body>
</html>