fix: wallet display bug, add test email endpoint

- Fix wallet balance always showing 'Disconnected' in admin dashboard
- Always attempt balance fetch even if isHealthy=false
- Show error state with message instead of generic 'Disconnected'
- Add POST /api/admin/alerts/test-email endpoint to verify Resend config
- Move alertService to module scope for endpoint access
This commit is contained in:
jwinterm
2026-02-01 15:59:30 -05:00
parent a81c19c936
commit 6e0f3e9012
2 changed files with 70 additions and 21 deletions
+19 -8
View File
@@ -498,17 +498,28 @@
// Wallet balance
if (overview.walletBalance) {
const bal = overview.walletBalance.unlocked_balance || 0;
const formatted = (bal / 1e12).toFixed(4);
document.getElementById('statBalance').textContent = formatted;
document.getElementById('statUnlocked').textContent = `Unlocked: ${formatted}`;
const walletEl = document.getElementById('walletStatus');
walletEl.className = 'wallet-status' + (bal < 100000000000 ? ' warning' : ' healthy');
document.getElementById('walletBalance').textContent = `${formatted} ${window.location.hostname.includes('monerogue') ? 'XMR' : 'WOW'}`;
const cryptoType = window.location.hostname.includes('monerogue') ? 'XMR' : 'WOW';
if (overview.walletBalance.error) {
// Wallet RPC error - show error state
document.getElementById('statBalance').textContent = 'Error';
document.getElementById('statUnlocked').textContent = overview.walletBalance.error;
document.getElementById('statUnlocked').title = overview.walletBalance.error;
walletEl.className = 'wallet-status disconnected';
document.getElementById('walletBalance').textContent = 'RPC Error';
} else {
// Wallet connected - show balance
const bal = overview.walletBalance.unlocked_balance || 0;
const formatted = (bal / 1e12).toFixed(4);
document.getElementById('statBalance').textContent = formatted;
document.getElementById('statUnlocked').textContent = `Unlocked: ${formatted}`;
walletEl.className = 'wallet-status' + (bal < 100000000000 ? ' warning' : ' healthy');
document.getElementById('walletBalance').textContent = `${formatted} ${cryptoType}`;
}
} else {
document.getElementById('statBalance').textContent = '-';
document.getElementById('walletBalance').textContent = 'Disconnected';
document.getElementById('walletBalance').textContent = 'Not configured';
document.getElementById('walletStatus').className = 'wallet-status disconnected';
}