From ebad9da43988424130582260e47ded4b02916fd6 Mon Sep 17 00:00:00 2001 From: Artyom Ashirov <1323ED5@gmail.com> Date: Fri, 15 Nov 2024 00:21:34 +0300 Subject: [PATCH] Another back to admin fix --- src/handlers/adminHandler.js | 27 ------------------------- src/handlers/adminLocationHandler.js | 30 ++++++++++++++++++++++++++++ src/index.js | 3 ++- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/handlers/adminHandler.js b/src/handlers/adminHandler.js index 7a2e037..ef86a95 100644 --- a/src/handlers/adminHandler.js +++ b/src/handlers/adminHandler.js @@ -30,31 +30,4 @@ 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 - } - ); - } } \ No newline at end of file diff --git a/src/handlers/adminLocationHandler.js b/src/handlers/adminLocationHandler.js index 57f1fc3..3c20209 100644 --- a/src/handlers/adminLocationHandler.js +++ b/src/handlers/adminLocationHandler.js @@ -278,4 +278,34 @@ export default class AdminLocationHandler { ); } } + + + async backToMenu(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 + } + ); + + this.userStates.delete(chatId); + } } \ No newline at end of file diff --git a/src/index.js b/src/index.js index e14cada..fde65c1 100644 --- a/src/index.js +++ b/src/index.js @@ -215,7 +215,8 @@ bot.on('callback_query', async (callbackQuery) => { logDebug(action, 'handleConfirmDelete'); await adminLocationHandler.handleConfirmDelete(callbackQuery); } else if (action === 'admin_menu') { - await adminHandler.handleAdminQueryCommand(callbackQuery); + logDebug(action, 'backToMenu'); + await adminLocationHandler.backToMenu(callbackQuery); } // Admin product management