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);
if (!location) {
throw new Error('Location not found');
}
const categories = await CategoryService.getCategoriesByLocationId(location.id);
if (categories.length === 0) {
// Если локация не найдена, вернуть пользователя к предыдущему шагу
await bot.editMessageText(
'No products available in this location yet.',
'Location not found. Returning to previous menu.',
{
chat_id: chatId,
message_id: messageId,
reply_markup: {
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;
}
const categories = await CategoryService.getCategoriesByLocationId(location.id);
const keyboard = {
inline_keyboard: [
...categories.map(cat => [{
text: cat.name,
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}` }]
]
};