Another back to admin fix

This commit is contained in:
Artyom Ashirov 2024-11-15 00:21:34 +03:00
parent f504d5fb7b
commit ebad9da439
3 changed files with 32 additions and 28 deletions

View File

@ -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
}
);
}
}

View File

@ -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);
}
}

View File

@ -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