feat: admin panel - Settings, Categories, Payment Wallets, Seed/Clear data, User Balances

- Settings page: bot token (masked), admin IDs, commission config, WireGuard status
- Categories page: CRUD with product count, delete guard
- Payment Wallets page: commission wallets display, toggle, percentage
- Users page: balance adjustment form (total_balance / bonus_balance) with audit log
- Seed & Reset page: seed demo data (5 users, 10 products, 5 wallets, 5 purchases)
  and clear all data button with confirmation
- Dashboard: flash messages for seed/clear success
- Fixed seed.js: use dynamic IDs instead of hardcoded to avoid FK violations
- Fixed seed.js: clear all tables before seeding to avoid UNIQUE constraints
This commit is contained in:
NW
2026-06-22 14:20:58 +01:00
parent 4657b1dfb5
commit 2012435370
15 changed files with 414 additions and 4 deletions

View File

@@ -0,0 +1,32 @@
import { layout } from './layout.js';
export function renderPaymentWallets(data) {
const walletRows = Object.entries(data.wallets).map(([type, addr]) =>
`<tr>
<td><strong>${type}</strong></td>
<td><code>${escapeHtml(addr || 'Not set')}</code></td>
</tr>`
).join('');
const content = `
<div class="detail-card">
<h2>Commission Status</h2>
<p><strong>Commission:</strong> <span class="badge badge-${data.commissionEnabled ? 'active' : 'banned'}">${data.commissionEnabled ? 'ON' : 'OFF'}</span></p>
<p><strong>Percentage:</strong> ${data.commissionPercent}%</p>
</div>
<div class="detail-card">
<h2>Commission Wallet Addresses</h2>
<p class="muted">These are the shop's payment wallets. Edit them in the <code>.env</code> file.</p>
<table>
<thead><tr><th>Currency</th><th>Address</th></tr></thead>
<tbody>${walletRows}</tbody>
</table>
</div>
`;
return layout('Payment Wallets', content, 'payment-wallets');
}
function escapeHtml(str) {
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}