veltrixcode commited on
Commit
6fa9c3a
·
verified ·
1 Parent(s): eab827a

Delete public/admin.html

Browse files
Files changed (1) hide show
  1. public/admin.html +0 -489
public/admin.html DELETED
@@ -1,489 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Admin - SLD GC Portal</title>
7
- <script src="https://cdn.tailwindcss.com"></script>
8
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
9
- <style>
10
- :root {
11
- --apple-blue: #007AFF;
12
- --apple-gray: #1C1C1E;
13
- --apple-light: #F2F2F7;
14
- --apple-dark: #000000;
15
- }
16
-
17
- body {
18
- font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
19
- -webkit-font-smoothing: antialiased;
20
- }
21
-
22
- .glass {
23
- background: rgba(255, 255, 255, 0.08);
24
- backdrop-filter: blur(20px);
25
- -webkit-backdrop-filter: blur(20px);
26
- border: 1px solid rgba(255, 255, 255, 0.1);
27
- }
28
-
29
- .apple-btn {
30
- background: var(--apple-blue);
31
- border-radius: 12px;
32
- transition: all 0.2s ease;
33
- }
34
-
35
- .apple-btn:hover { transform: scale(0.98); }
36
-
37
- .apple-input {
38
- background: rgba(255, 255, 255, 0.1);
39
- border: 1px solid rgba(255, 255, 255, 0.2);
40
- border-radius: 12px;
41
- transition: all 0.3s ease;
42
- }
43
-
44
- .apple-input:focus {
45
- border-color: var(--apple-blue);
46
- box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
47
- }
48
-
49
- .apple-card {
50
- background: rgba(255, 255, 255, 0.05);
51
- border-radius: 16px;
52
- border: 1px solid rgba(255, 255, 255, 0.1);
53
- transition: all 0.3s ease;
54
- }
55
-
56
- .apple-card:hover { transform: translateY(-2px); }
57
-
58
- .loading { animation: spin 1s linear infinite; }
59
- @keyframes spin { to { transform: rotate(360deg); } }
60
-
61
- .fade-in { animation: fadeIn 0.5s ease-in-out; }
62
- @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
63
- </style>
64
- </head>
65
- <body class="bg-black text-white min-h-screen">
66
- <!-- Auth Section -->
67
- <div id="authSection" class="min-h-screen bg-gradient-to-br from-black via-gray-900 to-blue-900 flex items-center justify-center p-4">
68
- <div class="glass p-8 rounded-3xl max-w-md w-full fade-in">
69
- <div class="text-center mb-8">
70
- <div class="w-20 h-20 glass rounded-2xl flex items-center justify-center mx-auto mb-6">
71
- <i class="fas fa-shield-alt text-3xl text-blue-400"></i>
72
- </div>
73
- <h1 class="text-3xl font-bold mb-2">Admin Portal</h1>
74
- <p class="text-gray-400">Secure access required</p>
75
- </div>
76
- <div class="space-y-4">
77
- <button onclick="sendOTP()" class="w-full apple-btn text-white py-3 px-6 font-medium">
78
- <i class="fas fa-paper-plane mr-2"></i>Send OTP
79
- </button>
80
- <div id="otpSection" class="hidden space-y-4">
81
- <input type="text" id="otpInput" placeholder="Enter 6-digit OTP" class="w-full apple-input text-white p-3">
82
- <button onclick="verifyOTP()" class="w-full apple-btn text-white py-3 px-6 font-medium">
83
- <i class="fas fa-check-circle mr-2"></i>Verify OTP
84
- </button>
85
- </div>
86
- </div>
87
- </div>
88
- </div>
89
-
90
- <!-- Dashboard -->
91
- <div id="dashboard" class="hidden min-h-screen bg-black">
92
- <!-- Header -->
93
- <header class="glass sticky top-0 z-50 border-b border-gray-800">
94
- <div class="max-w-7xl mx-auto px-4 py-4">
95
- <div class="flex justify-between items-center">
96
- <div class="flex items-center space-x-4">
97
- <div class="w-10 h-10 bg-blue-600 rounded-xl flex items-center justify-center">
98
- <i class="fas fa-tachometer-alt text-white"></i>
99
- </div>
100
- <div>
101
- <h1 class="text-xl font-bold">Admin Dashboard</h1>
102
- <p class="text-sm text-gray-400">Manage submissions</p>
103
- </div>
104
- </div>
105
- <button onclick="logout()" class="apple-btn bg-red-500 text-white px-4 py-2">
106
- <i class="fas fa-sign-out-alt mr-2"></i>Logout
107
- </button>
108
- </div>
109
- </div>
110
- </header>
111
-
112
- <main class="max-w-7xl mx-auto p-4 pb-20">
113
- <!-- Stats -->
114
- <div class="grid grid-cols-2 lg:grid-cols-4 gap-4 mb-6">
115
- <div class="apple-card p-4">
116
- <div class="flex items-center justify-between">
117
- <div>
118
- <p class="text-gray-400 text-sm">Total</p>
119
- <p id="totalCount" class="text-2xl font-bold">0</p>
120
- </div>
121
- <i class="fas fa-file-alt text-blue-400 text-xl"></i>
122
- </div>
123
- </div>
124
- <div class="apple-card p-4">
125
- <div class="flex items-center justify-between">
126
- <div>
127
- <p class="text-gray-400 text-sm">Pending</p>
128
- <p id="pendingCount" class="text-2xl font-bold text-yellow-400">0</p>
129
- </div>
130
- <i class="fas fa-clock text-yellow-400 text-xl"></i>
131
- </div>
132
- </div>
133
- <div class="apple-card p-4">
134
- <div class="flex items-center justify-between">
135
- <div>
136
- <p class="text-gray-400 text-sm">Approved</p>
137
- <p id="approvedCount" class="text-2xl font-bold text-green-400">0</p>
138
- </div>
139
- <i class="fas fa-check-circle text-green-400 text-xl"></i>
140
- </div>
141
- </div>
142
- <div class="apple-card p-4">
143
- <div class="flex items-center justify-between">
144
- <div>
145
- <p class="text-gray-400 text-sm">Paid</p>
146
- <p id="paidCount" class="text-2xl font-bold text-blue-400">0</p>
147
- </div>
148
- <i class="fas fa-money-bill-wave text-blue-400 text-xl"></i>
149
- </div>
150
- </div>
151
- </div>
152
-
153
- <!-- Submissions -->
154
- <div class="glass rounded-2xl overflow-hidden">
155
- <div class="p-6 border-b border-gray-800">
156
- <h2 class="text-xl font-bold">Recent Submissions</h2>
157
- </div>
158
- <div id="submissionsList" class="divide-y divide-gray-800"></div>
159
- </div>
160
- </main>
161
- </div>
162
-
163
- <!-- Video Modal -->
164
- <div id="videoModal" class="fixed inset-0 bg-black bg-opacity-80 hidden flex items-center justify-center p-4 z-50">
165
- <div class="glass rounded-2xl max-w-4xl w-full max-h-[90vh] overflow-hidden">
166
- <div class="flex justify-between items-center p-4 border-b border-gray-800">
167
- <h3 class="text-lg font-bold">Video Proof</h3>
168
- <button onclick="closeVideo()" class="w-8 h-8 bg-red-500 rounded-lg flex items-center justify-center">
169
- <i class="fas fa-times text-sm"></i>
170
- </button>
171
- </div>
172
- <div class="p-4">
173
- <video id="modalVideo" controls class="w-full rounded-xl"></video>
174
- </div>
175
- </div>
176
- </div>
177
-
178
- <!-- Chat Modal -->
179
- <div id="chatModal" class="fixed inset-0 bg-black bg-opacity-80 hidden flex items-center justify-center p-4 z-50">
180
- <div class="glass rounded-2xl max-w-2xl w-full max-h-[90vh] flex flex-col">
181
- <div class="flex justify-between items-center p-4 border-b border-gray-800">
182
- <div>
183
- <h3 class="text-lg font-bold">Chat</h3>
184
- <p class="text-sm text-gray-400" id="chatEmail"></p>
185
- </div>
186
- <button onclick="closeChat()" class="w-8 h-8 bg-red-500 rounded-lg flex items-center justify-center">
187
- <i class="fas fa-times text-sm"></i>
188
- </button>
189
- </div>
190
- <div id="chatMessages" class="flex-1 overflow-y-auto p-4 space-y-3 max-h-80"></div>
191
- <form id="chatForm" class="p-4 border-t border-gray-800">
192
- <div class="flex space-x-3">
193
- <input type="text" id="messageInput" placeholder="Type message..." class="flex-1 apple-input text-white p-3">
194
- <button type="submit" class="apple-btn text-white px-4 py-3">
195
- <i class="fas fa-paper-plane"></i>
196
- </button>
197
- </div>
198
- </form>
199
- </div>
200
- </div>
201
-
202
- <script>
203
- let currentUserId = null;
204
-
205
- // Auth Functions
206
- async function sendOTP() {
207
- try {
208
- const response = await fetch('https://mail-steel.vercel.app/admin/send-otp', {
209
- method: 'POST',
210
- headers: { 'Content-Type': 'application/json' }
211
- });
212
- const data = await response.json();
213
- if (data.success) {
214
- document.getElementById('otpSection').classList.remove('hidden');
215
- showNotification('OTP sent successfully', 'success');
216
- } else {
217
- showNotification(data.error || 'Failed to send OTP', 'error');
218
- }
219
- } catch (error) {
220
- showNotification('Failed to send OTP', 'error');
221
- }
222
- }
223
-
224
- async function verifyOTP() {
225
- const otp = document.getElementById('otpInput').value;
226
- if (!otp) return showNotification('Please enter OTP', 'warning');
227
-
228
- try {
229
- const response = await fetch('https://mail-steel.vercel.app/admin/verify-otp', {
230
- method: 'POST',
231
- headers: { 'Content-Type': 'application/json' },
232
- body: JSON.stringify({ otp })
233
- });
234
- const data = await response.json();
235
- if (data.success) {
236
- sessionStorage.setItem('adminToken', otp);
237
- document.getElementById('authSection').classList.add('hidden');
238
- document.getElementById('dashboard').classList.remove('hidden');
239
- loadSubmissions();
240
- showNotification('Login successful', 'success');
241
- } else {
242
- showNotification(data.error || 'Invalid OTP', 'error');
243
- }
244
- } catch (error) {
245
- showNotification('Failed to verify OTP', 'error');
246
- }
247
- }
248
-
249
- function logout() {
250
- sessionStorage.removeItem('adminToken');
251
- location.reload();
252
- }
253
-
254
- // Dashboard Functions
255
- async function loadSubmissions() {
256
- try {
257
- const response = await fetch('/api/admin/submissions');
258
- const data = await response.json();
259
- if (!data.success) throw new Error(data.error);
260
-
261
- const submissions = data.submissions;
262
- updateStats(submissions);
263
- renderSubmissions(submissions);
264
- } catch (error) {
265
- document.getElementById('submissionsList').innerHTML = '<div class="p-6 text-center text-red-400">Error loading submissions</div>';
266
- }
267
- }
268
-
269
- function updateStats(submissions) {
270
- document.getElementById('totalCount').textContent = submissions.length;
271
- document.getElementById('pendingCount').textContent = submissions.filter(s => s.status === 'pending').length;
272
- document.getElementById('approvedCount').textContent = submissions.filter(s => s.status === 'approved').length;
273
- document.getElementById('paidCount').textContent = submissions.filter(s => s.status === 'paid').length;
274
- }
275
-
276
- function renderSubmissions(submissions) {
277
- document.getElementById('submissionsList').innerHTML = submissions.map(s => `
278
- <div class="p-4 hover:bg-gray-900 transition-colors">
279
- <div class="flex flex-col space-y-3">
280
- <div class="flex justify-between items-start">
281
- <div>
282
- <h3 class="font-bold text-lg">${s.ticket_user_name}</h3>
283
- <p class="text-gray-400 text-sm">ID: ${s.id}</p>
284
- </div>
285
- <span class="px-3 py-1 rounded-full text-xs font-medium ${getStatusClass(s.status)}">${s.status}</span>
286
- </div>
287
-
288
- <div class="grid grid-cols-1 md:grid-cols-3 gap-3">
289
- <div class="bg-gray-800 p-3 rounded-lg">
290
- <h4 class="font-medium text-gray-300 mb-2">Card Details</h4>
291
- <div class="space-y-1 text-sm text-gray-400">
292
- <p><i class="fas fa-ticket-alt w-4"></i> ${s.ticket_number}</p>
293
- <p><i class="fas fa-credit-card w-4"></i> ${s.gc_code}</p>
294
- <p><i class="fas fa-phone w-4"></i> ${s.gc_phone}</p>
295
- </div>
296
- </div>
297
-
298
- <div class="bg-gray-800 p-3 rounded-lg">
299
- <h4 class="font-medium text-gray-300 mb-2">Payment</h4>
300
- <div class="space-y-1 text-sm text-gray-400">
301
- <p><i class="fas fa-rupee-sign w-4"></i> ₹${s.amount}</p>
302
- <p><i class="fas fa-wallet w-4"></i> ${s.upi_id}</p>
303
- </div>
304
- </div>
305
-
306
- <div class="bg-gray-800 p-3 rounded-lg">
307
- <h4 class="font-medium text-gray-300 mb-2">User</h4>
308
- <div class="space-y-1 text-sm text-gray-400">
309
- <p><i class="fas fa-user w-4"></i> ${s.user_email}</p>
310
- <p><i class="fas fa-calendar w-4"></i> ${new Date(s.created_at).toLocaleDateString()}</p>
311
- </div>
312
- </div>
313
- </div>
314
-
315
- <div class="flex flex-wrap gap-2 pt-2">
316
- <button onclick="showVideo('${s.proof_video_url}')" class="px-3 py-2 bg-blue-600 rounded-lg text-sm">
317
- <i class="fas fa-video mr-1"></i>Video
318
- </button>
319
- <button onclick="openChat('${s.user_id}', '${s.user_email}')" class="px-3 py-2 bg-green-600 rounded-lg text-sm">
320
- <i class="fas fa-comments mr-1"></i>Chat
321
- </button>
322
- ${getActionButtons(s)}
323
- </div>
324
- </div>
325
- </div>
326
- `).join('');
327
- }
328
-
329
- function getStatusClass(status) {
330
- const classes = {
331
- pending: 'bg-yellow-100 text-yellow-800',
332
- approved: 'bg-green-100 text-green-800',
333
- rejected: 'bg-red-100 text-red-800',
334
- paid: 'bg-blue-100 text-blue-800',
335
- closed: 'bg-gray-100 text-gray-800'
336
- };
337
- return classes[status] || classes.closed;
338
- }
339
-
340
- function getActionButtons(s) {
341
- const buttons = {
342
- pending: `<button onclick="updateStatus('${s.id}', 'approved')" class="px-3 py-2 bg-green-600 rounded-lg text-sm">Approve</button>
343
- <button onclick="updateStatus('${s.id}', 'rejected')" class="px-3 py-2 bg-red-600 rounded-lg text-sm">Reject</button>`,
344
- approved: `<button onclick="updateStatus('${s.id}', 'paid')" class="px-3 py-2 bg-blue-600 rounded-lg text-sm">Mark Paid</button>`,
345
- paid: `<button onclick="updateStatus('${s.id}', 'closed')" class="px-3 py-2 bg-gray-600 rounded-lg text-sm">Close</button>`
346
- };
347
- return buttons[s.status] || '';
348
- }
349
-
350
- async function updateStatus(id, status) {
351
- if (!confirm(`Mark as ${status}?`)) return;
352
-
353
- try {
354
- const response = await fetch(`/api/admin/submissions/${id}/status`, {
355
- method: 'POST',
356
- headers: { 'Content-Type': 'application/json' },
357
- body: JSON.stringify({ status })
358
- });
359
- const data = await response.json();
360
- if (data.success) {
361
- showNotification(`Status updated to ${status}`, 'success');
362
- loadSubmissions();
363
- } else {
364
- throw new Error(data.error);
365
- }
366
- } catch (error) {
367
- showNotification('Failed to update status', 'error');
368
- }
369
- }
370
-
371
- // Modal Functions
372
- function showVideo(url) {
373
- document.getElementById('modalVideo').src = url;
374
- document.getElementById('videoModal').classList.remove('hidden');
375
- }
376
-
377
- function closeVideo() {
378
- document.getElementById('modalVideo').src = '';
379
- document.getElementById('videoModal').classList.add('hidden');
380
- }
381
-
382
- function openChat(userId, email) {
383
- currentUserId = userId;
384
- document.getElementById('chatEmail').textContent = email;
385
- document.getElementById('chatModal').classList.remove('hidden');
386
- loadMessages();
387
- }
388
-
389
- function closeChat() {
390
- document.getElementById('chatModal').classList.add('hidden');
391
- currentUserId = null;
392
- }
393
-
394
- async function loadMessages() {
395
- if (!currentUserId) return;
396
-
397
- try {
398
- const response = await fetch(`/api/admin/messages/${currentUserId}`);
399
- const data = await response.json();
400
- if (data.success) {
401
- document.getElementById('chatMessages').innerHTML = data.messages.map(m => `
402
- <div class="flex ${m.sender === 'admin' ? 'justify-end' : 'justify-start'}">
403
- <div class="max-w-xs px-4 py-2 rounded-2xl ${m.sender === 'admin' ? 'bg-blue-600' : 'bg-gray-700'}">
404
- <p class="text-sm">${m.content}</p>
405
- <p class="text-xs opacity-70 mt-1">${new Date(m.created_at).toLocaleString()}</p>
406
- </div>
407
- </div>
408
- `).join('');
409
- document.getElementById('chatMessages').scrollTop = document.getElementById('chatMessages').scrollHeight;
410
- }
411
- } catch (error) {
412
- document.getElementById('chatMessages').innerHTML = '<div class="text-center text-red-400">Error loading messages</div>';
413
- }
414
- }
415
-
416
- document.getElementById('chatForm').addEventListener('submit', async (e) => {
417
- e.preventDefault();
418
- const message = document.getElementById('messageInput').value.trim();
419
- if (!message || !currentUserId) return;
420
-
421
- // Get the send button and input field
422
- const sendButton = e.target.querySelector('button[type="submit"]');
423
- const messageInput = document.getElementById('messageInput');
424
- const originalButtonContent = sendButton.innerHTML;
425
-
426
- // Show loading state
427
- sendButton.innerHTML = '<i class="fas fa-spinner loading"></i>';
428
- sendButton.disabled = true;
429
- messageInput.disabled = true;
430
-
431
- try {
432
- const response = await fetch('/api/admin/messages', {
433
- method: 'POST',
434
- headers: { 'Content-Type': 'application/json' },
435
- body: JSON.stringify({ userId: currentUserId, content: message })
436
- });
437
- const data = await response.json();
438
- if (data.success) {
439
- document.getElementById('messageInput').value = '';
440
- loadMessages();
441
- } else {
442
- showNotification('Failed to send message', 'error');
443
- }
444
- } catch (error) {
445
- showNotification('Failed to send message', 'error');
446
- } finally {
447
- // Restore button and input state
448
- sendButton.innerHTML = originalButtonContent;
449
- sendButton.disabled = false;
450
- messageInput.disabled = false;
451
- messageInput.focus();
452
- }
453
- });
454
-
455
- // Utility Functions
456
- function showNotification(message, type = 'info') {
457
- const colors = {
458
- success: 'bg-green-500',
459
- error: 'bg-red-500',
460
- warning: 'bg-yellow-500',
461
- info: 'bg-blue-500'
462
- };
463
-
464
- const notification = document.createElement('div');
465
- notification.className = `fixed top-4 right-4 ${colors[type]} text-white p-4 rounded-xl z-50 transform transition-all duration-300 translate-x-full`;
466
- notification.innerHTML = `<div class="flex items-center space-x-2">
467
- <i class="fas fa-${type === 'success' ? 'check-circle' : type === 'error' ? 'exclamation-circle' : 'info-circle'}"></i>
468
- <span>${message}</span>
469
- </div>`;
470
-
471
- document.body.appendChild(notification);
472
- setTimeout(() => notification.classList.remove('translate-x-full'), 100);
473
- setTimeout(() => {
474
- notification.classList.add('translate-x-full');
475
- setTimeout(() => document.body.removeChild(notification), 300);
476
- }, 3000);
477
- }
478
-
479
- // Initialize
480
- window.onload = function() {
481
- if (sessionStorage.getItem('adminToken')) {
482
- document.getElementById('authSection').classList.add('hidden');
483
- document.getElementById('dashboard').classList.remove('hidden');
484
- loadSubmissions();
485
- }
486
- };
487
- </script>
488
- </body>
489
- </html>