chipflow-commander / transactions_topup.html
Xcronious's picture
tolong perhatikan lg fungsi fungsi yang ada di admin dashboard karna tidak seperti itu dan selesaikan semua modul yg tersisa
201773a verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ChipFlow - Top Up</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">Top Up Management</h1>
<div class="mb-6">
<button id="newTopupBtn" class="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700">
<i data-feather="plus" class="mr-2"></i>New Top Up
</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">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="topupTableBody">
<!-- Data will be loaded via JS -->
</tbody>
</table>
</div>
</div>
</div>
<script>
feather.replace();
// Load topup data
fetch('/api/topups')
.then(response => response.json())
.then(data => {
const tbody = document.getElementById('topupTableBody');
tbody.innerHTML = data.map(topup => `
<tr class="border-b">
<td class="py-3 px-4">${topup.id}</td>
<td class="py-3 px-4">${topup.customerName}</td>
<td class="py-3 px-4">${topup.bankName}</td>
<td class="py-3 px-4">${topup.amount}</td>
<td class="py-3 px-4">
<span class="px-2 py-1 rounded-full text-xs ${getStatusClass(topup.status)}">
${topup.status}
</span>
</td>
<td class="py-3 px-4">${new Date(topup.date).toLocaleDateString()}</td>
<td class="py-3 px-4">
<button onclick="viewTopup('${topup.id}')" class="text-blue-600 hover:text-blue-800 mr-2">
<i data-feather="eye"></i>
</button>
${topup.status === 'Pending' ? `
<button onclick="approveTopup('${topup.id}')" class="text-green-600 hover:text-green-800 mr-2">
<i data-feather="check"></i>
</button>
<button onclick="rejectTopup('${topup.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('newTopupBtn').addEventListener('click', () => {
window.location.href = '/topup_new.html';
});
function viewTopup(id) {
window.location.href = `/topup_detail.html?id=${id}`;
}
function approveTopup(id) {
fetch(`/api/topups/${id}/approve`, { method: 'POST' })
.then(() => window.location.reload());
}
function rejectTopup(id) {
fetch(`/api/topups/${id}/reject`, { method: 'POST' })
.then(() => window.location.reload());
}
</script>
</body>
</html>