diff --git a/LittleShop/littleshop.db-wal b/LittleShop/littleshop.db-wal index fb66879..7ff98da 100644 Binary files a/LittleShop/littleshop.db-wal and b/LittleShop/littleshop.db-wal differ diff --git a/TeleBot/TeleBot/Handlers/CallbackHandler.cs b/TeleBot/TeleBot/Handlers/CallbackHandler.cs index 615895d..91e97b9 100644 --- a/TeleBot/TeleBot/Handlers/CallbackHandler.cs +++ b/TeleBot/TeleBot/Handlers/CallbackHandler.cs @@ -194,13 +194,47 @@ namespace TeleBot.Handlers var category = categories.FirstOrDefault(c => c.Id == categoryId); var products = await _shopService.GetProductsAsync(categoryId, 1); + // Edit the original message to show category header (bigger, more prominent) + var headerText = $"šŸ›ļø **{category?.Name ?? "Unknown Category"} PRODUCTS**\n\nšŸ“‹ Browse individual products below:"; + await bot.EditMessageTextAsync( message.Chat.Id, message.MessageId, - MessageFormatter.FormatProductList(products, category?.Name), + headerText, parseMode: Telegram.Bot.Types.Enums.ParseMode.Markdown, - replyMarkup: MenuBuilder.ProductListMenu(products, categoryId, 1) + replyMarkup: MenuBuilder.CategoryNavigationMenu(categoryId) ); + + // Send individual product bubbles + if (products.Items.Any()) + { + foreach (var product in products.Items) + { + await bot.SendTextMessageAsync( + message.Chat.Id, + MessageFormatter.FormatSingleProduct(product), + parseMode: Telegram.Bot.Types.Enums.ParseMode.Markdown, + replyMarkup: MenuBuilder.SingleProductMenu(product.Id) + ); + } + + // Send navigation message after all products + await bot.SendTextMessageAsync( + message.Chat.Id, + "šŸ”½ *Navigation*", + parseMode: Telegram.Bot.Types.Enums.ParseMode.Markdown, + replyMarkup: MenuBuilder.ProductNavigationMenu(categoryId) + ); + } + else + { + await bot.SendTextMessageAsync( + message.Chat.Id, + "No products available in this category.", + replyMarkup: MenuBuilder.BackToCategoriesMenu() + ); + } + session.State = SessionState.ViewingProducts; } @@ -244,6 +278,14 @@ namespace TeleBot.Handlers replyMarkup: MenuBuilder.SingleProductMenu(product.Id) ); } + + // Send navigation message after all products + await bot.SendTextMessageAsync( + message.Chat.Id, + "šŸ”½ *Navigation*", + parseMode: Telegram.Bot.Types.Enums.ParseMode.Markdown, + replyMarkup: MenuBuilder.ProductNavigationMenu(categoryId) + ); } else { diff --git a/TeleBot/TeleBot/UI/MenuBuilder.cs b/TeleBot/TeleBot/UI/MenuBuilder.cs index 9594d08..d950c8e 100644 --- a/TeleBot/TeleBot/UI/MenuBuilder.cs +++ b/TeleBot/TeleBot/UI/MenuBuilder.cs @@ -28,9 +28,11 @@ namespace TeleBot.UI foreach (var category in categories) { + // Add description to category button text + var categoryText = GetCategoryDisplayText(category.Name, category.Description); buttons.Add(new[] { InlineKeyboardButton.WithCallbackData( - $"šŸ“ {category.Name}", + categoryText, $"category:{category.Id}" ) }); @@ -352,5 +354,45 @@ namespace TeleBot.UI } }); } + + public static InlineKeyboardMarkup ProductNavigationMenu(Guid? categoryId) + { + return new InlineKeyboardMarkup(new[] + { + new[] { + InlineKeyboardButton.WithCallbackData("ā¬…ļø Back to Categories", "browse"), + InlineKeyboardButton.WithCallbackData("šŸ›’ View Cart", "cart") + }, + new[] { + InlineKeyboardButton.WithCallbackData("šŸ  Main Menu", "menu") + } + }); + } + + private static string GetCategoryDisplayText(string categoryName, string? description) + { + var emoji = categoryName.ToLower() switch + { + var name when name.Contains("electronics") => "šŸ“±", + var name when name.Contains("clothing") || name.Contains("fashion") => "šŸ‘•", + var name when name.Contains("books") || name.Contains("book") => "šŸ“š", + var name when name.Contains("home") || name.Contains("house") => "šŸ ", + var name when name.Contains("sports") || name.Contains("fitness") => "⚽", + var name when name.Contains("beauty") || name.Contains("cosmetics") => "šŸ’„", + var name when name.Contains("food") || name.Contains("grocery") => "šŸŽ", + _ => "šŸ“¦" + }; + + if (!string.IsNullOrEmpty(description)) + { + // Truncate description for button + var shortDesc = description.Length > 40 + ? description.Substring(0, 37) + "..." + : description; + return $"{emoji} {categoryName}\n{shortDesc}"; + } + + return $"{emoji} {categoryName}"; + } } } \ No newline at end of file diff --git a/TeleBot/TeleBot/UI/MessageFormatter.cs b/TeleBot/TeleBot/UI/MessageFormatter.cs index 125a95f..59c0016 100644 --- a/TeleBot/TeleBot/UI/MessageFormatter.cs +++ b/TeleBot/TeleBot/UI/MessageFormatter.cs @@ -30,18 +30,8 @@ namespace TeleBot.UI public static string FormatCategories(List categories) { var sb = new StringBuilder(); - sb.AppendLine("šŸ“ *Product Categories*\n"); - - foreach (var category in categories) - { - sb.AppendLine($"• *{category.Name}*"); - if (!string.IsNullOrEmpty(category.Description)) - { - sb.AppendLine($" _{category.Description}_"); - } - } - - sb.AppendLine("\nSelect a category to browse products:"); + sb.AppendLine("šŸ›ļø **PRODUCT CATEGORIES**\n"); + sb.AppendLine("šŸ”½ Choose a category to start shopping:"); return sb.ToString(); }