-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
374 lines (336 loc) · 16.6 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GiveHub</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<!-- Header -->
<header class="app-header">
<div class="header-content">
<div class="logo-section">
<button class="menu-trigger" id="menuTrigger">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="3" y1="12" x2="21" y2="12"></line>
<line x1="3" y1="6" x2="21" y2="6"></line>
<line x1="3" y1="18" x2="21" y2="18"></line>
</svg>
</button>
<img src="/img/white-logo.svg" width="32" height="32">
<span style="font-weight: 600; font-size: 1.25rem;">The Give Hub</span>
</div>
<div class="user-section">
<button class="icon-button" id="themeToggle" aria-label="Toggle theme">
<!-- Moon icon for light mode -->
<svg class="moon-icon" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path>
</svg>
<!-- Sun icon for dark mode (hidden by default) -->
<svg class="sun-icon hidden" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="5"></circle>
<line x1="12" y1="1" x2="12" y2="3"></line>
<line x1="12" y1="21" x2="12" y2="23"></line>
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
<line x1="1" y1="12" x2="3" y2="12"></line>
<line x1="21" y1="12" x2="23" y2="12"></line>
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
</svg>
</button>
<button class="icon-button">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"></path>
<path d="M13.73 21a2 2 0 0 1-3.46 0"></path>
</svg>
</button>
<div class="user-avatar">CR</div>
</div>
</div>
</header>
<!-- Sidebar -->
<aside class="app-sidebar" id="sidebar">
<nav class="nav-section">
<div class="nav-title">Dashboard</div>
<ul class="nav-menu">
<li class="nav-item">
<a href="dashboard.html" onclick="app.loadContent(this.getAttribute('href'));return false" class="nav-link">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="3" width="7" height="7"></rect>
<rect x="14" y="3" width="7" height="7"></rect>
<rect x="14" y="14" width="7" height="7"></rect>
<rect x="3" y="14" width="7" height="7"></rect>
</svg>
Overview
</a>
</li>
<li class="nav-item">
<a href="browse.html" onclick="app.loadContent(this.getAttribute('href'));return false" class="nav-link">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M12 2l9 4-9 4-9-4 9-4z"/>
<path d="M12 22v-8"/>
<path d="M3 10v8l9 4"/>
<path d="M21 10v8l-9 4"/>
</svg>
Campaigns
</a>
</li>
<li class="nav-item">
<a href="donors.html" onclick="app.loadContent(this.getAttribute('href'));return false" class="nav-link">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path>
<circle cx="9" cy="7" r="4"></circle>
<path d="M23 21v-2a4 4 0 0 0-3-3.87"></path>
<path d="M16 3.13a4 4 0 0 1 0 7.75"></path>
</svg>
Donors
</a>
</li>
</ul>
<div class="nav-title" style="margin-top: 2rem;">Management</div>
<ul class="nav-menu">
<li class="nav-item">
<a href="settings.html" onclick="app.loadContent(this.getAttribute('href'));return false" class="nav-link">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="3"></circle>
<path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path>
</svg>
Settings
</a>
</li>
</ul>
</nav>
</aside>
<!-- Overlay for mobile -->
<div class="overlay" id="overlay"></div>
<!-- Main Content -->
<main class="app-main">
<div class="frame-loader" id="frameLoader"></div>
<div class="frame-error" id="frameError">
<div class="frame-error-content">
<h2>Unable to Load Content</h2>
<p>There was a problem loading the requested page. Please try again.</p>
<button class="retry-button" onclick="reloadFrame()">Retry</button>
</div>
</div>
<iframe
id="contentFrame"
class="content-frame"
src="about:blank"
title="Content Area">
</iframe>
</main>
<script type="module">
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/11.0.2/firebase-app.js";
import { getAnalytics } from "https://www.gstatic.com/firebasejs/11.0.2/firebase-analytics.js";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "AIzaSyBD46eiABWftJ6WdJpFsQxF5iUknUoTFIo",
authDomain: "the-givehub.firebaseapp.com",
projectId: "the-givehub",
storageBucket: "the-givehub.firebasestorage.app",
messagingSenderId: "503214679990",
appId: "1:503214679990:web:88bb2bc6116709931ec317",
measurementId: "G-8SWNP3PJ94"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
</script>
<script>
(function() {
let app = {
init() {
// Handle navigation clicks
document.querySelectorAll('.nav-link').forEach(link => {
link.addEventListener('click', (e) => {
e.preventDefault();
// Remove active class from all links
document.querySelectorAll('.nav-link').forEach(l =>
l.classList.remove('active'));
// Add active class to clicked link
link.classList.add('active');
// Close sidebar on mobile
if (window.innerWidth <= 768) {
app.elements.sidebar.classList.remove('active');
app.elements.overlay.classList.remove('active');
}
// Load content based on href
const url = link.getAttribute('href');
if (url && url !== '#') {
app.loadContent(url);
}
});
});
app.auth.init();
app.theme.init();
// Initialize with default content
app.loadContent('/browse.html');
// Event listeners
app.elements.menuTrigger.addEventListener('click', app.toggleSidebar);
app.elements.overlay.addEventListener('click', app.toggleSidebar);
// Close sidebar on window resize if in mobile view
window.addEventListener('resize', () => {
if (window.innerWidth > 768 && app.elements.sidebar.classList.contains('active')) {
app.elements.sidebar.classList.remove('active');
app.elements.overlay.classList.remove('active');
}
});
},
theme: {
init() {
const themeToggle = document.getElementById('themeToggle');
const moonIcon = themeToggle.querySelector('.moon-icon');
const sunIcon = themeToggle.querySelector('.sun-icon');
// Check for saved theme preference or system preference
const savedTheme = localStorage.getItem('theme');
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
// Set initial theme
if (savedTheme === 'dark' || (!savedTheme && prefersDark)) {
document.documentElement.setAttribute('data-theme', 'dark');
moonIcon.classList.add('hidden');
sunIcon.classList.remove('hidden');
}
// Toggle theme
themeToggle.addEventListener('click', () => {
const isDark = document.documentElement.getAttribute('data-theme') === 'dark';
if (isDark) {
document.documentElement.removeAttribute('data-theme');
localStorage.setItem('theme', 'light');
moonIcon.classList.remove('hidden');
sunIcon.classList.add('hidden');
} else {
document.documentElement.setAttribute('data-theme', 'dark');
localStorage.setItem('theme', 'dark');
moonIcon.classList.add('hidden');
sunIcon.classList.remove('hidden');
}
});
}
},
config: {
account: {
id: 1,
name: "Better Living"
},
user: {
id: 1,
name: "Chris Robison",
username: "cdr",
pic: "/img/profilepics/cdr.png"
},
navUrls: {
'overview': '/dashboard.html',
'campaigns': '/browse.html',
'donors': '/donors.html',
'settings': '/settings.html'
}
},
elements: {
menuTrigger: document.getElementById('menuTrigger'),
sidebar: document.getElementById('sidebar'),
overlay: document.getElementById('overlay'),
contentFrame: document.getElementById('contentFrame'),
frameLoader: document.getElementById('frameLoader'),
frameError: document.getElementById('frameError'),
},
state: {
loaded: false
},
data: {
mycampaigns:[],
},
// Toggle sidebar
toggleSidebar() {
app.elements.sidebar.classList.toggle('active');
app.elements.overlay.classList.toggle('active');
},
loadContent(url) {
app.elements.frameLoader.classList.add('active');
app.elements.frameError.classList.remove('active');
app.elements.contentFrame.onload = () => {
app.elements.frameLoader.classList.remove('active');
};
app.elements.contentFrame.onerror = () => {
app.elements.frameLoader.classList.remove('active');
app.elements.frameError.classList.add('active');
};
try {
app.elements.contentFrame.src = url;
} catch (error) {
app.elements.frameLoader.classList.remove('active');
app.elements.frameError.classList.add('active');
}
},
reloadFrame() {
if (app.elements.contentFrame.src !== 'about:blank') {
app.loadContent(app.elements.contentFrame.src);
}
},
};
// Add this to your app object
app.auth = {
init() {
// Import Firebase auth when using modules
import('https://www.gstatic.com/firebasejs/11.0.2/firebase-auth.js')
.then((firebaseAuth) => {
const auth = firebaseAuth.getAuth(app);
// Set up auth state listener
auth.onAuthStateChanged((user) => {
if (user) {
// User is signed in
localStorage.setItem('authStatus', 'authenticated');
document.body.setAttribute('data-auth-status', 'authenticated');
// Store user info if needed
const userData = {
uid: user.uid,
email: user.email,
displayName: user.displayName,
photoURL: user.photoURL
};
localStorage.setItem('userData', JSON.stringify(userData));
// Update UI elements if needed
if (user.photoURL) {
const avatar = document.querySelector('.user-avatar');
if (avatar) {
avatar.innerHTML = `<img src="${user.photoURL}" alt="${user.displayName}" class="w-full h-full rounded-full">`;
}
}
console.log('User is authenticated:', user);
} else {
// User is signed out
localStorage.removeItem('authStatus');
localStorage.removeItem('userData');
document.body.removeAttribute('data-auth-status');
console.log('User is not authenticated');
// Redirect to login if needed
window.location.href = '/login.html';
}
});
})
.catch(error => {
console.error('Error loading Firebase Auth:', error);
});
},
// Helper method to check current auth status
isAuthenticated() {
return localStorage.getItem('authStatus') === 'authenticated';
},
// Helper to get current user data
getCurrentUser() {
const userData = localStorage.getItem('userData');
return userData ? JSON.parse(userData) : null;
}
};
window.app = app;
app.init();
})();
</script>
</body>
</html>