-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.html
More file actions
829 lines (722 loc) · 35.1 KB
/
profile.html
File metadata and controls
829 lines (722 loc) · 35.1 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
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>StuffSwap | Profile</title>
<link rel="stylesheet" href="css/styles.css">
<script src="js/config.dev.js"></script>
<script src="js/auth.js"></script>
</head>
<body>
<!-- Top Navigation -->
<nav class="nav-bar">
<div class="nav-brand">
<span class="brand-text">Stuff</span>
<span class="brand-accent">Swap</span>
</div>
<div class="nav-links">
<a href="dashboard.html">Home</a>
<a href="whatIsStuffSwap.html">About</a>
<a href="favorites.html">Favorites</a>
<a href="cart.html">Cart</a>
<a href="profile.html" class="active">Profile</a>
</div>
<button class="logout" onclick="logout()">Logout</button>
</nav>
<!-- Main Content -->
<main class="profile-container">
<!-- Profile Overview -->
<section class="profile-overview">
<div class="profile-header">
<div class="profile-photo">
<div class="avatar" id="profileAvatar">
<span class="avatar-placeholder">👤</span>
</div>
<button class="photo-change" onclick="document.getElementById('profilePhotoInput').click()">
Change Photo
</button>
<input type="file" id="profilePhotoInput" accept="image/*" style="display: none"
onchange="handleProfilePhotoUpload(event)">
</div>
<div class="profile-info">
<h1 id="profileName">Loading...</h1>
<p class="email" id="profileEmail">loading@email.com</p>
<p class="location" id="profileLocation">📍 Location: Loading...</p>
<p class="member-since">Member since <span id="memberSince">Loading...</span></p>
</div>
</div>
<!-- Quick Stats -->
<div class="stats-section">
<div class="stat-card">
<span class="stat-value" id="itemsCount">0</span>
<span class="stat-label">Items Listed</span>
</div>
<div class="stat-card">
<span class="stat-value" id="swapsCount">0</span>
<span class="stat-label">Successful Swaps</span>
</div>
<div class="stat-card">
<span class="stat-value" id="rating">5.0</span>
<span class="stat-label">Rating</span>
</div>
</div>
</section>
<!-- Products Section -->
<section class="products-section">
<div class="section-header">
<h2>My Products</h2>
<button class="btn-primary" onclick="openAddProductModal()">
<span>+</span> Add New Product
</button>
</div>
<!-- Products Grid -->
<div class="products-container">
<div class="products-loading" id="productsLoading">
<div class="spinner"></div>
<p>Loading your products...</p>
</div>
<div class="products-empty" id="productsEmpty" style="display: none;">
<div class="empty-state">
<span class="empty-icon">📦</span>
<h3>No Products Yet</h3>
<p>Start by adding your first product to swap!</p>
<button class="btn-primary" onclick="openAddProductModal()">Add Your First Product</button>
</div>
</div>
<div class="products-grid" id="productsGrid"></div>
</div>
</section>
<!-- Settings Sections -->
<div class="settings-grid">
<!-- Personal Information -->
<section class="settings-section">
<h2>Personal Information</h2>
<form id="personalForm" class="form-section">
<div class="form-group">
<label for="username">Username</label>
<input type="text" id="username" name="username" required>
</div>
<div class="form-group">
<label for="displayName">Display Name</label>
<input type="text" id="displayName" name="displayName">
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" id="email" name="email" required>
</div>
<div class="form-row">
<div class="form-group">
<label for="zipcode">Zipcode</label>
<input type="text" id="zipcode" name="zipcode" required>
</div>
<div class="form-group">
<label for="phone">Phone (Optional)</label>
<input type="tel" id="phone" name="phone">
</div>
</div>
<div class="form-group">
<label for="bio">Bio</label>
<textarea id="bio" name="bio" rows="3"></textarea>
</div>
<button type="submit" class="btn-primary">Save Changes</button>
</form>
</section>
<!-- Account Settings -->
<div class="settings-stack">
<!-- Security -->
<section class="settings-section">
<h2>Security</h2>
<form id="securityForm" class="form-section">
<div class="form-group">
<label for="currentPassword">Current Password</label>
<input type="password" id="currentPassword" name="currentPassword">
</div>
<div class="form-group">
<label for="newPassword">New Password</label>
<input type="password" id="newPassword" name="newPassword">
</div>
<div class="form-group">
<label for="confirmPassword">Confirm Password</label>
<input type="password" id="confirmPassword" name="confirmPassword">
</div>
<button type="submit" class="btn-primary">Update Password</button>
</form>
</section>
<!-- Preferences -->
<section class="settings-section">
<h2>Preferences</h2>
<div class="preferences-list">
<label class="toggle-switch">
<input type="checkbox" id="emailNotifications" checked>
<span class="toggle-slider"></span>
<span class="toggle-label">Email Notifications</span>
</label>
<label class="toggle-switch">
<input type="checkbox" id="locationSharing" checked>
<span class="toggle-slider"></span>
<span class="toggle-label">Location Sharing</span>
</label>
<label class="toggle-switch">
<input type="checkbox" id="publicProfile">
<span class="toggle-slider"></span>
<span class="toggle-label">Public Profile</span>
</label>
</div>
</section>
<!-- Account Actions -->
<section class="settings-section">
<h2>Account Actions</h2>
<div class="action-buttons">
<button onclick="exportData()" class="btn-secondary">Export Data</button>
<button onclick="deleteAccount()" class="btn-danger">Delete Account</button>
</div>
</section>
</div>
</div>
</main>
<!-- Add/Edit Product Modal -->
<div class="modal" id="productModal" style="display: none;">
<div class="modal-content">
<div class="modal-header">
<h2 id="modalTitle">Add New Product</h2>
<button class="modal-close" onclick="closeProductModal()">×</button>
</div>
<form id="productForm" class="form-section">
<div class="form-group">
<label for="productName">Product Name*</label>
<input type="text" id="productName" name="productName" required>
</div>
<div class="form-row">
<div class="form-group">
<label for="productCategory">Category*</label>
<select id="productCategory" name="productCategory" required>
<option value="">Select Category</option>
<option value="clothes">Clothes</option>
<option value="furniture">Furniture</option>
<option value="electronics">Electronics</option>
<option value="books">Books</option>
<option value="toys">Toys</option>
<option value="sports">Sports</option>
<option value="other">Other</option>
</select>
</div>
<div class="form-group">
<label for="productCondition">Condition*</label>
<select id="productCondition" name="productCondition" required>
<option value="">Select Condition</option>
<option value="new">New</option>
<option value="like-new">Like New</option>
<option value="good">Good</option>
<option value="fair">Fair</option>
<option value="poor">Poor</option>
</select>
</div>
</div>
<div class="form-group">
<label for="productValue">Estimated Value ($)*</label>
<input type="number" id="productValue" name="productValue" min="0" step="0.01" required>
</div>
<div class="form-group">
<label for="productDescription">Description*</label>
<textarea id="productDescription" name="productDescription" rows="3" required></textarea>
</div>
<div class="form-group">
<label for="productImages">Product Images</label>
<div class="file-upload">
<input type="file" id="productImages" name="productImages" accept="image/*" multiple>
<div class="upload-placeholder">
<span class="upload-icon">📸</span>
<span>Click to upload images</span>
<span class="upload-hint">You can select multiple images</span>
</div>
</div>
<div id="imagePreview" class="image-preview"></div>
</div>
<div class="form-group">
<label for="productTags">Tags (Optional)</label>
<input type="text" id="productTags" name="productTags"
placeholder="Enter tags separated by commas (e.g., vintage, handmade)">
</div>
<div class="form-actions">
<button type="button" class="btn-secondary" onclick="closeProductModal()">Cancel</button>
<button type="submit" class="btn-primary">Save Product</button>
</div>
</form>
</div>
</div>
<!-- Toast Container for Notifications -->
<div id="toastContainer"></div>
<!-- Product Management Scripts -->
<script>
function toggleNav() {
document.getElementById("navLinks").classList.toggle("show");
}
// Load user profile data when page loads
document.addEventListener('DOMContentLoaded', async () => {
try {
const user = await Auth.getCurrentUser();
if (user) {
loadUserProfile(user);
loadProducts(); // Load products on profile load
} else {
window.location.href = 'login.html';
}
} catch (error) {
console.error('Error loading profile:', error);
window.location.href = 'login.html';
}
});
async function loadUserProfile(user) {
try {
// Update profile header
document.getElementById('profileName').textContent = user.user_metadata?.username || user.email?.split('@')[0] || 'User';
document.getElementById('profileEmail').textContent = user.email || 'No email';
document.getElementById('profileLocation').textContent = '📍 Location: Not set';
document.getElementById('memberSince').textContent = new Date(user.created_at).toLocaleDateString();
// Load form data
document.getElementById('email').value = user.email || '';
document.getElementById('username').value = user.user_metadata?.username || '';
document.getElementById('displayName').value = user.user_metadata?.display_name || '';
// Load profile data from database
const supabase = await Auth.initializeSupabase();
const { data: profile, error } = await supabase
.from('profiles')
.select('*')
.eq('id', user.id)
.single();
if (error) throw error;
if (profile) {
document.getElementById('zipcode').value = profile.zipcode || '';
document.getElementById('phone').value = profile.phone || '';
document.getElementById('bio').value = profile.bio || '';
document.getElementById('profileLocation').textContent = `📍 Location: ${profile.zipcode || 'Not set'}`;
// Load profile photo if exists
const avatarElement = document.getElementById('profileAvatar');
if (profile.avatar_url) {
avatarElement.innerHTML = `
<img src="${profile.avatar_url}"
alt="Profile Photo"
onerror="this.src='https://via.placeholder.com/150?text=👤';this.onerror=null;"
style="width: 100%; height: 100%; border-radius: 50%; object-fit: cover;">
`;
} else {
avatarElement.innerHTML = `<span class="avatar-placeholder">👤</span>`;
}
}
} catch (error) {
console.error('Error loading profile:', error);
showToast('Failed to load profile data', 'error');
}
}
async function handleProfilePhotoUpload(event) {
const file = event.target.files[0];
if (!file) return;
// Validate file type and size
if (!file.type.startsWith('image/')) {
showToast('Please select an image file.', 'error');
return;
}
if (file.size > 5 * 1024 * 1024) { // 5MB limit
showToast('Image size must be less than 5MB.', 'error');
return;
}
try {
const user = await Auth.getCurrentUser();
if (!user) {
showToast('Please log in to update profile photo.', 'error');
return;
}
const supabase = await Auth.initializeSupabase();
// Show loading state
const avatarElement = document.getElementById('profileAvatar');
const originalContent = avatarElement.innerHTML;
avatarElement.innerHTML = '<div class="spinner"></div>';
// Upload image to Supabase Storage
const fileExt = file.name.split('.').pop();
const fileName = `${user.id}-${Date.now()}.${fileExt}`;
const filePath = `avatars/${fileName}`;
// Delete old avatar if exists
const { data: profile } = await supabase
.from('profiles')
.select('avatar_url')
.eq('id', user.id)
.single();
if (profile?.avatar_url) {
const oldFileName = profile.avatar_url.split('/').pop();
await supabase.storage
.from('avatars')
.remove([`avatars/${oldFileName}`]);
}
// Upload new avatar
const { error: uploadError, data: uploadData } = await supabase.storage
.from('avatars')
.upload(filePath, file);
if (uploadError) throw uploadError;
// Get public URL
const { data: { publicUrl } } = supabase.storage
.from('avatars')
.getPublicUrl(filePath);
// Update profile with new photo URL
const { error: updateError } = await supabase
.from('profiles')
.upsert({
id: user.id,
avatar_url: publicUrl,
updated_at: new Date().toISOString()
});
if (updateError) throw updateError;
// Update UI
avatarElement.innerHTML = `
<img src="${publicUrl}"
alt="Profile Photo"
onerror="this.src='https://via.placeholder.com/150?text=👤';this.onerror=null;"
style="width: 100%; height: 100%; border-radius: 50%; object-fit: cover;">
`;
showToast('Profile photo updated successfully!', 'success');
} catch (error) {
console.error('Error uploading profile photo:', error);
showToast('Failed to upload profile photo. Please try again.', 'error');
// Restore original avatar content on error
const avatarElement = document.getElementById('profileAvatar');
avatarElement.innerHTML = `
<span class="avatar-placeholder">👤</span>
`;
}
}
// Handle personal information form submission
document.getElementById('personalForm').addEventListener('submit', async (e) => {
e.preventDefault();
const submitButton = e.target.querySelector('.save-button');
const originalText = submitButton.textContent;
submitButton.textContent = 'Updating...';
submitButton.disabled = true;
try {
const user = await Auth.getCurrentUser();
const supabase = await Auth.initializeSupabase();
const formData = {
username: document.getElementById('username').value,
display_name: document.getElementById('displayName').value,
email: document.getElementById('email').value,
zipcode: document.getElementById('zipcode').value,
phone: document.getElementById('phone').value,
bio: document.getElementById('bio').value
};
// Update profile in database
const { error } = await supabase
.from('profiles')
.upsert({
id: user.id,
...formData,
updated_at: new Date().toISOString()
});
if (error) throw error;
alert('Profile updated successfully!');
loadUserProfile(user); // Reload profile data
} catch (error) {
console.error('Error updating profile:', error);
alert('Failed to update profile. Please try again.');
} finally {
submitButton.textContent = originalText;
submitButton.disabled = false;
}
});
// Handle security form submission
document.getElementById('securityForm').addEventListener('submit', async (e) => {
e.preventDefault();
const currentPassword = document.getElementById('currentPassword').value;
const newPassword = document.getElementById('newPassword').value;
const confirmPassword = document.getElementById('confirmPassword').value;
if (newPassword !== confirmPassword) {
alert('New passwords do not match!');
return;
}
const submitButton = e.target.querySelector('.save-button');
const originalText = submitButton.textContent;
submitButton.textContent = 'Changing...';
submitButton.disabled = true;
try {
const supabase = await Auth.initializeSupabase();
// Update password
const { error } = await supabase.auth.updateUser({
password: newPassword
});
if (error) throw error;
alert('Password changed successfully!');
e.target.reset();
} catch (error) {
console.error('Error changing password:', error);
alert('Failed to change password. Please try again.');
} finally {
submitButton.textContent = originalText;
submitButton.disabled = false;
}
});
// Account action functions
async function logout() {
if (confirm('Are you sure you want to logout?')) {
try {
await Auth.signOut();
window.location.href = 'login.html';
} catch (error) {
console.error('Logout error:', error);
alert('Logout failed. Please try again.');
}
}
}
function exportData() {
alert('Data export feature coming soon!');
}
function deleteAccount() {
if (confirm('Are you sure you want to delete your account? This action cannot be undone.')) {
alert('Account deletion feature coming soon!');
}
}
// Handle preference changes
document.querySelectorAll('.preference-item input[type="checkbox"]').forEach(checkbox => {
checkbox.addEventListener('change', function() {
console.log(`${this.id}: ${this.checked}`);
// Save preferences to database
});
});
// Product Modal Functions
function openAddProductModal() {
document.getElementById('modalTitle').textContent = 'Add New Product';
document.getElementById('productForm').reset();
document.getElementById('imagePreview').innerHTML = '';
document.getElementById('productModal').style.display = 'flex';
}
function closeProductModal() {
document.getElementById('productModal').style.display = 'none';
}
// Handle product form submission
document.getElementById('productForm').addEventListener('submit', async (e) => {
e.preventDefault();
const submitButton = e.target.querySelector('button[type="submit"]');
const originalText = submitButton.textContent;
submitButton.textContent = 'Saving...';
submitButton.disabled = true;
try {
const user = await Auth.getCurrentUser();
if (!user) throw new Error('Please log in to add products');
const supabase = await Auth.initializeSupabase();
const formData = new FormData(e.target);
// Handle image uploads
const imageFiles = document.getElementById('productImages').files;
const imageUrls = [];
if (imageFiles.length > 0) {
for (let i = 0; i < imageFiles.length; i++) {
const file = imageFiles[i];
const fileExt = file.name.split('.').pop();
const fileName = `${user.id}-${Date.now()}-${i}.${fileExt}`;
const filePath = `product-images/${fileName}`;
const { error: uploadError } = await supabase.storage
.from('product-images')
.upload(filePath, file);
if (uploadError) throw uploadError;
const { data: { publicUrl } } = supabase.storage
.from('product-images')
.getPublicUrl(filePath);
imageUrls.push(publicUrl);
}
}
// Prepare product data
const productData = {
name: formData.get('productName'),
category: formData.get('productCategory'),
condition: formData.get('productCondition'),
value: parseFloat(formData.get('productValue')),
description: formData.get('productDescription'),
tags: formData.get('productTags'),
image_urls: imageUrls,
main_image_url: imageUrls[0] || null,
owner_id: user.id,
status: 'available'
};
// Insert product using the secure function
const { data: productId, error } = await supabase
.rpc('insert_user_item', {
p_name: productData.name,
p_description: productData.description,
p_category: productData.category,
p_condition: productData.condition,
p_value: productData.value,
p_tags: productData.tags,
p_image_urls: productData.image_urls,
p_main_image_url: productData.main_image_url,
p_zipcode: document.getElementById('zipcode').value || '00000'
});
if (error) throw error;
showToast('Product added successfully!', 'success');
closeProductModal();
loadProducts();
} catch (error) {
console.error('Error adding product:', error);
showToast(error.message || 'Failed to add product', 'error');
} finally {
submitButton.textContent = originalText;
submitButton.disabled = false;
}
});
// Image preview functionality
document.getElementById('productImages').addEventListener('change', function(event) {
const preview = document.getElementById('imagePreview');
preview.innerHTML = '';
const files = event.target.files;
for (let i = 0; i < files.length; i++) {
const file = files[i];
if (file.type.startsWith('image/')) {
const reader = new FileReader();
reader.onload = function(e) {
const img = document.createElement('img');
img.src = e.target.result;
preview.appendChild(img);
};
reader.readAsDataURL(file);
}
}
});
// Load and display products
async function loadProducts() {
const productsGrid = document.getElementById('productsGrid');
const loadingEl = document.getElementById('productsLoading');
const emptyEl = document.getElementById('productsEmpty');
try {
loadingEl.style.display = 'flex';
productsGrid.style.display = 'none';
emptyEl.style.display = 'none';
const user = await Auth.getCurrentUser();
const supabase = await Auth.initializeSupabase();
const { data: products, error } = await supabase
.from('items')
.select('*')
.eq('owner_id', user.id)
.order('created_at', { ascending: false });
if (error) throw error;
loadingEl.style.display = 'none';
if (!products || products.length === 0) {
emptyEl.style.display = 'flex';
return;
}
productsGrid.style.display = 'grid';
productsGrid.innerHTML = products.map(product => `
<div class="product-card">
<div class="product-image">
<img src="${product.main_image_url || 'https://via.placeholder.com/200x200?text=No+Image'}"
alt="${product.name}"
onerror="this.src='https://via.placeholder.com/200x200?text=Image+Error'">
</div>
<div class="product-info">
<h3>${product.name}</h3>
<p class="product-category">${product.category}</p>
<p class="product-condition">${product.condition}</p>
<p class="product-value">$${product.value}</p>
<p class="product-status ${product.status}">${product.status}</p>
</div>
<div class="product-actions">
<button onclick="editProduct('${product.id}')" class="btn-icon">✏️</button>
<button onclick="deleteProduct('${product.id}')" class="btn-icon">🗑️</button>
</div>
</div>
`).join('');
} catch (error) {
console.error('Error loading products:', error);
showToast('Failed to load products', 'error');
loadingEl.style.display = 'none';
emptyEl.style.display = 'flex';
}
}
// Delete product
async function deleteProduct(productId) {
if (!confirm('Are you sure you want to delete this product?')) return;
try {
const supabase = await Auth.initializeSupabase();
// Get product images to delete
const { data: product } = await supabase
.from('items')
.select('image_urls')
.eq('id', productId)
.single();
// Delete product
const { error } = await supabase
.from('items')
.delete()
.eq('id', productId);
if (error) throw error;
// Clean up images
if (product?.image_urls?.length) {
for (const imageUrl of product.image_urls) {
const fileName = imageUrl.split('/').pop();
await supabase.storage
.from('product-images')
.remove([`product-images/${fileName}`]);
}
}
showToast('Product deleted successfully', 'success');
loadProducts();
} catch (error) {
console.error('Error deleting product:', error);
showToast('Failed to delete product', 'error');
}
}
// Toast notification
function showToast(message, type = 'info') {
const toast = document.createElement('div');
toast.className = `toast toast-${type}`;
toast.innerHTML = `
<span class="toast-message">${message}</span>
<button class="toast-close" onclick="this.parentElement.remove()">×</button>
`;
document.getElementById('toastContainer').appendChild(toast);
setTimeout(() => toast.remove(), 5000);
}
// Load products on page load
document.addEventListener('DOMContentLoaded', () => {
loadProducts();
});
</script>
<!-- Footer -->
<footer class="main-footer">
<div class="footer-content">
<!-- Left Section - Branding -->
<div class="footer-brand">
<div class="footer-logo">
<span class="logo-text">STUFF</span>
<span class="logo-accent">SWAP</span>
</div>
<p class="footer-tagline">Thoughtful swapping for growing communities.</p>
<p class="footer-copyright">© 2024 Stuff Swap. Community Exchange Platform. All Rights Reserved.</p>
</div>
<!-- Middle Section - Newsletter -->
<div class="footer-newsletter">
<h3>COMMUNITY INSIGHTS FOR CLEVER SWAPPERS</h3>
<h4>DIRECT TO YOUR INBOX</h4>
<div class="newsletter-form">
<input type="email" placeholder="YOUR E-MAIL" class="newsletter-input">
<button class="newsletter-btn">SUBSCRIBE</button>
</div>
</div>
<!-- Right Section - Social & Contact -->
<div class="footer-contact">
<div class="social-section">
<h3>FOLLOW US</h3>
<div class="social-icons">
<a href="#" class="social-icon">📷</a>
<a href="#" class="social-icon">👥</a>
<a href="#" class="social-icon">🐦</a>
</div>
</div>
<div class="contact-section">
<h3>CONTACT US</h3>
<p class="contact-info">support@stuffswap.com</p>
</div>
</div>
</div>
<!-- Bottom Legal Links -->
<div class="footer-legal">
<a href="#" class="legal-link">PRIVACY POLICY</a>
<a href="#" class="legal-link">TERMS AND CONDITIONS</a>
</div>
</footer>
</body>
</html>