Spaces:
Running
Running
File size: 4,612 Bytes
201773a | 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 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ChipFlow - Transfers</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">Transfer Management</h1>
<div class="mb-6">
<button id="newTransferBtn" class="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700">
<i data-feather="plus" class="mr-2"></i>New Transfer
</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">From Customer</th>
<th class="py-3 px-4">To Customer</th>
<th class="py-3 px-4">Chips</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="transferTableBody">
<!-- Data will be loaded via JS -->
</tbody>
</table>
</div>
</div>
</div>
<script>
feather.replace();
// Load transfer data
fetch('/api/transfers')
.then(response => response.json())
.then(data => {
const tbody = document.getElementById('transferTableBody');
tbody.innerHTML = data.map(transfer => `
<tr class="border-b">
<td class="py-3 px-4">${transfer.id}</td>
<td class="py-3 px-4">${transfer.fromCustomer}</td>
<td class="py-3 px-4">${transfer.toCustomer}</td>
<td class="py-3 px-4">${transfer.chips}</td>
<td class="py-3 px-4">
<span class="px-2 py-1 rounded-full text-xs ${getStatusClass(transfer.status)}">
${transfer.status}
</span>
</td>
<td class="py-3 px-4">${new Date(transfer.date).toLocaleDateString()}</td>
<td class="py-3 px-4">
<button onclick="viewTransfer('${transfer.id}')" class="text-blue-600 hover:text-blue-800 mr-2">
<i data-feather="eye"></i>
</button>
${transfer.status === 'Pending' ? `
<button onclick="approveTransfer('${transfer.id}')" class="text-green-600 hover:text-green-800 mr-2">
<i data-feather="check"></i>
</button>
<button onclick="rejectTransfer('${transfer.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('newTransferBtn').addEventListener('click', () => {
window.location.href = '/transfer_new.html';
});
function viewTransfer(id) {
window.location.href = `/transfer_detail.html?id=${id}`;
}
function approveTransfer(id) {
fetch(`/api/transfers/${id}/approve`, { method: 'POST' })
.then(() => window.location.reload());
}
function rejectTransfer(id) {
fetch(`/api/transfers/${id}/reject`, { method: 'POST' })
.then(() => window.location.reload());
}
</script>
</body>
</html> |