From ea7f5dbd11794b6d656466944510f4f9162e50eb Mon Sep 17 00:00:00 2001 From: NW Date: Mon, 25 Nov 2024 23:58:05 +0000 Subject: [PATCH] Update handleCategoryUpdate --- src/handlers/adminHandlers/adminProductHandler.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/handlers/adminHandlers/adminProductHandler.js b/src/handlers/adminHandlers/adminProductHandler.js index f0cb537..684198e 100644 --- a/src/handlers/adminHandlers/adminProductHandler.js +++ b/src/handlers/adminHandlers/adminProductHandler.js @@ -255,6 +255,7 @@ export default class AdminProductHandler { const state = userStates.get(chatId); if (!state || !state.action?.startsWith('edit_category_')) { + console.log('[DEBUG] Invalid state or action:', state); return false; } @@ -266,11 +267,15 @@ export default class AdminProductHandler { try { const [locationId, categoryId] = state.action.replace('edit_category_', '').split('_'); + console.log('[DEBUG] Updating category:', { locationId, categoryId, newName: msg.text }); + await db.runAsync( 'UPDATE categories SET name = ? WHERE id = ? AND location_id = ?', [msg.text, categoryId, locationId] ); + console.log('[DEBUG] Category updated successfully'); + await bot.sendMessage( chatId, `✅ Название категории обновлено на "${msg.text}".`, @@ -288,7 +293,7 @@ export default class AdminProductHandler { userStates.delete(chatId); } catch (error) { - console.error('Ошибка обновления категории:', error); + console.error('[ERROR] Error updating category:', error); await bot.sendMessage(chatId, 'Ошибка обновления категории. Пожалуйста, попробуйте снова.'); }