Update DistrictSelection back button

This commit is contained in:
NW 2024-12-14 13:16:22 +00:00
parent 207b9a829c
commit 12d29c66b9

View File

@ -128,20 +128,15 @@ export default class UserProductHandler {
const location = await LocationService.getLocation(country, city, district); const location = await LocationService.getLocation(country, city, district);
if (!location) { if (!location) {
throw new Error('Location not found'); // Если локация не найдена, вернуть пользователя к предыдущему шагу
}
const categories = await CategoryService.getCategoriesByLocationId(location.id);
if (categories.length === 0) {
await bot.editMessageText( await bot.editMessageText(
'No products available in this location yet.', 'Location not found. Returning to previous menu.',
{ {
chat_id: chatId, chat_id: chatId,
message_id: messageId, message_id: messageId,
reply_markup: { reply_markup: {
inline_keyboard: [[ inline_keyboard: [[
{text: '« Back to Districts', callback_data: `shop_city_${country}_${city}`} { text: '« Back', callback_data: 'shop_start' }
]] ]]
} }
} }
@ -149,13 +144,15 @@ export default class UserProductHandler {
return; return;
} }
const categories = await CategoryService.getCategoriesByLocationId(location.id);
const keyboard = { const keyboard = {
inline_keyboard: [ inline_keyboard: [
...categories.map(cat => [{ ...categories.map(cat => [{
text: cat.name, text: cat.name,
callback_data: `shop_category_${location.id}_${cat.id}` callback_data: `shop_category_${location.id}_${cat.id}`
}]), }]),
[{text: '« Back to Districts', callback_data: `shop_city_${country}_${city}`}] [{ text: '« Back', callback_data: `shop_city_${country}_${city}` }]
] ]
}; };