update viev balance

This commit is contained in:
NW 2024-12-17 00:19:53 +00:00
parent 4aebb4e41b
commit bfb9a55e36

View File

@ -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.';
}
@ -94,6 +102,44 @@ export default class UserWalletsHandler {
}
}
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;