diff --git a/src/handlers/userHandlers/userWalletsHandler.js b/src/handlers/userHandlers/userWalletsHandler.js index 276ce40..2ad8a76 100644 --- a/src/handlers/userHandlers/userWalletsHandler.js +++ b/src/handlers/userHandlers/userWalletsHandler.js @@ -59,7 +59,15 @@ export default class UserWalletsHandler { } } - message += `📊 *Total Balance:* $${totalUsdValue.toFixed(2)}\n`; + // Add total crypto balance + message += `💰 *Total Crypto Balance:* $${totalUsdValue.toFixed(2)}\n`; + + // Add bonus balance + message += `🎁 *Bonus Balance:* $${user.bonus_balance.toFixed(2)}\n`; + + // Add total balance + const totalBalance = user.bonus_balance + user.total_balance; + message += `📊 *Total Balance:* $${totalBalance.toFixed(2)}\n`; } else { message = 'You don\'t have any active wallets yet.'; } @@ -93,6 +101,44 @@ export default class UserWalletsHandler { await bot.sendMessage(chatId, 'Error loading balance. Please try again.'); } } + + static async handleRefreshBalance(callbackQuery) { + const chatId = callbackQuery.message.chat.id; + const messageId = callbackQuery.message.message_id; + + try { + await bot.editMessageText( + '🔄 Refreshing balances...', + { + chat_id: chatId, + message_id: messageId + } + ); + + // Re-fetch and display updated balances + await this.showBalance({ + chat: { id: chatId }, + from: { id: callbackQuery.from.id } + }); + + // Delete the "refreshing" message + await bot.deleteMessage(chatId, messageId); + } catch (error) { + console.error('Error in handleRefreshBalance:', error); + await bot.editMessageText( + '❌ Error refreshing balances. Please try again.', + { + chat_id: chatId, + message_id: messageId, + reply_markup: { + inline_keyboard: [[ + { text: '« Back', callback_data: 'back_to_balance' } + ]] + } + } + ); + } + } static async handleAddWallet(callbackQuery) { const chatId = callbackQuery.message.chat.id;