Update DistrictSelection back button
This commit is contained in:
parent
207b9a829c
commit
12d29c66b9
@ -123,42 +123,39 @@ export default class UserProductHandler {
|
||||
const chatId = callbackQuery.message.chat.id;
|
||||
const messageId = callbackQuery.message.message_id;
|
||||
const [country, city, district] = callbackQuery.data.replace('shop_district_', '').split('_');
|
||||
|
||||
|
||||
try {
|
||||
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' }
|
||||
]]
|
||||
}
|
||||
}
|
||||
);
|
||||
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}` }]
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
await bot.editMessageText(
|
||||
'📦 Select category:',
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user