Back to admin menu fix

This commit is contained in:
Artyom Ashirov 2024-11-15 00:15:13 +03:00
parent d506d79367
commit f504d5fb7b
2 changed files with 55 additions and 27 deletions

View File

@ -1,4 +1,3 @@
import db from '../config/database.js';
import config from '../config/config.js';
export default class AdminHandler {
@ -32,4 +31,30 @@ export default class AdminHandler {
await this.bot.sendMessage(chatId, 'Admin Panel:', keyboard);
}
async handleAdminQueryCommand(callbackQuery) {
if (!this.isAdmin(callbackQuery.from.id)) return;
const chatId = callbackQuery.message.chat.id;
const messageId = callbackQuery.message.message_id;
const keyboard = {
reply_markup: {
keyboard: [
['👥 Manage Users', '📦 Manage Products'],
['💰 Manage Wallets', '📍 Manage Locations'],
['💾 Database Backup']
],
resize_keyboard: true
}
};
await this.bot.editMessageText(
`You we're returned to the admin menu`,
{
chat_id: chatId,
message_id: messageId,
reply_markup: keyboard
}
);
}
}

View File

@ -214,7 +214,10 @@ bot.on('callback_query', async (callbackQuery) => {
} else if (action.startsWith('confirm_delete_')) {
logDebug(action, 'handleConfirmDelete');
await adminLocationHandler.handleConfirmDelete(callbackQuery);
} else if (action === 'admin_menu') {
await adminHandler.handleAdminQueryCommand(callbackQuery);
}
// Admin product management
else if (action === 'manage_products') {
logDebug(action, 'handleProductManagement');