File size: 24,357 Bytes
d877bec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8a51c37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d877bec
 
 
 
 
 
 
 
 
 
 
 
8a51c37
 
 
 
d877bec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f886025
 
5216726
f886025
d877bec
 
 
 
 
 
f886025
 
 
 
 
 
 
5216726
f886025
 
 
 
 
 
 
d877bec
 
 
5216726
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d877bec
5216726
d877bec
 
5216726
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d877bec
 
 
 
 
8a51c37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d877bec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8a51c37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d877bec
 
 
 
5216726
f886025
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d877bec
 
 
f886025
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d877bec
 
 
 
f886025
d877bec
 
f886025
 
 
 
 
d877bec
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vvmm Admin Dashboard</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://unpkg.com/feather-icons"></script>
</head>
<body class="bg-gray-100">
    <div class="min-h-screen">
        <!-- Admin Navbar -->
        <nav class="bg-blue-900 text-white shadow-lg">
            <div class="container mx-auto px-4 py-3">
                <div class="flex justify-between items-center">
                    <div class="flex items-center space-x-2">
                        <i data-feather="shield" class="w-8 h-8"></i>
                        <span class="text-xl font-bold">vvmm Admin</span>
                    </div>
                    <div class="flex items-center space-x-4">
                        <span id="adminName">Martin Mutale</span>
                        <button id="adminLogout" class="bg-red-500 text-white px-4 py-2 rounded-lg font-medium hover:bg-red-600 transition">
                            Logout
                        </button>
                    </div>
                </div>
            </div>

            <!-- Manual Wallet Adjustment -->
            <div class="bg-white rounded-lg shadow overflow-hidden mt-8">
                <div class="px-6 py-4 border-b">
                    <h2 class="text-xl font-bold">Wallet Management</h2>
                </div>
                <div class="p-6">
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                        <div class="bg-green-50 p-6 rounded-lg">
                            <h3 class="font-bold text-lg mb-4">Add Funds</h3>
                            <div class="mb-4">
                                <label class="block text-gray-700 mb-2">User Email</label>
                                <input type="email" id="addFundsEmail" class="w-full px-4 py-2 border rounded-lg">
                            </div>
                            <div class="mb-4">
                                <label class="block text-gray-700 mb-2">Amount (ZMW)</label>
                                <input type="number" id="addFundsAmount" class="w-full px-4 py-2 border rounded-lg" min="1">
                            </div>
                            <div class="mb-4">
                                <label class="block text-gray-700 mb-2">Description</label>
                                <input type="text" id="addFundsReason" class="w-full px-4 py-2 border rounded-lg">
                            </div>
                            <button onclick="adminAddFunds()" class="w-full bg-green-600 text-white py-3 rounded-lg font-bold hover:bg-green-700">
                                Add Funds
                            </button>
                        </div>
                        <div class="bg-red-50 p-6 rounded-lg">
                            <h3 class="font-bold text-lg mb-4">Deduct Funds</h3>
                            <div class="mb-4">
                                <label class="block text-gray-700 mb-2">User Email</label>
                                <input type="email" id="deductFundsEmail" class="w-full px-4 py-2 border rounded-lg">
                            </div>
                            <div class="mb-4">
                                <label class="block text-gray-700 mb-2">Amount (ZMW)</label>
                                <input type="number" id="deductFundsAmount" class="w-full px-4 py-2 border rounded-lg" min="1">
                            </div>
                            <div class="mb-4">
                                <label class="block text-gray-700 mb-2">Reason</label>
                                <input type="text" id="deductFundsReason" class="w-full px-4 py-2 border rounded-lg">
                            </div>
                            <button onclick="adminDeductFunds()" class="w-full bg-red-600 text-white py-3 rounded-lg font-bold hover:bg-red-700">
                                Deduct Funds
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </nav>

        <!-- Admin Dashboard -->
        <div class="container mx-auto px-4 py-8">
            <div class="mb-8">
                <img src="http://static.photos/office/1200x630/1" alt="Admin Dashboard" class="w-full rounded-lg shadow-lg">
            </div>
            <div class="grid grid-cols-1 md:grid-cols-4 gap-6 mb-8">
                <div class="bg-white p-6 rounded-lg shadow">
                    <h3 class="text-lg font-bold mb-2">Total Users</h3>
                    <p class="text-3xl font-bold text-blue-600">0</p>
                </div>
                <div class="bg-white p-6 rounded-lg shadow">
                    <h3 class="text-lg font-bold mb-2">Processing Fees</h3>
                    <p class="text-3xl font-bold text-purple-600">K0</p>
                </div>
                <div class="bg-white p-6 rounded-lg shadow">
                    <h3 class="text-lg font-bold mb-2">Pending Deposits</h3>
                    <p class="text-3xl font-bold text-yellow-500">0</p>
                </div>
                <div class="bg-white p-6 rounded-lg shadow">
                    <h3 class="text-lg font-bold mb-2">Pending Withdrawals</h3>
                    <p class="text-3xl font-bold text-orange-500">0</p>
                </div>
                <div class="bg-white p-6 rounded-lg shadow">
                    <h3 class="text-lg font-bold mb-2">Total Balance</h3>
                    <p class="text-3xl font-bold text-green-500">K0</p>
                </div>
            </div>

            <!-- Transactions Section -->
            <div class="bg-white rounded-lg shadow overflow-hidden mb-8">
                <div class="px-6 py-4 border-b">
                    <h2 class="text-xl font-bold">Pending Transactions</h2>
                </div>
                <div class="divide-y">
                    <div class="p-6 flex justify-between items-center">
                        <div class="flex items-center">
                            <img src="http://static.photos/people/200x200/3" alt="User" class="w-12 h-12 rounded-full mr-4 object-cover">
                            <div>
                                <p class="font-bold">Deposit - K280</p>
                                <p class="text-gray-600">From: user@example.com</p>
                                <p class="text-sm text-gray-500">Today, 10:30 AM</p>
                                <p class="text-sm font-medium">Payment to: vvmm Official (+260978310594)</p>
                            </div>
                        </div>
                        <div class="flex space-x-2">
                            <button onclick="adminApproveTransaction(1, 'deposit')" class="bg-green-500 text-white px-4 py-2 rounded-lg hover:bg-green-600">Approve</button>
                            <button onclick="adminRejectTransaction(1, 'deposit')" class="bg-red-500 text-white px-4 py-2 rounded-lg hover:bg-red-600">Reject</button>
                        </div>
                    </div>
                    <div class="p-6 flex justify-between items-center">
                        <div class="flex items-center">
                            <img src="http://static.photos/people/200x200/4" alt="User" class="w-12 h-12 rounded-full mr-4 object-cover">
                            <div>
                                <p class="font-bold">Withdrawal - K100</p>
                                <p class="text-gray-600">From: user2@example.com</p>
                                <p class="text-sm text-gray-500">Today, 11:45 AM</p>
                                <p class="text-sm font-medium">Payment from: vvmm Official (+260978310594)</p>
                            </div>
                        </div>
                        <div class="flex space-x-2">
                            <button onclick="adminApproveTransaction(2, 'withdrawal')" class="bg-green-500 text-white px-4 py-2 rounded-lg hover:bg-green-600">Approve</button>
                            <button onclick="adminRejectTransaction(2, 'withdrawal')" class="bg-red-500 text-white px-4 py-2 rounded-lg hover:bg-red-600">Reject</button>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Team Members -->
            <div class="bg-white rounded-lg shadow overflow-hidden mb-8">
                <div class="px-6 py-4 border-b">
                    <h2 class="text-xl font-bold">Team Members</h2>
                </div>
                <div class="p-6">
                    <div class="overflow-x-auto">
                        <table class="min-w-full divide-y divide-gray-200">
                            <thead class="bg-gray-50">
                                <tr>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Level</th>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Investment</th>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Commission</th>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
                                </tr>
                            </thead>
                            <tbody class="bg-white divide-y divide-gray-200">
                                <tr>
                                    <td class="px-6 py-4 whitespace-nowrap">John Doe</td>
                                    <td class="px-6 py-4 whitespace-nowrap">Level 1</td>
                                    <td class="px-6 py-4 whitespace-nowrap">K500</td>
                                    <td class="px-6 py-4 whitespace-nowrap">K25 (5%)</td>
                                    <td class="px-6 py-4 whitespace-nowrap">
                                        <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">Active</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="px-6 py-4 whitespace-nowrap">Jane Smith</td>
                                    <td class="px-6 py-4 whitespace-nowrap">Level 2</td>
                                    <td class="px-6 py-4 whitespace-nowrap">K300</td>
                                    <td class="px-6 py-4 whitespace-nowrap">K9 (3%)</td>
                                    <td class="px-6 py-4 whitespace-nowrap">
                                        <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-yellow-100 text-yellow-800">Pending</span>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

            <!-- Payment Proofs -->
            <div class="bg-white rounded-lg shadow overflow-hidden mb-8">
                <div class="px-6 py-4 border-b">
                    <h2 class="text-xl font-bold">Payment Proofs</h2>
                </div>
                <div class="p-6">
                    <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                        <div class="border rounded-lg p-4">
                            <img src="http://static.photos/finance/320x240/1" alt="Payment Proof" class="w-full rounded mb-2">
                            <p class="font-bold">Deposit - K280</p>
                            <p class="text-sm text-gray-600">From: user1@example.com</p>
                            <p class="text-sm text-gray-500">Today, 09:15 AM</p>
                            <div class="mt-2">
                                <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">Verified</span>
                            </div>
                        </div>
                        <div class="border rounded-lg p-4">
                            <img src="http://static.photos/finance/320x240/2" alt="Payment Proof" class="w-full rounded mb-2">
                            <p class="font-bold">Withdrawal - K150</p>
                            <p class="text-sm text-gray-600">From: user2@example.com</p>
                            <p class="text-sm text-gray-500">Yesterday, 02:30 PM</p>
                            <div class="mt-2">
                                <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-yellow-100 text-yellow-800">Pending</span>
                            </div>
                        </div>
                        <div class="border rounded-lg p-4">
                            <img src="http://static.photos/finance/320x240/3" alt="Payment Proof" class="w-full rounded mb-2">
                            <p class="font-bold">Deposit - K500</p>
                            <p class="text-sm text-gray-600">From: user3@example.com</p>
                            <p class="text-sm text-gray-500">Yesterday, 11:45 AM</p>
                            <div class="mt-2">
                                <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800">Rejected</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Products Management -->
            <div class="bg-white rounded-lg shadow overflow-hidden mt-8">
                <div class="px-6 py-4 border-b">
                    <h2 class="text-xl font-bold">Manage Products</h2>
                </div>
                <div class="p-6">
                    <div class="mb-6">
                        <button class="bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 mb-4">
                            Add New Product
                        </button>
                        <div class="overflow-x-auto">
                            <table class="min-w-full divide-y divide-gray-200">
                                <thead class="bg-gray-50">
                                    <tr>
                                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Product</th>
                                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Min Investment</th>
                                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
                                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
                                    </tr>
                                </thead>
                                <tbody class="bg-white divide-y divide-gray-200">
                                    <tr>
                                        <td class="px-6 py-4 whitespace-nowrap">
                                            <div class="flex items-center">
                                                <img src="http://static.photos/finance/200x200/4" alt="Agriculture" class="w-10 h-10 rounded-full mr-3">
                                                <div>
                                                    <p class="font-medium">Agriculture Fund</p>
                                                    <p class="text-sm text-gray-500">15-20% returns</p>
                                                </div>
                                            </div>
                                        </td>
                                        <td class="px-6 py-4 whitespace-nowrap">K500</td>
                                        <td class="px-6 py-4 whitespace-nowrap">
                                            <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">Active</span>
                                        </td>
                                        <td class="px-6 py-4 whitespace-nowrap">
                                            <button class="text-blue-600 hover:text-blue-900 mr-3">Edit</button>
                                            <button class="text-red-600 hover:text-red-900">Archive</button>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="px-6 py-4 whitespace-nowrap">
                                            <div class="flex items-center">
                                                <img src="http://static.photos/finance/200x200/5" alt="Real Estate" class="w-10 h-10 rounded-full mr-3">
                                                <div>
                                                    <p class="font-medium">Real Estate Trust</p>
                                                    <p class="text-sm text-gray-500">Monthly income</p>
                                                </div>
                                            </div>
                                        </td>
                                        <td class="px-6 py-4 whitespace-nowrap">K1000</td>
                                        <td class="px-6 py-4 whitespace-nowrap">
                                            <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">Active</span>
                                        </td>
                                        <td class="px-6 py-4 whitespace-nowrap">
                                            <button class="text-blue-600 hover:text-blue-900 mr-3">Edit</button>
                                            <button class="text-red-600 hover:text-red-900">Archive</button>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Settings -->
            <div class="bg-white rounded-lg shadow overflow-hidden mt-8">
                <div class="px-6 py-4 border-b">
                    <h2 class="text-xl font-bold">Platform Settings</h2>
                </div>
                <div class="p-6">
                    <div class="mb-4">
                        <label class="block font-bold mb-2">Referral Commission Rates</label>
                        <div class="grid grid-cols-3 gap-4">
                            <div>
                                <label class="block text-gray-700 mb-1">Level 1 (%)</label>
                                <input type="number" value="5" class="w-full px-4 py-2 border rounded-lg">
                            </div>
                            <div>
                                <label class="block text-gray-700 mb-1">Level 2 (%)</label>
                                <input type="number" value="3" class="w-full px-4 py-2 border rounded-lg">
                            </div>
                            <div>
                                <label class="block text-gray-700 mb-1">Level 3 (%)</label>
                                <input type="number" value="1" class="w-full px-4 py-2 border rounded-lg">
                            </div>
                        </div>
                    </div>
                    <button class="bg-blue-600 text-white px-6 py-2 rounded-lg hover:bg-blue-700">Save Settings</button>
                </div>
            </div>
        </div>
    </div>

    <script>
        // Admin wallet functions
        function adminAddFunds() {
            const email = document.getElementById('addFundsEmail').value;
            const amount = parseFloat(document.getElementById('addFundsAmount').value);
            const reason = document.getElementById('addFundsReason').value;
            
            if(!email || !amount || !reason) {
                alert('Please fill all fields');
                return;
            }
            
            if(confirm(`Add K${amount} to ${email} for "${reason}"?`)) {
                // In real app, would make API call here
                alert(`Successfully added K${amount} to ${email}'s wallet`);
                document.getElementById('addFundsEmail').value = '';
                document.getElementById('addFundsAmount').value = '';
                document.getElementById('addFundsReason').value = '';
            }
        }

        function adminDeductFunds() {
            const email = document.getElementById('deductFundsEmail').value;
            const amount = parseFloat(document.getElementById('deductFundsAmount').value);
            const reason = document.getElementById('deductFundsReason').value;
            
            if(!email || !amount || !reason) {
                alert('Please fill all fields');
                return;
            }
            
            if(confirm(`Deduct K${amount} from ${email} for "${reason}"?`)) {
                // In real app, would make API call here
                alert(`Successfully deducted K${amount} from ${email}'s wallet`);
                document.getElementById('deductFundsEmail').value = '';
                document.getElementById('deductFundsAmount').value = '';
                document.getElementById('deductFundsReason').value = '';
            }
        }
        feather.replace();
        
        // Admin functions
        function adminApproveTransaction(id, type) {
            // Update transaction status
            fetch(`/api/transactions/${id}/approve`, {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                    'Authorization': `Bearer ${localStorage.getItem('adminToken')}`
                },
                body: JSON.stringify({ type })
            })
            .then(response => response.json())
            .then(data => {
                if(data.success) {
                    alert(`Successfully approved ${type} transaction`);
                    location.reload();
                } else {
                    alert(`Error: ${data.message}`);
                }
            })
            .catch(error => {
                console.error('Error:', error);
                alert('Failed to approve transaction');
            });
        }

        function adminRejectTransaction(id, type) {
            const reason = prompt("Enter rejection reason:");
            if(reason) {
                fetch(`/api/transactions/${id}/reject`, {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                        'Authorization': `Bearer ${localStorage.getItem('adminToken')}`
                    },
                    body: JSON.stringify({ type, reason })
                })
                .then(response => response.json())
                .then(data => {
                    if(data.success) {
                        alert(`Transaction rejected: ${reason}`);
                        location.reload();
                    } else {
                        alert(`Error: ${data.message}`);
                    }
                })
                .catch(error => {
                    console.error('Error:', error);
                    alert('Failed to reject transaction');
                });
            }
        }

        // Logout
        document.getElementById('adminLogout').addEventListener('click', function() {
            localStorage.removeItem('adminToken');
            window.location.href = 'index.html';
        });

        // Check admin auth
        if(!localStorage.getItem('adminToken')) {
            window.location.href = 'index.html';
        }
    </script>
</body>
</html>