Spaces:
Running
Running
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>ChipFlow - Withdrawals</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script> | |
| </head> | |
| <body class="bg-gray-100"> | |
| <div class="container mx-auto p-4"> | |
| <div class="bg-white rounded-lg shadow p-6"> | |
| <h1 class="text-2xl font-bold mb-6">Withdrawal Management</h1> | |
| <div class="mb-6"> | |
| <button id="newWithdrawBtn" class="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700"> | |
| <i data-feather="plus" class="mr-2"></i>New Withdrawal | |
| </button> | |
| </div> | |
| <div class="overflow-x-auto"> | |
| <table class="min-w-full bg-white"> | |
| <thead> | |
| <tr class="bg-gray-100 text-left"> | |
| <th class="py-3 px-4">ID</th> | |
| <th class="py-3 px-4">Customer</th> | |
| <th class="py-3 px-4">Bank</th> | |
| <th class="py-3 px-4">Chips</th> | |
| <th class="py-3 px-4">Amount</th> | |
| <th class="py-3 px-4">Status</th> | |
| <th class="py-3 px-4">Date</th> | |
| <th class="py-3 px-4">Actions</th> | |
| </tr> | |
| </thead> | |
| <tbody id="withdrawTableBody"> | |
| <!-- Data will be loaded via JS --> | |
| </tbody> | |
| </table> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| feather.replace(); | |
| // Load withdrawal data | |
| fetch('/api/withdrawals') | |
| .then(response => response.json()) | |
| .then(data => { | |
| const tbody = document.getElementById('withdrawTableBody'); | |
| tbody.innerHTML = data.map(withdrawal => ` | |
| <tr class="border-b"> | |
| <td class="py-3 px-4">${withdrawal.id}</td> | |
| <td class="py-3 px-4">${withdrawal.customerName}</td> | |
| <td class="py-3 px-4">${withdrawal.bankName}</td> | |
| <td class="py-3 px-4">${withdrawal.chips}</td> | |
| <td class="py-3 px-4">${withdrawal.amount}</td> | |
| <td class="py-3 px-4"> | |
| <span class="px-2 py-1 rounded-full text-xs ${getStatusClass(withdrawal.status)}"> | |
| ${withdrawal.status} | |
| </span> | |
| </td> | |
| <td class="py-3 px-4">${new Date(withdrawal.date).toLocaleDateString()}</td> | |
| <td class="py-3 px-4"> | |
| <button onclick="viewWithdrawal('${withdrawal.id}')" class="text-blue-600 hover:text-blue-800 mr-2"> | |
| <i data-feather="eye"></i> | |
| </button> | |
| ${withdrawal.status === 'Pending' ? ` | |
| <button onclick="approveWithdrawal('${withdrawal.id}')" class="text-green-600 hover:text-green-800 mr-2"> | |
| <i data-feather="check"></i> | |
| </button> | |
| <button onclick="rejectWithdrawal('${withdrawal.id}')" class="text-red-600 hover:text-red-800"> | |
| <i data-feather="x"></i> | |
| </button> | |
| ` : ''} | |
| </td> | |
| </tr> | |
| `).join(''); | |
| feather.replace(); | |
| }); | |
| function getStatusClass(status) { | |
| return { | |
| 'Pending': 'bg-yellow-100 text-yellow-800', | |
| 'Completed': 'bg-green-100 text-green-800', | |
| 'Rejected': 'bg-red-100 text-red-800' | |
| }[status] || 'bg-gray-100 text-gray-800'; | |
| } | |
| document.getElementById('newWithdrawBtn').addEventListener('click', () => { | |
| window.location.href = '/withdraw_new.html'; | |
| }); | |
| function viewWithdrawal(id) { | |
| window.location.href = `/withdraw_detail.html?id=${id}`; | |
| } | |
| function approveWithdrawal(id) { | |
| fetch(`/api/withdrawals/${id}/approve`, { method: 'POST' }) | |
| .then(() => window.location.reload()); | |
| } | |
| function rejectWithdrawal(id) { | |
| fetch(`/api/withdrawals/${id}/reject`, { method: 'POST' }) | |
| .then(() => window.location.reload()); | |
| } | |
| </script> | |
| </body> | |
| </html> |