feat: Add customer management, payments, and push notifications with security enhancements
Some checks failed
Build and Deploy LittleShop / Build TeleBot Docker Image (push) Failing after 11s
Build and Deploy LittleShop / Build LittleShop Docker Image (push) Failing after 15s
Build and Deploy LittleShop / Deploy to Production VPS (Manual Only) (push) Has been skipped
Build and Deploy LittleShop / Deploy to Pre-Production (CT109) (push) Has been skipped

Major Feature Additions:
- Customer management: Full CRUD with data export and privacy compliance
- Payment management: Centralized payment tracking and administration
- Push notification subscriptions: Manage and track web push subscriptions

Security Enhancements:
- IP whitelist middleware for administrative endpoints
- Data retention service with configurable policies
- Enhanced push notification security documentation
- Security fixes progress tracking (2025-11-14)

UI/UX Improvements:
- Enhanced navigation with improved mobile responsiveness
- Updated admin dashboard with order status counts
- Improved product CRUD forms
- New customer and payment management interfaces

Backend Improvements:
- Extended customer service with data export capabilities
- Enhanced order service with status count queries
- Improved crypto payment service with better error handling
- Updated validators and configuration

Documentation:
- DEPLOYMENT_NGINX_GUIDE.md: Nginx deployment instructions
- IP_STORAGE_ANALYSIS.md: IP storage security analysis
- PUSH_NOTIFICATION_SECURITY.md: Push notification security guide
- UI_UX_IMPROVEMENT_PLAN.md: Planned UI/UX enhancements
- UI_UX_IMPROVEMENTS_COMPLETED.md: Completed improvements

Cleanup:
- Removed temporary database WAL files
- Removed stale commit message file

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-16 19:33:02 +00:00
parent 47e43d4ff8
commit a2247d7c02
45 changed files with 5302 additions and 371 deletions

View File

@@ -28,14 +28,12 @@ public class AccountController : Controller
}
[HttpPost]
// [ValidateAntiForgeryToken] // Temporarily disabled for HTTPS proxy issue
[ValidateAntiForgeryToken]
public async Task<IActionResult> Login(string Username, string Password)
{
// Make parameters case-insensitive for form compatibility
var username = Username?.ToLowerInvariant();
var password = Password;
Console.WriteLine($"Received Username: '{username}', Password: '{password}'");
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
{

View File

@@ -74,16 +74,6 @@ public class BotsController : Controller
[ValidateAntiForgeryToken]
public async Task<IActionResult> Wizard(BotWizardDto dto)
{
Console.WriteLine("=== BOT WIZARD DEBUG ===");
Console.WriteLine($"Received: BotName='{dto?.BotName}', BotUsername='{dto?.BotUsername}', PersonalityName='{dto?.PersonalityName}'");
Console.WriteLine($"ModelState.IsValid: {ModelState.IsValid}");
Console.WriteLine("Raw form data:");
foreach (var key in Request.Form.Keys)
{
Console.WriteLine($" {key} = '{Request.Form[key]}'");
}
Console.WriteLine("========================");
_logger.LogInformation("Wizard POST received - BotName: '{BotName}', BotUsername: '{BotUsername}'", dto.BotName, dto.BotUsername);
if (!ModelState.IsValid)
@@ -102,7 +92,6 @@ public class BotsController : Controller
var personalities = new[] { "Alan", "Dave", "Sarah", "Mike", "Emma", "Tom" };
var random = new Random();
dto.PersonalityName = personalities[random.Next(personalities.Length)];
Console.WriteLine($"Auto-assigned personality: {dto.PersonalityName}");
}
// Generate BotFather commands

View File

@@ -31,15 +31,8 @@ public class CategoriesController : Controller
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(CreateCategoryDto model)
{
Console.WriteLine($"Received Category: Name='{model?.Name}', Description='{model?.Description}'");
Console.WriteLine($"ModelState.IsValid: {ModelState.IsValid}");
if (!ModelState.IsValid)
{
foreach (var error in ModelState)
{
Console.WriteLine($"ModelState Error - Key: {error.Key}, Errors: {string.Join(", ", error.Value.Errors.Select(e => e.ErrorMessage))}");
}
return View(model);
}
@@ -70,18 +63,8 @@ public class CategoriesController : Controller
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(Guid id, UpdateCategoryDto model)
{
Console.WriteLine($"Edit POST - CategoryId: {id}");
Console.WriteLine($"Edit POST - Name: '{model?.Name}'");
Console.WriteLine($"Edit POST - Description: '{model?.Description}'");
Console.WriteLine($"Edit POST - IsActive: {model?.IsActive} (HasValue: {model?.IsActive.HasValue})");
Console.WriteLine($"ModelState.IsValid: {ModelState.IsValid}");
if (!ModelState.IsValid)
{
foreach (var error in ModelState)
{
Console.WriteLine($"ModelState Error - Key: {error.Key}, Errors: {string.Join(", ", error.Value.Errors.Select(e => e.ErrorMessage))}");
}
ViewData["CategoryId"] = id;
return View(model);
}

View File

@@ -0,0 +1,339 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using LittleShop.Services;
using LittleShop.DTOs;
namespace LittleShop.Areas.Admin.Controllers;
[Area("Admin")]
[Authorize(AuthenticationSchemes = "Cookies", Roles = "Admin")]
public class CustomersController : Controller
{
private readonly ICustomerService _customerService;
private readonly IOrderService _orderService;
private readonly ILogger<CustomersController> _logger;
public CustomersController(
ICustomerService customerService,
IOrderService orderService,
ILogger<CustomersController> logger)
{
_customerService = customerService;
_orderService = orderService;
_logger = logger;
}
public async Task<IActionResult> Index(string searchTerm = "")
{
try
{
IEnumerable<CustomerDto> customers;
if (!string.IsNullOrWhiteSpace(searchTerm))
{
customers = await _customerService.SearchCustomersAsync(searchTerm);
ViewData["SearchTerm"] = searchTerm;
}
else
{
customers = await _customerService.GetAllCustomersAsync();
}
return View(customers.OrderByDescending(c => c.CreatedAt));
}
catch (Exception ex)
{
_logger.LogError(ex, "Error loading customers index");
TempData["ErrorMessage"] = "Error loading customers";
return View(new List<CustomerDto>());
}
}
public async Task<IActionResult> Details(Guid id)
{
try
{
var customer = await _customerService.GetCustomerByIdAsync(id);
if (customer == null)
{
TempData["ErrorMessage"] = "Customer not found";
return RedirectToAction(nameof(Index));
}
// Get customer's order history
var allOrders = await _orderService.GetAllOrdersAsync();
var customerOrders = allOrders
.Where(o => o.CustomerId == id)
.OrderByDescending(o => o.CreatedAt)
.ToList();
ViewData["CustomerOrders"] = customerOrders;
return View(customer);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error loading customer {CustomerId}", id);
TempData["ErrorMessage"] = "Error loading customer details";
return RedirectToAction(nameof(Index));
}
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Block(Guid id, string reason)
{
try
{
if (string.IsNullOrWhiteSpace(reason))
{
TempData["ErrorMessage"] = "Block reason is required";
return RedirectToAction(nameof(Details), new { id });
}
var success = await _customerService.BlockCustomerAsync(id, reason);
if (success)
{
_logger.LogWarning("Customer {CustomerId} blocked by admin. Reason: {Reason}", id, reason);
TempData["SuccessMessage"] = "Customer blocked successfully";
}
else
{
TempData["ErrorMessage"] = "Failed to block customer";
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Error blocking customer {CustomerId}", id);
TempData["ErrorMessage"] = "Error blocking customer";
}
return RedirectToAction(nameof(Details), new { id });
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Unblock(Guid id)
{
try
{
var success = await _customerService.UnblockCustomerAsync(id);
if (success)
{
_logger.LogInformation("Customer {CustomerId} unblocked by admin", id);
TempData["SuccessMessage"] = "Customer unblocked successfully";
}
else
{
TempData["ErrorMessage"] = "Failed to unblock customer";
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Error unblocking customer {CustomerId}", id);
TempData["ErrorMessage"] = "Error unblocking customer";
}
return RedirectToAction(nameof(Details), new { id });
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> RefreshRiskScore(Guid id)
{
try
{
await _customerService.UpdateCustomerMetricsAsync(id);
TempData["SuccessMessage"] = "Risk score recalculated successfully";
}
catch (Exception ex)
{
_logger.LogError(ex, "Error refreshing risk score for customer {CustomerId}", id);
TempData["ErrorMessage"] = "Error refreshing risk score";
}
return RedirectToAction(nameof(Details), new { id });
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Delete(Guid id)
{
try
{
var success = await _customerService.DeleteCustomerAsync(id);
if (success)
{
_logger.LogWarning("Customer {CustomerId} deleted by admin", id);
TempData["SuccessMessage"] = "Customer deleted successfully (soft delete - data retained)";
return RedirectToAction(nameof(Index));
}
else
{
TempData["ErrorMessage"] = "Failed to delete customer";
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Error deleting customer {CustomerId}", id);
TempData["ErrorMessage"] = "Error deleting customer";
}
return RedirectToAction(nameof(Details), new { id });
}
/// <summary>
/// Export customer data as JSON (GDPR "Right to Data Portability")
/// </summary>
[HttpGet]
public async Task<IActionResult> ExportJson(Guid id)
{
try
{
var exportData = await _customerService.GetCustomerDataForExportAsync(id);
if (exportData == null)
{
return NotFound();
}
var fileName = $"customer-data-{exportData.TelegramUsername ?? exportData.TelegramUserId.ToString()}-{DateTime.UtcNow:yyyyMMdd-HHmmss}.json";
var jsonOptions = new System.Text.Json.JsonSerializerOptions
{
WriteIndented = true,
PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase
};
var jsonData = System.Text.Json.JsonSerializer.Serialize(exportData, jsonOptions);
_logger.LogInformation("Customer {CustomerId} data exported as JSON by admin", id);
return File(System.Text.Encoding.UTF8.GetBytes(jsonData), "application/json", fileName);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error exporting customer {CustomerId} data as JSON", id);
TempData["ErrorMessage"] = "Error generating JSON export";
return RedirectToAction(nameof(Details), new { id });
}
}
/// <summary>
/// Export customer data as CSV (GDPR "Right to Data Portability")
/// </summary>
[HttpGet]
public async Task<IActionResult> ExportCsv(Guid id)
{
try
{
var exportData = await _customerService.GetCustomerDataForExportAsync(id);
if (exportData == null)
{
return NotFound();
}
var fileName = $"customer-data-{exportData.TelegramUsername ?? exportData.TelegramUserId.ToString()}-{DateTime.UtcNow:yyyyMMdd-HHmmss}.csv";
var csvData = GenerateCsvExport(exportData);
_logger.LogInformation("Customer {CustomerId} data exported as CSV by admin", id);
return File(System.Text.Encoding.UTF8.GetBytes(csvData), "text/csv", fileName);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error exporting customer {CustomerId} data as CSV", id);
TempData["ErrorMessage"] = "Error generating CSV export";
return RedirectToAction(nameof(Details), new { id });
}
}
/// <summary>
/// Helper method to generate CSV export from customer data
/// </summary>
private string GenerateCsvExport(LittleShop.DTOs.CustomerDataExportDto exportData)
{
var csv = new System.Text.StringBuilder();
// Customer Profile Section
csv.AppendLine("CUSTOMER PROFILE");
csv.AppendLine("Field,Value");
csv.AppendLine($"Customer ID,{exportData.CustomerId}");
csv.AppendLine($"Telegram User ID,{exportData.TelegramUserId}");
csv.AppendLine($"Telegram Username,\"{EscapeCsv(exportData.TelegramUsername)}\"");
csv.AppendLine($"Telegram Display Name,\"{EscapeCsv(exportData.TelegramDisplayName)}\"");
csv.AppendLine($"First Name,\"{EscapeCsv(exportData.TelegramFirstName)}\"");
csv.AppendLine($"Last Name,\"{EscapeCsv(exportData.TelegramLastName)}\"");
csv.AppendLine($"Email,\"{EscapeCsv(exportData.Email)}\"");
csv.AppendLine($"Phone,\"{EscapeCsv(exportData.PhoneNumber)}\"");
csv.AppendLine($"Allow Marketing,{exportData.AllowMarketing}");
csv.AppendLine($"Allow Order Updates,{exportData.AllowOrderUpdates}");
csv.AppendLine($"Language,{exportData.Language}");
csv.AppendLine($"Timezone,{exportData.Timezone}");
csv.AppendLine($"Total Orders,{exportData.TotalOrders}");
csv.AppendLine($"Total Spent,{exportData.TotalSpent:F2}");
csv.AppendLine($"Average Order Value,{exportData.AverageOrderValue:F2}");
csv.AppendLine($"Is Blocked,{exportData.IsBlocked}");
csv.AppendLine($"Block Reason,\"{EscapeCsv(exportData.BlockReason)}\"");
csv.AppendLine($"Risk Score,{exportData.RiskScore}");
csv.AppendLine($"Created At,{exportData.CreatedAt:yyyy-MM-dd HH:mm:ss}");
csv.AppendLine($"Updated At,{exportData.UpdatedAt:yyyy-MM-dd HH:mm:ss}");
csv.AppendLine();
// Orders Section
csv.AppendLine("ORDERS");
csv.AppendLine("Order ID,Status,Total Amount,Currency,Order Date,Shipping Name,Shipping Address,City,Post Code,Country,Tracking Number");
foreach (var order in exportData.Orders)
{
csv.AppendLine($"{order.OrderId},{order.Status},{order.TotalAmount:F2},{order.Currency},{order.OrderDate:yyyy-MM-dd HH:mm:ss}," +
$"\"{EscapeCsv(order.ShippingName)}\",\"{EscapeCsv(order.ShippingAddress)}\",\"{EscapeCsv(order.ShippingCity)}\"," +
$"\"{order.ShippingPostCode}\",\"{order.ShippingCountry}\",\"{EscapeCsv(order.TrackingNumber)}\"");
// Order Items sub-section
if (order.Items.Any())
{
csv.AppendLine(" Order Items:");
csv.AppendLine(" Product Name,Variant,Quantity,Unit Price,Total Price");
foreach (var item in order.Items)
{
csv.AppendLine($" \"{EscapeCsv(item.ProductName)}\",\"{EscapeCsv(item.VariantName)}\"," +
$"{item.Quantity},{item.UnitPrice:F2},{item.TotalPrice:F2}");
}
}
}
csv.AppendLine();
// Messages Section
if (exportData.Messages.Any())
{
csv.AppendLine("MESSAGES");
csv.AppendLine("Sent At,Type,Content,Was Read,Read At");
foreach (var message in exportData.Messages)
{
csv.AppendLine($"{message.SentAt:yyyy-MM-dd HH:mm:ss},{message.MessageType}," +
$"\"{EscapeCsv(message.Content)}\",{message.WasRead}," +
$"{(message.ReadAt.HasValue ? message.ReadAt.Value.ToString("yyyy-MM-dd HH:mm:ss") : "")}");
}
csv.AppendLine();
}
// Reviews Section
if (exportData.Reviews.Any())
{
csv.AppendLine("REVIEWS");
csv.AppendLine("Product Name,Rating,Comment,Created At,Is Approved,Is Verified Purchase");
foreach (var review in exportData.Reviews)
{
csv.AppendLine($"\"{EscapeCsv(review.ProductName)}\",{review.Rating}," +
$"\"{EscapeCsv(review.Comment)}\",{review.CreatedAt:yyyy-MM-dd HH:mm:ss}," +
$"{review.IsApproved},{review.IsVerifiedPurchase}");
}
}
return csv.ToString();
}
/// <summary>
/// Escape CSV values containing quotes, commas, or newlines
/// </summary>
private string EscapeCsv(string? value)
{
if (string.IsNullOrEmpty(value)) return string.Empty;
return value.Replace("\"", "\"\""); // Escape quotes by doubling them
}
}

View File

@@ -56,12 +56,13 @@ public class OrdersController : Controller
break;
}
// Get workflow counts for tab badges
ViewData["PendingCount"] = (await _orderService.GetOrdersByStatusAsync(LittleShop.Enums.OrderStatus.PendingPayment)).Count();
ViewData["AcceptCount"] = (await _orderService.GetOrdersRequiringActionAsync()).Count();
ViewData["PackingCount"] = (await _orderService.GetOrdersForPackingAsync()).Count();
ViewData["DispatchedCount"] = (await _orderService.GetOrdersByStatusAsync(LittleShop.Enums.OrderStatus.Dispatched)).Count();
ViewData["OnHoldCount"] = (await _orderService.GetOrdersOnHoldAsync()).Count();
// Get workflow counts for tab badges (single optimized query)
var statusCounts = await _orderService.GetOrderStatusCountsAsync();
ViewData["PendingCount"] = statusCounts.PendingPaymentCount;
ViewData["AcceptCount"] = statusCounts.RequiringActionCount;
ViewData["PackingCount"] = statusCounts.ForPackingCount;
ViewData["DispatchedCount"] = statusCounts.DispatchedCount;
ViewData["OnHoldCount"] = statusCounts.OnHoldCount;
return View();
}
@@ -137,15 +138,6 @@ public class OrdersController : Controller
{
if (!ModelState.IsValid)
{
// Log validation errors for debugging
foreach (var error in ModelState)
{
if (error.Value?.Errors.Count > 0)
{
Console.WriteLine($"Validation error for {error.Key}: {string.Join(", ", error.Value.Errors.Select(e => e.ErrorMessage))}");
}
}
// Return to details page with error
var order = await _orderService.GetOrderByIdAsync(id);
if (order == null)

View File

@@ -0,0 +1,53 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using LittleShop.Services;
using LittleShop.Enums;
namespace LittleShop.Areas.Admin.Controllers;
[Area("Admin")]
[Authorize(AuthenticationSchemes = "Cookies", Roles = "Admin")]
public class PaymentsController : Controller
{
private readonly ICryptoPaymentService _paymentService;
private readonly IOrderService _orderService;
private readonly ILogger<PaymentsController> _logger;
public PaymentsController(
ICryptoPaymentService paymentService,
IOrderService orderService,
ILogger<PaymentsController> _logger)
{
_paymentService = paymentService;
_orderService = orderService;
this._logger = _logger;
}
//GET: Admin/Payments
public async Task<IActionResult> Index(string? status = null)
{
try
{
var payments = await _paymentService.GetAllPaymentsAsync();
// Filter by status if provided
if (!string.IsNullOrEmpty(status) && Enum.TryParse<PaymentStatus>(status, out var paymentStatus))
{
payments = payments.Where(p => p.Status == paymentStatus);
ViewData["CurrentStatus"] = status;
}
// Get orders for payment-order linking
var allOrders = await _orderService.GetAllOrdersAsync();
ViewData["Orders"] = allOrders.ToDictionary(o => o.Id, o => o);
return View(payments.OrderByDescending(p => p.CreatedAt));
}
catch (Exception ex)
{
_logger.LogError(ex, "Error retrieving payments list");
TempData["ErrorMessage"] = "Failed to load payments. Please try again.";
return View(Enumerable.Empty<LittleShop.DTOs.CryptoPaymentDto>());
}
}
}

View File

@@ -14,13 +14,17 @@ public class ProductsController : Controller
private readonly ICategoryService _categoryService;
private readonly IProductImportService _importService;
private readonly IVariantCollectionService _variantCollectionService;
private readonly IReviewService _reviewService;
private readonly ILogger<ProductsController> _logger;
public ProductsController(IProductService productService, ICategoryService categoryService, IProductImportService importService, IVariantCollectionService variantCollectionService)
public ProductsController(IProductService productService, ICategoryService categoryService, IProductImportService importService, IVariantCollectionService variantCollectionService, IReviewService reviewService, ILogger<ProductsController> logger)
{
_productService = productService;
_categoryService = categoryService;
_importService = importService;
_variantCollectionService = variantCollectionService;
_reviewService = reviewService;
_logger = logger;
}
public async Task<IActionResult> Index()
@@ -49,24 +53,11 @@ public class ProductsController : Controller
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(CreateProductDto model)
{
Console.WriteLine($"Received Product: Name='{model?.Name}', Description='{model?.Description}', Price={model?.Price}, Stock={model?.StockQuantity}");
Console.WriteLine($"CategoryId: {model?.CategoryId}");
Console.WriteLine($"Weight: {model?.Weight}, WeightUnit: {model?.WeightUnit}");
Console.WriteLine($"ModelState.IsValid: {ModelState.IsValid}");
// Remove Description validation errors since it's optional
ModelState.Remove("Description");
if (!ModelState.IsValid)
{
Console.WriteLine("Validation errors:");
foreach (var error in ModelState)
{
if (error.Value?.Errors.Count > 0)
{
Console.WriteLine($" {error.Key}: {string.Join(", ", error.Value.Errors.Select(e => e.ErrorMessage))}");
}
}
var categories = await _categoryService.GetAllCategoriesAsync();
ViewData["Categories"] = categories.Where(c => c.IsActive);
@@ -114,32 +105,9 @@ public class ProductsController : Controller
product.VariantsJson = System.Text.Json.JsonSerializer.Serialize(variantsForJson);
}
// TODO: Add ReviewService injection and retrieve actual reviews
// For now, providing mock review data for demonstration
ViewData["ProductReviews"] = new[]
{
new {
Rating = 5,
CustomerName = "John D.",
Comment = "Excellent quality! Exceeded my expectations.",
CreatedAt = DateTime.Now.AddDays(-7),
OrderReference = "ORD-123456"
},
new {
Rating = 4,
CustomerName = "Sarah M.",
Comment = "Very good product, fast delivery.",
CreatedAt = DateTime.Now.AddDays(-14),
OrderReference = "ORD-789012"
},
new {
Rating = 5,
CustomerName = (string?)null, // Anonymous
Comment = "Love it! Will order again.",
CreatedAt = DateTime.Now.AddDays(-21),
OrderReference = "ORD-345678"
}
};
// Load actual product reviews from ReviewService
var productReviews = await _reviewService.GetReviewsByProductAsync(id, approvedOnly: true);
ViewData["ProductReviews"] = productReviews;
var model = new UpdateProductDto
{
@@ -325,16 +293,29 @@ public class ProductsController : Controller
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteAllSalesData()
public async Task<IActionResult> DeleteAllSalesData(string confirmText)
{
// Require explicit typed confirmation
if (confirmText != "DELETE ALL SALES DATA")
{
TempData["ErrorMessage"] = "❌ Confirmation text did not match. Operation cancelled for safety.";
return RedirectToAction(nameof(Index));
}
try
{
var deletedCount = await _importService.DeleteAllOrdersAndSalesDataAsync();
// Log this critical action
_logger.LogWarning("CRITICAL: User {UserId} deleted ALL sales data ({Count} records)",
User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier)?.Value, deletedCount);
TempData["SuccessMessage"] = $"✅ Successfully deleted {deletedCount} sales records (orders, payments, customers, messages)";
return RedirectToAction(nameof(Index));
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to delete all sales data");
TempData["ErrorMessage"] = $"Failed to delete sales data: {ex.Message}";
return RedirectToAction(nameof(Index));
}

View File

@@ -0,0 +1,107 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using LittleShop.Services;
namespace LittleShop.Areas.Admin.Controllers;
[Area("Admin")]
[Authorize(AuthenticationSchemes = "Cookies", Roles = "Admin")]
public class PushSubscriptionsController : Controller
{
private readonly IPushNotificationService _pushService;
private readonly ILogger<PushSubscriptionsController> _logger;
public PushSubscriptionsController(
IPushNotificationService pushService,
ILogger<PushSubscriptionsController> logger)
{
_pushService = pushService;
_logger = logger;
}
// GET: Admin/PushSubscriptions
public async Task<IActionResult> Index()
{
try
{
var subscriptions = await _pushService.GetActiveSubscriptionsAsync();
return View(subscriptions.OrderByDescending(s => s.SubscribedAt));
}
catch (Exception ex)
{
_logger.LogError(ex, "Error retrieving push subscriptions list");
TempData["ErrorMessage"] = "Failed to load push subscriptions. Please try again.";
return View(new List<LittleShop.Models.PushSubscription>());
}
}
// POST: Admin/PushSubscriptions/Delete/{id}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Delete(int id)
{
try
{
// Find subscription by ID and delete via UnsubscribeAsync (which uses endpoint)
var subscriptions = await _pushService.GetActiveSubscriptionsAsync();
var subscription = subscriptions.FirstOrDefault(s => s.Id == id);
if (subscription == null)
{
TempData["ErrorMessage"] = "Push subscription not found.";
return RedirectToAction(nameof(Index));
}
var success = await _pushService.UnsubscribeAsync(subscription.Endpoint);
if (success)
{
_logger.LogInformation("Deleted push subscription {Id} (Endpoint: {Endpoint})", id, subscription.Endpoint);
TempData["SuccessMessage"] = "Push subscription deleted successfully.";
}
else
{
_logger.LogWarning("Failed to delete push subscription {Id}", id);
TempData["ErrorMessage"] = "Failed to delete push subscription.";
}
return RedirectToAction(nameof(Index));
}
catch (Exception ex)
{
_logger.LogError(ex, "Error deleting push subscription {Id}", id);
TempData["ErrorMessage"] = $"Error deleting push subscription: {ex.Message}";
return RedirectToAction(nameof(Index));
}
}
// POST: Admin/PushSubscriptions/CleanupExpired
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> CleanupExpired()
{
try
{
var deletedCount = await _pushService.CleanupExpiredSubscriptionsAsync();
_logger.LogInformation("Cleaned up {Count} expired push subscriptions", deletedCount);
if (deletedCount > 0)
{
TempData["SuccessMessage"] = $"Successfully cleaned up {deletedCount} expired subscription(s).";
}
else
{
TempData["InfoMessage"] = "No expired subscriptions found to clean up.";
}
return RedirectToAction(nameof(Index));
}
catch (Exception ex)
{
_logger.LogError(ex, "Error cleaning up expired push subscriptions");
TempData["ErrorMessage"] = $"Error during cleanup: {ex.Message}";
return RedirectToAction(nameof(Index));
}
}
}

View File

@@ -55,6 +55,7 @@ public class ReviewsController : Controller
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Approve(Guid id)
{
try
@@ -86,6 +87,7 @@ public class ReviewsController : Controller
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Delete(Guid id)
{
try

View File

@@ -86,9 +86,9 @@ public class UsersController : Controller
}
// Validate password if provided
if (!string.IsNullOrEmpty(model.Password) && model.Password.Length < 3)
if (!string.IsNullOrEmpty(model.Password) && model.Password.Length < 8)
{
ModelState.AddModelError("Password", "Password must be at least 3 characters if changing");
ModelState.AddModelError("Password", "Password must be at least 8 characters if changing");
}
if (!ModelState.IsValid)

View File

@@ -0,0 +1,445 @@
@model LittleShop.DTOs.CustomerDto
@{
ViewData["Title"] = $"Customer: {Model.TelegramDisplayName}";
var customerOrders = ViewData["CustomerOrders"] as List<LittleShop.DTOs.OrderDto> ?? new List<LittleShop.DTOs.OrderDto>();
}
<div class="row mb-3">
<div class="col">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="@Url.Action("Index", "Dashboard")">Dashboard</a></li>
<li class="breadcrumb-item"><a href="@Url.Action("Index", "Customers")">Customers</a></li>
<li class="breadcrumb-item active">@Model.TelegramDisplayName</li>
</ol>
</nav>
</div>
</div>
<!-- Customer Header -->
<div class="row mb-4">
<div class="col-md-8">
<h1>
<i class="fas fa-user-circle"></i> @Model.TelegramDisplayName
@if (Model.IsBlocked)
{
<span class="badge bg-danger ms-2">
<i class="fas fa-ban"></i> BLOCKED
</span>
}
else if (!Model.IsActive)
{
<span class="badge bg-secondary ms-2">
<i class="fas fa-trash"></i> DELETED
</span>
}
else
{
<span class="badge bg-success ms-2">
<i class="fas fa-check-circle"></i> ACTIVE
</span>
}
</h1>
<p class="text-muted mb-0">
Telegram: @@<strong>@Model.TelegramUsername</strong> | ID: @Model.TelegramUserId
</p>
</div>
<div class="col-md-4 text-end">
<!-- GDPR Data Export Buttons -->
<div class="btn-group me-2" role="group">
<a href="@Url.Action("ExportJson", "Customers", new { id = Model.Id })"
class="btn btn-info"
title="Export all customer data as JSON (GDPR Right to Data Portability)">
<i class="fas fa-file-code"></i> Export JSON
</a>
<a href="@Url.Action("ExportCsv", "Customers", new { id = Model.Id })"
class="btn btn-success"
title="Export all customer data as CSV (GDPR Right to Data Portability)">
<i class="fas fa-file-csv"></i> Export CSV
</a>
</div>
<a href="@Url.Action("Index", "Customers")" class="btn btn-secondary">
<i class="fas fa-arrow-left"></i> Back to List
</a>
</div>
</div>
<!-- Customer Information Cards -->
<div class="row mb-4">
<!-- Basic Information -->
<div class="col-md-6">
<div class="card">
<div class="card-header bg-primary text-white">
<h5 class="mb-0"><i class="fas fa-id-card"></i> Customer Information</h5>
</div>
<div class="card-body">
<table class="table table-sm mb-0">
<tr>
<th style="width: 40%;">Display Name:</th>
<td>@Model.TelegramDisplayName</td>
</tr>
<tr>
<th>Full Name:</th>
<td>
@if (!string.IsNullOrEmpty(Model.TelegramFirstName) || !string.IsNullOrEmpty(Model.TelegramLastName))
{
@Model.TelegramFirstName @Model.TelegramLastName
}
else
{
<span class="text-muted">Not provided</span>
}
</td>
</tr>
<tr>
<th>Telegram Username:</th>
<td>@@<strong>@Model.TelegramUsername</strong></td>
</tr>
<tr>
<th>Telegram User ID:</th>
<td><code>@Model.TelegramUserId</code></td>
</tr>
<tr>
<th>Language:</th>
<td>@Model.Language.ToUpper()</td>
</tr>
<tr>
<th>Timezone:</th>
<td>@Model.Timezone</td>
</tr>
<tr>
<th>Customer Since:</th>
<td>@Model.CreatedAt.ToString("MMMM dd, yyyy")</td>
</tr>
<tr>
<th>Last Active:</th>
<td>
@if (Model.LastActiveAt > DateTime.MinValue)
{
var daysAgo = (DateTime.UtcNow - Model.LastActiveAt).Days;
@Model.LastActiveAt.ToString("MMMM dd, yyyy HH:mm")
@if (daysAgo <= 1)
{
<span class="badge bg-success">Active today</span>
}
else if (daysAgo <= 7)
{
<span class="badge bg-info">@daysAgo days ago</span>
}
else if (daysAgo <= 30)
{
<span class="badge bg-warning">@daysAgo days ago</span>
}
else
{
<span class="badge bg-danger">@daysAgo days ago</span>
}
}
else
{
<span class="text-muted">Never</span>
}
</td>
</tr>
</table>
</div>
</div>
</div>
<!-- Risk Score & Metrics -->
<div class="col-md-6">
<div class="card">
<div class="card-header bg-warning text-dark">
<h5 class="mb-0"><i class="fas fa-shield-alt"></i> Risk Assessment</h5>
</div>
<div class="card-body">
@{
var riskLevel = Model.RiskScore >= 80 ? "Very High Risk" :
Model.RiskScore >= 50 ? "High Risk" :
Model.RiskScore >= 30 ? "Medium Risk" :
"Low Risk";
var riskClass = Model.RiskScore >= 80 ? "danger" :
Model.RiskScore >= 50 ? "warning" :
Model.RiskScore >= 30 ? "info" :
"success";
}
<div class="text-center mb-3">
<h1 class="display-4 text-@riskClass mb-0">
<i class="fas fa-exclamation-triangle"></i> @Model.RiskScore
</h1>
<p class="text-@riskClass fw-bold mb-0">@riskLevel</p>
</div>
<hr>
<table class="table table-sm mb-0">
<tr>
<th style="width: 60%;">Total Orders:</th>
<td class="text-end"><strong>@Model.TotalOrders</strong></td>
</tr>
<tr class="table-success">
<th>Successful Orders:</th>
<td class="text-end text-success"><strong>@Model.SuccessfulOrders</strong></td>
</tr>
<tr class="table-warning">
<th>Cancelled Orders:</th>
<td class="text-end text-warning"><strong>@Model.CancelledOrders</strong></td>
</tr>
<tr class="table-danger">
<th>Disputed Orders:</th>
<td class="text-end text-danger"><strong>@Model.DisputedOrders</strong></td>
</tr>
<tr>
<th>Success Rate:</th>
<td class="text-end">
@if (Model.TotalOrders > 0)
{
var successRate = (Model.SuccessfulOrders * 100.0) / Model.TotalOrders;
@successRate.ToString("F1")<text>%</text>
}
else
{
<span class="text-muted">N/A</span>
}
</td>
</tr>
</table>
<div class="mt-3">
<form method="post" action="@Url.Action("RefreshRiskScore", new { id = Model.Id })" class="d-inline">
@Html.AntiForgeryToken()
<button type="submit" class="btn btn-sm btn-outline-warning w-100">
<i class="fas fa-sync-alt"></i> Recalculate Risk Score
</button>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- Spending Metrics -->
<div class="row mb-4">
<div class="col-md-3">
<div class="card bg-primary text-white">
<div class="card-body text-center">
<h6 class="mb-2">Total Spent</h6>
<h3 class="mb-0">£@Model.TotalSpent.ToString("N2")</h3>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card bg-success text-white">
<div class="card-body text-center">
<h6 class="mb-2">Average Order Value</h6>
<h3 class="mb-0">£@Model.AverageOrderValue.ToString("N2")</h3>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card bg-info text-white">
<div class="card-body text-center">
<h6 class="mb-2">First Order</h6>
<h3 class="mb-0" style="font-size: 1.2rem;">
@if (Model.FirstOrderDate > DateTime.MinValue)
{
@Model.FirstOrderDate.ToString("MMM dd, yyyy")
}
else
{
<span>No orders</span>
}
</h3>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card bg-warning text-dark">
<div class="card-body text-center">
<h6 class="mb-2">Last Order</h6>
<h3 class="mb-0" style="font-size: 1.2rem;">
@if (Model.LastOrderDate > DateTime.MinValue)
{
@Model.LastOrderDate.ToString("MMM dd, yyyy")
}
else
{
<span>No orders</span>
}
</h3>
</div>
</div>
</div>
</div>
<!-- Customer Management Actions -->
<div class="row mb-4">
<div class="col">
<div class="card @(Model.IsBlocked ? "border-danger" : "")">
<div class="card-header @(Model.IsBlocked ? "bg-danger text-white" : "bg-light")">
<h5 class="mb-0"><i class="fas fa-cog"></i> Customer Management Actions</h5>
</div>
<div class="card-body">
@if (Model.IsBlocked)
{
<div class="alert alert-danger">
<h5><i class="fas fa-ban"></i> Customer is Blocked</h5>
<p class="mb-0"><strong>Reason:</strong> @Model.BlockReason</p>
</div>
<form method="post" action="@Url.Action("Unblock", new { id = Model.Id })" class="d-inline">
@Html.AntiForgeryToken()
<button type="submit" class="btn btn-success" onclick="return confirm('Are you sure you want to unblock this customer?')">
<i class="fas fa-check-circle"></i> Unblock Customer
</button>
</form>
}
else
{
<button type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#blockModal">
<i class="fas fa-ban"></i> Block Customer
</button>
}
<button type="button" class="btn btn-warning" data-bs-toggle="modal" data-bs-target="#deleteModal">
<i class="fas fa-trash"></i> Delete Customer
</button>
@if (!string.IsNullOrEmpty(Model.CustomerNotes))
{
<hr>
<h6>Admin Notes:</h6>
<p class="text-muted mb-0">@Model.CustomerNotes</p>
}
</div>
</div>
</div>
</div>
<!-- Order History -->
<div class="row">
<div class="col">
<div class="card">
<div class="card-header bg-light">
<h5 class="mb-0">
<i class="fas fa-shopping-cart"></i> Order History
<span class="badge bg-primary">@customerOrders.Count</span>
</h5>
</div>
<div class="card-body p-0">
@if (customerOrders.Any())
{
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="table-light">
<tr>
<th>Order ID</th>
<th>Date</th>
<th>Status</th>
<th class="text-end">Items</th>
<th class="text-end">Total</th>
<th class="text-center">Actions</th>
</tr>
</thead>
<tbody>
@foreach (var order in customerOrders)
{
<tr>
<td><code>@order.Id.ToString().Substring(0, 8)</code></td>
<td>@order.CreatedAt.ToString("MMM dd, yyyy HH:mm")</td>
<td>
@{
var statusClass = order.Status.ToString() == "Delivered" ? "success" :
order.Status.ToString() == "Cancelled" ? "danger" :
order.Status.ToString() == "PendingPayment" ? "warning" :
"info";
}
<span class="badge bg-@statusClass">@order.Status</span>
</td>
<td class="text-end">@order.Items.Sum(i => i.Quantity)</td>
<td class="text-end"><strong>£@order.TotalAmount.ToString("N2")</strong></td>
<td class="text-center">
<a href="@Url.Action("Details", "Orders", new { id = order.Id })" class="btn btn-sm btn-primary">
<i class="fas fa-eye"></i> View
</a>
</td>
</tr>
}
</tbody>
</table>
</div>
}
else
{
<div class="alert alert-info mb-0">
<i class="fas fa-info-circle"></i> No orders yet for this customer.
</div>
}
</div>
</div>
</div>
</div>
<!-- Block Customer Modal -->
<div class="modal fade" id="blockModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<form method="post" action="@Url.Action("Block", new { id = Model.Id })">
@Html.AntiForgeryToken()
<div class="modal-header bg-danger text-white">
<h5 class="modal-title"><i class="fas fa-ban"></i> Block Customer</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<div class="alert alert-warning">
<i class="fas fa-exclamation-triangle"></i>
<strong>Warning:</strong> Blocking this customer will prevent them from placing new orders.
</div>
<div class="mb-3">
<label for="blockReason" class="form-label">
<strong>Reason for blocking:</strong> <span class="text-danger">*</span>
</label>
<textarea name="reason" id="blockReason" class="form-control" rows="3"
placeholder="Enter the reason for blocking this customer..." required></textarea>
<small class="text-muted">This reason will be visible to administrators.</small>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-danger">
<i class="fas fa-ban"></i> Block Customer
</button>
</div>
</form>
</div>
</div>
</div>
<!-- Delete Customer Modal -->
<div class="modal fade" id="deleteModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<form method="post" action="@Url.Action("Delete", new { id = Model.Id })">
@Html.AntiForgeryToken()
<div class="modal-header bg-warning text-dark">
<h5 class="modal-title"><i class="fas fa-trash"></i> Delete Customer</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<div class="alert alert-info">
<i class="fas fa-info-circle"></i>
<strong>Note:</strong> This is a soft delete. Customer data will be retained but marked as inactive.
</div>
<p>Are you sure you want to delete customer <strong>@Model.TelegramDisplayName</strong>?</p>
<p class="text-muted mb-0">The customer record and order history will be preserved but hidden from normal views.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-warning">
<i class="fas fa-trash"></i> Delete Customer
</button>
</div>
</form>
</div>
</div>
</div>

View File

@@ -0,0 +1,232 @@
@model IEnumerable<LittleShop.DTOs.CustomerDto>
@{
ViewData["Title"] = "Customers";
var searchTerm = ViewData["SearchTerm"] as string ?? "";
}
<div class="row mb-3">
<div class="col">
<h1><i class="fas fa-users"></i> Customer Management</h1>
<p class="text-muted mb-0">Manage customer accounts, view order history, and monitor risk scores</p>
</div>
</div>
<!-- Search Bar -->
<div class="row mb-4">
<div class="col-md-6">
<form method="get" action="@Url.Action("Index")" class="input-group">
<input type="text" name="searchTerm" value="@searchTerm"
class="form-control"
placeholder="Search by name, username, Telegram ID, or email...">
<button class="btn btn-primary" type="submit">
<i class="fas fa-search"></i> Search
</button>
@if (!string.IsNullOrEmpty(searchTerm))
{
<a href="@Url.Action("Index")" class="btn btn-secondary">
<i class="fas fa-times"></i> Clear
</a>
}
</form>
</div>
<div class="col-md-6 text-end">
<span class="text-muted">
<strong>@Model.Count()</strong> customer@(Model.Count() != 1 ? "s" : "") found
</span>
</div>
</div>
<!-- Statistics Cards -->
<div class="row mb-4">
<div class="col-md-3">
<div class="card border-primary">
<div class="card-body">
<h6 class="text-muted mb-2">Total Customers</h6>
<h3 class="mb-0">@Model.Count()</h3>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card border-success">
<div class="card-body">
<h6 class="text-muted mb-2">Active</h6>
<h3 class="mb-0 text-success">@Model.Count(c => c.IsActive && !c.IsBlocked)</h3>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card border-danger">
<div class="card-body">
<h6 class="text-muted mb-2">Blocked</h6>
<h3 class="mb-0 text-danger">@Model.Count(c => c.IsBlocked)</h3>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card border-warning">
<div class="card-body">
<h6 class="text-muted mb-2">High Risk (>70)</h6>
<h3 class="mb-0 text-warning">@Model.Count(c => c.RiskScore > 70)</h3>
</div>
</div>
</div>
</div>
<!-- Customers Table -->
@if (Model.Any())
{
<div class="card">
<div class="card-header bg-light">
<h5 class="mb-0"><i class="fas fa-list"></i> Customer List</h5>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="table-light">
<tr>
<th>Customer</th>
<th>Telegram</th>
<th class="text-center">Status</th>
<th class="text-end">Orders</th>
<th class="text-end">Total Spent</th>
<th class="text-center">Risk Score</th>
<th>Last Active</th>
<th class="text-center">Actions</th>
</tr>
</thead>
<tbody>
@foreach (var customer in Model)
{
<tr class="@(customer.IsBlocked ? "table-danger" : "")">
<td>
<div>
<strong>@customer.TelegramDisplayName</strong>
@if (!string.IsNullOrEmpty(customer.TelegramFirstName) && !string.IsNullOrEmpty(customer.TelegramLastName))
{
<br><small class="text-muted">@customer.TelegramFirstName @customer.TelegramLastName</small>
}
</div>
</td>
<td>
<div>
@@<strong>@customer.TelegramUsername</strong>
<br><small class="text-muted">ID: @customer.TelegramUserId</small>
</div>
</td>
<td class="text-center">
@if (customer.IsBlocked)
{
<span class="badge bg-danger">
<i class="fas fa-ban"></i> Blocked
</span>
}
else if (!customer.IsActive)
{
<span class="badge bg-secondary">
<i class="fas fa-trash"></i> Deleted
</span>
}
else
{
<span class="badge bg-success">
<i class="fas fa-check-circle"></i> Active
</span>
}
</td>
<td class="text-end">
<div>
<strong>@customer.TotalOrders</strong>
@if (customer.SuccessfulOrders > 0)
{
<br><small class="text-success">@customer.SuccessfulOrders successful</small>
}
@if (customer.CancelledOrders > 0)
{
<br><small class="text-muted">@customer.CancelledOrders cancelled</small>
}
@if (customer.DisputedOrders > 0)
{
<br><small class="text-danger">@customer.DisputedOrders disputed</small>
}
</div>
</td>
<td class="text-end">
<strong>£@customer.TotalSpent.ToString("N2")</strong>
@if (customer.AverageOrderValue > 0)
{
<br><small class="text-muted">Avg: £@customer.AverageOrderValue.ToString("N2")</small>
}
</td>
<td class="text-center">
@{
var riskBadgeClass = customer.RiskScore >= 80 ? "bg-danger" :
customer.RiskScore >= 50 ? "bg-warning" :
customer.RiskScore >= 30 ? "bg-info" :
"bg-success";
var riskIcon = customer.RiskScore >= 80 ? "fa-exclamation-triangle" :
customer.RiskScore >= 50 ? "fa-exclamation-circle" :
customer.RiskScore >= 30 ? "fa-info-circle" :
"fa-check-circle";
}
<span class="badge @riskBadgeClass" style="font-size: 1.1em;">
<i class="fas @riskIcon"></i> @customer.RiskScore
</span>
</td>
<td>
@if (customer.LastActiveAt > DateTime.MinValue)
{
var daysAgo = (DateTime.UtcNow - customer.LastActiveAt).Days;
<span>@customer.LastActiveAt.ToString("MMM dd, yyyy")</span>
@if (daysAgo <= 1)
{
<br><small class="text-success">Today</small>
}
else if (daysAgo <= 7)
{
<br><small class="text-muted">@daysAgo days ago</small>
}
else if (daysAgo <= 30)
{
<br><small class="text-warning">@daysAgo days ago</small>
}
else
{
<br><small class="text-danger">@daysAgo days ago</small>
}
}
else
{
<span class="text-muted">Never</span>
}
</td>
<td class="text-center">
<a href="@Url.Action("Details", new { id = customer.Id })"
class="btn btn-sm btn-primary"
title="View Details">
<i class="fas fa-eye"></i>
</a>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
}
else
{
<div class="alert alert-info">
<i class="fas fa-info-circle"></i>
@if (!string.IsNullOrEmpty(searchTerm))
{
<strong>No customers found matching "@searchTerm"</strong>
<p class="mb-0">Try a different search term or <a href="@Url.Action("Index")" class="alert-link">view all customers</a>.</p>
}
else
{
<strong>No customers yet</strong>
<p class="mb-0">Customers will appear here automatically when they place their first order through the TeleBot.</p>
}
</div>
}

View File

@@ -2,12 +2,107 @@
ViewData["Title"] = "Dashboard";
}
<div class="row mb-4">
<div class="row mb-3">
<div class="col">
<h1><i class="fas fa-tachometer-alt"></i> Dashboard</h1>
<p class="text-muted mb-0">Welcome back! Here's what needs your attention today.</p>
</div>
</div>
<!-- PWA Install Prompt (Inline Content) -->
<div id="pwa-install-alert" class="alert alert-info alert-dismissible fade show d-flex align-items-center" role="alert" style="display: none !important;">
<i class="fas fa-mobile-alt me-3 fs-4"></i>
<div class="flex-grow-1">
<strong>Install TeleShop Admin as an App</strong>
<p class="mb-0 small">Get a better experience with offline access and a native app feel.</p>
</div>
<button id="pwa-install-btn" class="btn btn-primary btn-sm me-2">
<i class="fas fa-download"></i> Install
</button>
<button id="pwa-dismiss-btn" type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
@{
var pendingOrders = (int)ViewData["PendingOrders"]!;
var lowStockProducts = (int)ViewData["LowStockProducts"]!;
var outOfStockProducts = (int)ViewData["OutOfStockProducts"]!;
var totalUrgentActions = pendingOrders + (lowStockProducts > 5 ? 1 : 0) + (outOfStockProducts > 0 ? 1 : 0);
}
<!-- URGENT ACTIONS PANEL -->
@if (totalUrgentActions > 0)
{
<div class="row mb-4">
<div class="col">
<div class="card border-warning shadow-sm">
<div class="card-header bg-warning text-dark">
<h5 class="mb-0">
<i class="fas fa-exclamation-triangle"></i>
<strong>Urgent Actions Required</strong>
<span class="badge bg-danger ms-2">@totalUrgentActions</span>
</h5>
</div>
<div class="card-body">
<div class="list-group list-group-flush">
@if (pendingOrders > 0)
{
<a href="@Url.Action("Index", "Orders", new { area = "Admin", status = "PendingPayment" })"
class="list-group-item list-group-item-action list-group-item-warning d-flex justify-content-between align-items-center">
<div>
<i class="fas fa-shopping-cart text-warning me-2"></i>
<strong>@pendingOrders order@(pendingOrders != 1 ? "s" : "") awaiting payment</strong>
<small class="d-block text-muted">Customers may need payment reminders</small>
</div>
<i class="fas fa-chevron-right"></i>
</a>
}
@if (outOfStockProducts > 0)
{
<a href="@Url.Action("Index", "Products", new { area = "Admin" })"
class="list-group-item list-group-item-action list-group-item-danger d-flex justify-content-between align-items-center">
<div>
<i class="fas fa-box-open text-danger me-2"></i>
<strong>@outOfStockProducts product@(outOfStockProducts != 1 ? "s" : "") out of stock</strong>
<small class="d-block text-muted">Update inventory or mark as unavailable</small>
</div>
<i class="fas fa-chevron-right"></i>
</a>
}
@if (lowStockProducts > 5)
{
<a href="@Url.Action("Index", "Products", new { area = "Admin" })"
class="list-group-item list-group-item-action list-group-item-warning d-flex justify-content-between align-items-center">
<div>
<i class="fas fa-exclamation-circle text-warning me-2"></i>
<strong>@lowStockProducts products running low on stock</strong>
<small class="d-block text-muted">Stock levels below 10 units</small>
</div>
<i class="fas fa-chevron-right"></i>
</a>
}
</div>
</div>
</div>
</div>
</div>
}
else
{
<div class="row mb-4">
<div class="col">
<div class="alert alert-success d-flex align-items-center" role="alert">
<i class="fas fa-check-circle fs-4 me-3"></i>
<div>
<strong>All systems running smoothly!</strong>
<p class="mb-0 small">No urgent actions required at this time.</p>
</div>
</div>
</div>
</div>
}
<div class="row">
<div class="col-md-3">
<div class="card text-white bg-primary mb-3">
@@ -104,9 +199,6 @@
<div class="card">
<div class="card-header">
<h5><i class="fas fa-chart-line"></i> Quick Actions</h5>
<button id="pwa-install-dashboard" class="btn btn-sm btn-outline-primary" style="float: right;">
<i class="fas fa-mobile-alt"></i> Install App
</button>
</div>
<div class="card-body">
<div class="list-group list-group-flush">
@@ -147,15 +239,29 @@
<script>
document.addEventListener('DOMContentLoaded', function() {
const installBtn = document.getElementById('pwa-install-dashboard');
const installAlert = document.getElementById('pwa-install-alert');
const installBtn = document.getElementById('pwa-install-btn');
const dismissBtn = document.getElementById('pwa-dismiss-btn');
// Check if user has dismissed the alert
const alertDismissed = localStorage.getItem('pwa-install-dismissed');
// Check if app is in standalone mode (already installed)
const isStandalone = window.matchMedia('(display-mode: standalone)').matches;
// Show alert if not dismissed and not already installed
if (installAlert && !alertDismissed && !isStandalone) {
installAlert.style.display = 'flex';
}
if (installBtn) {
installBtn.addEventListener('click', function() {
// Check if app is in standalone mode
if (window.matchMedia('(display-mode: standalone)').matches) {
if (isStandalone) {
alert('App is already installed!');
return;
}
// Show manual install instructions
alert(`To install TeleShop Admin as an app:
@@ -172,5 +278,11 @@ document.addEventListener('DOMContentLoaded', function() {
The app will then work offline and appear in your apps list!`);
});
}
if (dismissBtn) {
dismissBtn.addEventListener('click', function() {
localStorage.setItem('pwa-install-dismissed', 'true');
});
}
});
</script>

View File

@@ -0,0 +1,260 @@
@model IEnumerable<LittleShop.DTOs.CryptoPaymentDto>
@{
ViewData["Title"] = "Payment Transactions";
var orders = ViewData["Orders"] as Dictionary<Guid, LittleShop.DTOs.OrderDto> ?? new Dictionary<Guid, LittleShop.DTOs.OrderDto>();
var currentStatus = ViewData["CurrentStatus"] as string ?? "";
}
<div class="row mb-3">
<div class="col">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="@Url.Action("Index", "Dashboard")">Dashboard</a></li>
<li class="breadcrumb-item active">Payment Transactions</li>
</ol>
</nav>
</div>
</div>
<div class="row mb-3">
<div class="col">
<h1><i class="fas fa-wallet"></i> Payment Transactions</h1>
<p class="text-muted mb-0">View all cryptocurrency payment transactions and their statuses</p>
</div>
</div>
<!-- Status Filter Tabs -->
<div class="row mb-4">
<div class="col">
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link @(string.IsNullOrEmpty(currentStatus) ? "active" : "")"
href="@Url.Action("Index")">
All Payments
<span class="badge bg-secondary ms-1">@Model.Count()</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link @(currentStatus == "Pending" ? "active" : "")"
href="@Url.Action("Index", new { status = "Pending" })">
<i class="fas fa-clock"></i> Pending
<span class="badge bg-warning ms-1">@Model.Count(p => p.Status == LittleShop.Enums.PaymentStatus.Pending)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link @(currentStatus == "Paid" ? "active" : "")"
href="@Url.Action("Index", new { status = "Paid" })">
<i class="fas fa-check-circle"></i> Paid
<span class="badge bg-success ms-1">@Model.Count(p => p.Status == LittleShop.Enums.PaymentStatus.Paid)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link @(currentStatus == "Expired" ? "active" : "")"
href="@Url.Action("Index", new { status = "Expired" })">
<i class="fas fa-times-circle"></i> Expired
<span class="badge bg-danger ms-1">@Model.Count(p => p.Status == LittleShop.Enums.PaymentStatus.Expired)</span>
</a>
</li>
</ul>
</div>
</div>
<!-- Statistics Cards -->
<div class="row mb-4">
<div class="col-md-3">
<div class="card border-primary">
<div class="card-body">
<h6 class="text-muted mb-2">Total Transactions</h6>
<h3 class="mb-0">@Model.Count()</h3>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card border-success">
<div class="card-body">
<h6 class="text-muted mb-2">Successful Payments</h6>
<h3 class="mb-0 text-success">@Model.Count(p => p.Status == LittleShop.Enums.PaymentStatus.Paid || p.Status == LittleShop.Enums.PaymentStatus.Completed)</h3>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card border-warning">
<div class="card-body">
<h6 class="text-muted mb-2">Pending</h6>
<h3 class="mb-0 text-warning">@Model.Count(p => p.Status == LittleShop.Enums.PaymentStatus.Pending)</h3>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card border-info">
<div class="card-body">
<h6 class="text-muted mb-2">Total Value</h6>
<h3 class="mb-0">£@Model.Where(p => p.Status == LittleShop.Enums.PaymentStatus.Paid || p.Status == LittleShop.Enums.PaymentStatus.Completed).Sum(p => p.PaidAmount).ToString("N2")</h3>
</div>
</div>
</div>
</div>
<!-- Payments Table -->
@if (Model.Any())
{
<div class="card">
<div class="card-header bg-light">
<h5 class="mb-0"><i class="fas fa-list"></i> Transaction List</h5>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="table-light">
<tr>
<th>Payment ID</th>
<th>Order</th>
<th>Currency</th>
<th class="text-end">Required</th>
<th class="text-end">Paid</th>
<th class="text-center">Status</th>
<th>Created</th>
<th>Expires/Paid</th>
<th class="text-center">Actions</th>
</tr>
</thead>
<tbody>
@foreach (var payment in Model)
{
var statusClass = payment.Status.ToString() == "Paid" || payment.Status.ToString() == "Completed" ? "success" :
payment.Status.ToString() == "Expired" || payment.Status.ToString() == "Cancelled" ? "danger" :
payment.Status.ToString() == "Pending" ? "warning" :
"info";
var isExpired = DateTime.UtcNow > payment.ExpiresAt && payment.Status == LittleShop.Enums.PaymentStatus.Pending;
<tr class="@(isExpired ? "table-warning" : "")">
<td>
<code>@payment.Id.ToString().Substring(0, 8)</code>
@if (!string.IsNullOrEmpty(payment.SilverPayOrderId))
{
<br><small class="text-muted">SilverPay: @payment.SilverPayOrderId</small>
}
</td>
<td>
@if (orders.ContainsKey(payment.OrderId))
{
var order = orders[payment.OrderId];
<a href="@Url.Action("Details", "Orders", new { id = payment.OrderId })">
Order #@payment.OrderId.ToString().Substring(0, 8)
</a>
<br><small class="text-muted">£@order.TotalAmount.ToString("N2")</small>
}
else
{
<span class="text-muted">Order #@payment.OrderId.ToString().Substring(0, 8)</span>
}
</td>
<td>
<span class="badge bg-dark">
@payment.Currency
</span>
</td>
<td class="text-end">
<strong>@payment.RequiredAmount.ToString("0.########")</strong>
<br><small class="text-muted">@payment.Currency</small>
</td>
<td class="text-end">
@if (payment.PaidAmount > 0)
{
<strong class="text-success">@payment.PaidAmount.ToString("0.########")</strong>
<br><small class="text-muted">@payment.Currency</small>
}
else
{
<span class="text-muted">-</span>
}
</td>
<td class="text-center">
<span class="badge bg-@statusClass">
@if (payment.Status.ToString() == "Paid")
{
<i class="fas fa-check-circle"></i>
}
else if (payment.Status.ToString() == "Pending")
{
<i class="fas fa-clock"></i>
}
else if (payment.Status.ToString() == "Expired")
{
<i class="fas fa-times-circle"></i>
}
@payment.Status
</span>
@if (isExpired)
{
<br><small class="text-danger"><i class="fas fa-exclamation-triangle"></i> Expired</small>
}
</td>
<td>
@payment.CreatedAt.ToString("MMM dd, yyyy")
<br><small class="text-muted">@payment.CreatedAt.ToString("HH:mm")</small>
</td>
<td>
@if (payment.PaidAt.HasValue)
{
<span class="text-success">
<i class="fas fa-check"></i> @payment.PaidAt.Value.ToString("MMM dd, HH:mm")
</span>
}
else
{
<span class="@(isExpired ? "text-danger" : "text-muted")">
<i class="fas fa-clock"></i> @payment.ExpiresAt.ToString("MMM dd, HH:mm")
</span>
}
</td>
<td class="text-center">
@if (!string.IsNullOrEmpty(payment.TransactionHash))
{
<button type="button" class="btn btn-sm btn-outline-primary"
data-bs-toggle="tooltip"
title="@payment.TransactionHash">
<i class="fas fa-link"></i> TX
</button>
}
<a href="@Url.Action("Details", "Orders", new { id = payment.OrderId })"
class="btn btn-sm btn-primary"
title="View Order">
<i class="fas fa-eye"></i>
</a>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
}
else
{
<div class="alert alert-info">
<i class="fas fa-info-circle"></i>
@if (!string.IsNullOrEmpty(currentStatus))
{
<strong>No @currentStatus.ToLower() payments found</strong>
<p class="mb-0">Try <a href="@Url.Action("Index")" class="alert-link">viewing all payments</a>.</p>
}
else
{
<strong>No payment transactions yet</strong>
<p class="mb-0">Payment transactions will appear here when customers make cryptocurrency payments.</p>
}
</div>
}
@section Scripts {
<script>
// Initialize Bootstrap tooltips
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl)
});
</script>
}

View File

@@ -9,6 +9,7 @@
<div class="row mb-4">
<div class="col">
<h1><i class="fas fa-plus"></i> Create Product</h1>
<p class="text-muted">Fill in the essential details below. Additional options can be configured after creation.</p>
</div>
</div>
@@ -18,7 +19,7 @@
<div class="card-body">
<form method="post" asp-area="Admin" asp-controller="Products" asp-action="Create">
@Html.AntiForgeryToken()
@if (!ViewData.ModelState.IsValid)
{
<div class="alert alert-danger" role="alert">
@@ -31,183 +32,303 @@
</ul>
</div>
}
<div class="mb-3">
<label for="Name" class="form-label">Product Name</label>
<input name="Name" id="Name" value="@Model?.Name" class="form-control @(ViewData.ModelState["Name"]?.Errors.Count > 0 ? "is-invalid" : "")" required />
@if(ViewData.ModelState["Name"]?.Errors.Count > 0)
{
<div class="invalid-feedback">
@ViewData.ModelState["Name"]?.Errors.FirstOrDefault()?.ErrorMessage
</div>
}
</div>
<div class="mb-3">
<label for="Description" class="form-label">Description <small class="text-muted">(optional)</small></label>
<textarea name="Description" id="Description" class="form-control @(ViewData.ModelState["Description"]?.Errors.Count > 0 ? "is-invalid" : "")" rows="3" placeholder="Describe your product...">@Model?.Description</textarea>
@if(ViewData.ModelState["Description"]?.Errors.Count > 0)
{
<div class="invalid-feedback">
@ViewData.ModelState["Description"]?.Errors.FirstOrDefault()?.ErrorMessage
</div>
}
</div>
<div class="row">
<div class="col-md-4">
<div class="mb-3">
<label for="Price" class="form-label">Price (£)</label>
<input name="Price" id="Price" value="@Model?.Price" type="number" step="0.01" class="form-control @(ViewData.ModelState["Price"]?.Errors.Count > 0 ? "is-invalid" : "")" required />
@if(ViewData.ModelState["Price"]?.Errors.Count > 0)
{
<div class="invalid-feedback">
@ViewData.ModelState["Price"]?.Errors.FirstOrDefault()?.ErrorMessage
</div>
}
</div>
</div>
<div class="col-md-4">
<div class="mb-3">
<label for="StockQuantity" class="form-label">Stock Quantity</label>
<input name="StockQuantity" id="StockQuantity" value="@(Model?.StockQuantity ?? 0)" type="number" min="0" class="form-control @(ViewData.ModelState["StockQuantity"]?.Errors.Count > 0 ? "is-invalid" : "")" required />
@if(ViewData.ModelState["StockQuantity"]?.Errors.Count > 0)
{
<div class="invalid-feedback">
@ViewData.ModelState["StockQuantity"]?.Errors.FirstOrDefault()?.ErrorMessage
</div>
}
</div>
</div>
<div class="col-md-4">
<div class="mb-3">
<label for="CategoryId" class="form-label">Category</label>
<select name="CategoryId" id="CategoryId" class="form-select @(ViewData.ModelState["CategoryId"]?.Errors.Count > 0 ? "is-invalid" : "")" required>
<option value="">Select a category</option>
@if (categories != null)
{
@foreach (var category in categories)
{
<option value="@category.Id" selected="@(Model?.CategoryId == category.Id)">@category.Name</option>
}
}
</select>
@if(ViewData.ModelState["CategoryId"]?.Errors.Count > 0)
{
<div class="invalid-feedback">
@ViewData.ModelState["CategoryId"]?.Errors.FirstOrDefault()?.ErrorMessage
</div>
}
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="mb-3">
<label for="Weight" class="form-label">Weight/Volume</label>
<input name="Weight" id="Weight" value="@Model?.Weight" type="number" step="0.01" class="form-control @(ViewData.ModelState["Weight"]?.Errors.Count > 0 ? "is-invalid" : "")" required />
@if(ViewData.ModelState["Weight"]?.Errors.Count > 0)
{
<div class="invalid-feedback">
@ViewData.ModelState["Weight"]?.Errors.FirstOrDefault()?.ErrorMessage
</div>
}
</div>
</div>
<div class="col-md-6">
<div class="mb-3">
<label for="WeightUnit" class="form-label">Unit</label>
<select name="WeightUnit" id="WeightUnit" class="form-select @(ViewData.ModelState["WeightUnit"]?.Errors.Count > 0 ? "is-invalid" : "")">
<option value="0" selected="@(Model?.WeightUnit == LittleShop.Enums.ProductWeightUnit.Unit)">Unit</option>
<option value="1" selected="@(Model?.WeightUnit == LittleShop.Enums.ProductWeightUnit.Micrograms)">Micrograms</option>
<option value="2" selected="@(Model?.WeightUnit == LittleShop.Enums.ProductWeightUnit.Grams)">Grams</option>
<option value="3" selected="@(Model?.WeightUnit == LittleShop.Enums.ProductWeightUnit.Ounces)">Ounces</option>
<option value="4" selected="@(Model?.WeightUnit == LittleShop.Enums.ProductWeightUnit.Pounds)">Pounds</option>
<option value="5" selected="@(Model?.WeightUnit == LittleShop.Enums.ProductWeightUnit.Millilitres)">Millilitres</option>
<option value="6" selected="@(Model?.WeightUnit == LittleShop.Enums.ProductWeightUnit.Litres)">Litres</option>
</select>
@if(ViewData.ModelState["WeightUnit"]?.Errors.Count > 0)
{
<div class="invalid-feedback">
@ViewData.ModelState["WeightUnit"]?.Errors.FirstOrDefault()?.ErrorMessage
</div>
}
</div>
</div>
</div>
<!-- Variant Collection Section -->
<hr class="my-4">
<h5><i class="fas fa-layer-group"></i> Product Variants <small class="text-muted">(optional)</small></h5>
<p class="text-muted">Add variant properties like Size, Color, or Flavor to this product.</p>
<!-- ESSENTIAL INFORMATION (Always Visible) -->
<div class="mb-4">
<h5 class="text-primary mb-3">
<i class="fas fa-star text-warning"></i> Essential Information
</h5>
<div class="mb-3">
<label for="VariantCollectionId" class="form-label">Variant Collection</label>
<select name="VariantCollectionId" id="VariantCollectionId" class="form-select">
<option value="">No variant collection</option>
@if (variantCollections != null)
<div class="mb-3">
<label for="Name" class="form-label fw-bold">
Product Name <span class="text-danger">*</span>
<i class="fas fa-info-circle text-muted ms-1" data-bs-toggle="tooltip" title="Enter a clear, descriptive name that customers will see"></i>
</label>
<input name="Name" id="Name" value="@Model?.Name"
class="form-control form-control-lg @(ViewData.ModelState["Name"]?.Errors.Count > 0 ? "is-invalid" : "")"
placeholder="e.g., Wireless Noise-Cancelling Headphones"
required autofocus />
@if(ViewData.ModelState["Name"]?.Errors.Count > 0)
{
@foreach (var collection in variantCollections)
{
<option value="@collection.Id" selected="@(Model?.VariantCollectionId == collection.Id)">@collection.Name</option>
}
<div class="invalid-feedback">
@ViewData.ModelState["Name"]?.Errors.FirstOrDefault()?.ErrorMessage
</div>
}
</select>
<small class="form-text text-muted">Select a reusable variant template, or leave blank for custom variants</small>
<small class="form-text text-success d-none" id="name-success">
<i class="fas fa-check-circle"></i> Great! This name is unique.
</small>
</div>
<div class="row">
<div class="col-md-4">
<div class="mb-3">
<label for="Price" class="form-label fw-bold">
Price (£) <span class="text-danger">*</span>
</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-pound-sign"></i></span>
<input name="Price" id="Price" value="@Model?.Price" type="number" step="0.01" min="0.01"
class="form-control @(ViewData.ModelState["Price"]?.Errors.Count > 0 ? "is-invalid" : "")"
placeholder="10.00"
required />
@if(ViewData.ModelState["Price"]?.Errors.Count > 0)
{
<div class="invalid-feedback">
@ViewData.ModelState["Price"]?.Errors.FirstOrDefault()?.ErrorMessage
</div>
}
</div>
<small class="form-text text-muted">Base price before multi-buy discounts</small>
</div>
</div>
<div class="col-md-4">
<div class="mb-3">
<label for="StockQuantity" class="form-label fw-bold">
Stock Quantity <span class="text-danger">*</span>
</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-boxes"></i></span>
<input name="StockQuantity" id="StockQuantity" value="@(Model?.StockQuantity ?? 0)" type="number" min="0"
class="form-control @(ViewData.ModelState["StockQuantity"]?.Errors.Count > 0 ? "is-invalid" : "")"
placeholder="100"
required />
@if(ViewData.ModelState["StockQuantity"]?.Errors.Count > 0)
{
<div class="invalid-feedback">
@ViewData.ModelState["StockQuantity"]?.Errors.FirstOrDefault()?.ErrorMessage
</div>
}
</div>
<small class="form-text text-muted">Current inventory available</small>
</div>
</div>
<div class="col-md-4">
<div class="mb-3">
<label for="CategoryId" class="form-label fw-bold">
Category <span class="text-danger">*</span>
</label>
<select name="CategoryId" id="CategoryId" class="form-select @(ViewData.ModelState["CategoryId"]?.Errors.Count > 0 ? "is-invalid" : "")" required>
<option value="">Choose category...</option>
@if (categories != null)
{
@foreach (var category in categories)
{
<option value="@category.Id" selected="@(Model?.CategoryId == category.Id)">@category.Name</option>
}
}
</select>
@if(ViewData.ModelState["CategoryId"]?.Errors.Count > 0)
{
<div class="invalid-feedback">
@ViewData.ModelState["CategoryId"]?.Errors.FirstOrDefault()?.ErrorMessage
</div>
}
<small class="form-text text-muted">Helps customers find this product</small>
</div>
</div>
</div>
</div>
<!-- Dynamic Variant Fields (populated by JavaScript) -->
<div id="dynamic-variant-fields" class="mb-3">
<!-- JavaScript will populate this -->
</div>
<!-- Hidden VariantsJson field for form submission -->
<input type="hidden" name="VariantsJson" id="VariantsJson" value="@Model?.VariantsJson" />
<!-- Advanced JSON Editor (hidden by default) -->
<div class="mb-3">
<button type="button" id="toggle-advanced-variants" class="btn btn-sm btn-outline-secondary">
<i class="fas fa-code"></i> Show Advanced JSON Editor
<!-- PRODUCT DETAILS (Collapsible) -->
<div class="mb-4">
<button class="btn btn-outline-secondary w-100 text-start" type="button" data-bs-toggle="collapse" data-bs-target="#productDetailsSection" aria-expanded="false">
<i class="fas fa-chevron-down me-2"></i>
<strong>Product Details</strong>
<small class="text-muted ms-2">(Optional - Click to expand)</small>
</button>
<div class="collapse mt-3" id="productDetailsSection">
<div class="border rounded p-3 bg-light">
<div class="mb-3">
<label for="Description" class="form-label">
Description
<i class="fas fa-info-circle text-muted ms-1" data-bs-toggle="tooltip" title="Provide details about features, benefits, or specifications"></i>
</label>
<textarea name="Description" id="Description" class="form-control @(ViewData.ModelState["Description"]?.Errors.Count > 0 ? "is-invalid" : "")"
rows="4"
placeholder="e.g., Premium wireless headphones with active noise cancellation, 30-hour battery life, and comfortable over-ear design...">@Model?.Description</textarea>
@if(ViewData.ModelState["Description"]?.Errors.Count > 0)
{
<div class="invalid-feedback">
@ViewData.ModelState["Description"]?.Errors.FirstOrDefault()?.ErrorMessage
</div>
}
<small class="form-text text-muted">Supports emojis and Unicode characters</small>
</div>
<div class="row">
<div class="col-md-6">
<div class="mb-3">
<label for="Weight" class="form-label">
Weight/Volume
<i class="fas fa-info-circle text-muted ms-1" data-bs-toggle="tooltip" title="Used for shipping cost calculations"></i>
</label>
<input name="Weight" id="Weight" value="@Model?.Weight" type="number" step="0.01" min="0"
class="form-control @(ViewData.ModelState["Weight"]?.Errors.Count > 0 ? "is-invalid" : "")"
placeholder="e.g., 350"
required />
@if(ViewData.ModelState["Weight"]?.Errors.Count > 0)
{
<div class="invalid-feedback">
@ViewData.ModelState["Weight"]?.Errors.FirstOrDefault()?.ErrorMessage
</div>
}
</div>
</div>
<div class="col-md-6">
<div class="mb-3">
<label for="WeightUnit" class="form-label">Measurement Unit</label>
<select name="WeightUnit" id="WeightUnit" class="form-select @(ViewData.ModelState["WeightUnit"]?.Errors.Count > 0 ? "is-invalid" : "")">
<option value="0" selected="@(Model?.WeightUnit == LittleShop.Enums.ProductWeightUnit.Unit)">Unit (default)</option>
<option value="1" selected="@(Model?.WeightUnit == LittleShop.Enums.ProductWeightUnit.Micrograms)">Micrograms (μg)</option>
<option value="2" selected="@(Model?.WeightUnit == LittleShop.Enums.ProductWeightUnit.Grams)">Grams (g)</option>
<option value="3" selected="@(Model?.WeightUnit == LittleShop.Enums.ProductWeightUnit.Ounces)">Ounces (oz)</option>
<option value="4" selected="@(Model?.WeightUnit == LittleShop.Enums.ProductWeightUnit.Pounds)">Pounds (lb)</option>
<option value="5" selected="@(Model?.WeightUnit == LittleShop.Enums.ProductWeightUnit.Millilitres)">Millilitres (ml)</option>
<option value="6" selected="@(Model?.WeightUnit == LittleShop.Enums.ProductWeightUnit.Litres)">Litres (L)</option>
</select>
@if(ViewData.ModelState["WeightUnit"]?.Errors.Count > 0)
{
<div class="invalid-feedback">
@ViewData.ModelState["WeightUnit"]?.Errors.FirstOrDefault()?.ErrorMessage
</div>
}
</div>
</div>
</div>
</div>
</div>
</div>
<div id="advanced-variant-section" class="mb-3" style="display: none;">
<label class="form-label">Advanced: Custom Variants JSON</label>
<textarea class="form-control font-monospace" rows="4" placeholder='[{"Size":"M","Color":"Red"}]'
onchange="document.getElementById('VariantsJson').value = this.value">@Model?.VariantsJson</textarea>
<small class="form-text text-muted">For advanced users: Directly edit the JSON structure</small>
<!-- VARIANTS SECTION (Collapsible - Advanced) -->
<div class="mb-4">
<button class="btn btn-outline-info w-100 text-start" type="button" data-bs-toggle="collapse" data-bs-target="#variantsSection" aria-expanded="false">
<i class="fas fa-chevron-down me-2"></i>
<strong><i class="fas fa-layer-group"></i> Product Variants</strong>
<small class="text-muted ms-2">(Optional - For products with size/color options)</small>
</button>
<div class="collapse mt-3" id="variantsSection">
<div class="border rounded p-3 bg-light">
<p class="text-muted mb-3">
<i class="fas fa-lightbulb text-warning"></i>
Add variant properties like Size, Color, or Flavor to this product. Variants allow customers to choose specific options.
</p>
<div class="mb-3">
<label for="VariantCollectionId" class="form-label">Variant Collection</label>
<select name="VariantCollectionId" id="VariantCollectionId" class="form-select">
<option value="">No variant collection</option>
@if (variantCollections != null)
{
@foreach (var collection in variantCollections)
{
<option value="@collection.Id" selected="@(Model?.VariantCollectionId == collection.Id)">@collection.Name</option>
}
}
</select>
<small class="form-text text-muted">Select a reusable variant template, or leave blank for custom variants</small>
</div>
<!-- Dynamic Variant Fields (populated by JavaScript) -->
<div id="dynamic-variant-fields" class="mb-3">
<!-- JavaScript will populate this -->
</div>
<!-- Hidden VariantsJson field for form submission -->
<input type="hidden" name="VariantsJson" id="VariantsJson" value="@Model?.VariantsJson" />
<!-- Advanced JSON Editor (hidden by default) -->
<div class="mb-3">
<button type="button" id="toggle-advanced-variants" class="btn btn-sm btn-outline-secondary">
<i class="fas fa-code"></i> Show Advanced JSON Editor
</button>
</div>
<div id="advanced-variant-section" class="mb-3" style="display: none;">
<label class="form-label">Advanced: Custom Variants JSON</label>
<textarea class="form-control font-monospace" rows="4" placeholder='[{"Size":"M","Color":"Red"}]'
onchange="document.getElementById('VariantsJson').value = this.value">@Model?.VariantsJson</textarea>
<small class="form-text text-muted">For advanced users: Directly edit the JSON structure</small>
</div>
</div>
</div>
</div>
<div class="d-flex justify-content-between">
<a href="@Url.Action("Index")" class="btn btn-secondary">
<i class="fas fa-arrow-left"></i> Back to Products
<!-- FORM ACTIONS -->
<div class="d-flex justify-content-between align-items-center mt-4 pt-3 border-top">
<a href="@Url.Action("Index")" class="btn btn-lg btn-outline-secondary">
<i class="fas fa-arrow-left"></i> Cancel
</a>
<button type="submit" class="btn btn-primary">
<i class="fas fa-save"></i> Create Product
<button type="submit" class="btn btn-lg btn-primary px-5">
<i class="fas fa-check-circle"></i> Create Product
</button>
</div>
<div class="mt-3 text-center text-muted small">
<i class="fas fa-info-circle"></i>
You can add photos and configure multi-buy discounts after creating the product.
</div>
</form>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card">
<div class="card-header">
<h5><i class="fas fa-info-circle"></i> Product Information</h5>
<!-- QUICK START GUIDE -->
<div class="card border-primary mb-3">
<div class="card-header bg-primary text-white">
<h5 class="mb-0"><i class="fas fa-rocket"></i> Quick Start Guide</h5>
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong>Name:</strong> Unique product identifier</li>
<li><strong>Description:</strong> Optional, supports Unicode and emojis</li>
<li><strong>Price:</strong> Base price in GBP</li>
<li><strong>Stock:</strong> Current inventory quantity</li>
<li><strong>Weight/Volume:</strong> Used for shipping calculations</li>
<li><strong>Category:</strong> Product organization</li>
<li><strong>Photos:</strong> Can be added after creating the product</li>
<h6 class="text-primary"><i class="fas fa-star text-warning"></i> Essential Fields (Required)</h6>
<ol class="mb-3">
<li><strong>Product Name</strong> - Clear, descriptive title</li>
<li><strong>Price</strong> - Base price in £ (GBP)</li>
<li><strong>Stock Quantity</strong> - Available inventory</li>
<li><strong>Category</strong> - Helps customers find it</li>
</ol>
<h6 class="text-secondary"><i class="fas fa-cog"></i> Optional Sections</h6>
<ul class="list-unstyled mb-0">
<li class="mb-2">
<i class="fas fa-chevron-right text-muted"></i>
<strong>Product Details</strong><br>
<small class="text-muted">Description, weight/dimensions for shipping</small>
</li>
<li>
<i class="fas fa-chevron-right text-muted"></i>
<strong>Variants</strong><br>
<small class="text-muted">Size, color, or other options</small>
</li>
</ul>
</div>
</div>
<!-- HELPFUL TIPS -->
<div class="card border-info">
<div class="card-header bg-info text-white">
<h5 class="mb-0"><i class="fas fa-lightbulb"></i> Helpful Tips</h5>
</div>
<div class="card-body">
<ul class="list-unstyled mb-0">
<li class="mb-2">
<i class="fas fa-check-circle text-success"></i>
<strong>Photos:</strong> Add after creating the product
</li>
<li class="mb-2">
<i class="fas fa-check-circle text-success"></i>
<strong>Multi-buy:</strong> Configure bulk discounts later
</li>
<li class="mb-2">
<i class="fas fa-check-circle text-success"></i>
<strong>Smart Form:</strong> Remembers your last category
</li>
<li>
<i class="fas fa-check-circle text-success"></i>
<strong>Validation:</strong> Real-time feedback as you type
</li>
</ul>
<small class="text-muted">The form remembers your last used category and weight unit. Add photos after creation.</small>
</div>
</div>
</div>
@@ -217,83 +338,75 @@
<script src="~/js/product-variants.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Initialize Bootstrap tooltips
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]');
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl));
// Animate collapse button icons
const collapseButtons = document.querySelectorAll('[data-bs-toggle="collapse"]');
collapseButtons.forEach(button => {
const icon = button.querySelector('.fa-chevron-down');
const target = button.getAttribute('data-bs-target');
if (icon && target) {
document.querySelector(target)?.addEventListener('show.bs.collapse', () => {
icon.style.transform = 'rotate(180deg)';
icon.style.transition = 'transform 0.3s ease';
});
document.querySelector(target)?.addEventListener('hide.bs.collapse', () => {
icon.style.transform = 'rotate(0deg)';
});
}
});
const categorySelect = document.getElementById('CategoryId');
const weightUnitSelect = document.getElementById('WeightUnit');
const photoInput = document.getElementById('ProductPhotos');
const photoPreview = document.getElementById('photo-preview');
const nameInput = document.getElementById('Name');
// Restore last used category and weight unit
const lastCategory = localStorage.getItem('lastProductCategory');
const lastWeightUnit = localStorage.getItem('lastProductWeightUnit');
if (lastCategory && categorySelect) {
categorySelect.value = lastCategory;
console.log('Restored last category:', lastCategory);
}
if (lastWeightUnit && weightUnitSelect) {
weightUnitSelect.value = lastWeightUnit;
console.log('Restored last weight unit:', lastWeightUnit);
}
// Save category and weight unit when changed
if (categorySelect) {
categorySelect.addEventListener('change', function() {
if (this.value) {
localStorage.setItem('lastProductCategory', this.value);
console.log('Saved category preference:', this.value);
}
});
}
if (weightUnitSelect) {
weightUnitSelect.addEventListener('change', function() {
localStorage.setItem('lastProductWeightUnit', this.value);
console.log('Saved weight unit preference:', this.value);
});
}
// Photo preview functionality
if (photoInput) {
photoInput.addEventListener('change', function(e) {
const files = Array.from(e.target.files);
photoPreview.innerHTML = '';
if (files.length > 0) {
photoPreview.style.display = 'block';
files.forEach((file, index) => {
if (file.type.startsWith('image/')) {
const col = document.createElement('div');
col.className = 'col-md-3 col-6 mb-3';
const reader = new FileReader();
reader.onload = function(event) {
col.innerHTML = `
<div class="card">
<img src="${event.target.result}" class="card-img-top" style="height: 120px; object-fit: cover;" alt="Preview ${index + 1}">
<div class="card-body p-2">
<small class="text-muted">${file.name}</small><br>
<small class="text-success">${(file.size / 1024).toFixed(1)} KB</small>
</div>
</div>
`;
};
reader.readAsDataURL(file);
photoPreview.appendChild(col);
}
});
} else {
photoPreview.style.display = 'none';
}
});
}
// Focus on name field for better UX
const nameInput = document.getElementById('Name');
if (nameInput) {
setTimeout(() => nameInput.focus(), 100);
}
// Simple inline validation feedback for product name
if (nameInput) {
nameInput.addEventListener('input', function() {
const successMsg = document.getElementById('name-success');
if (this.value.trim().length >= 3) {
successMsg?.classList.remove('d-none');
} else {
successMsg?.classList.add('d-none');
}
});
}
});
</script>
}

View File

@@ -493,7 +493,7 @@
<i class="fas fa-star me-2"></i>Product Reviews
<small class="text-muted ms-2">
@{
var productReviews = ViewData["ProductReviews"] as IEnumerable<dynamic>;
var productReviews = ViewData["ProductReviews"] as IEnumerable<LittleShop.DTOs.ReviewDto>;
if (productReviews != null && productReviews.Any())
{
<span>@productReviews.Count() review(s)</span>
@@ -523,7 +523,7 @@
<div class="me-2">
@for (int i = 1; i <= 5; i++)
{
if (i <= (review.Rating ?? 0))
if (i <= review.Rating)
{
<i class="fas fa-star text-warning"></i>
}
@@ -533,20 +533,20 @@
}
}
</div>
<strong>@(review.CustomerName ?? "Anonymous Customer")</strong>
<strong>@(string.IsNullOrEmpty(review.CustomerDisplayName) ? "Anonymous Customer" : review.CustomerDisplayName)</strong>
</div>
<small class="text-muted">@(review.CreatedAt?.ToString("MMM dd, yyyy") ?? "Date unknown")</small>
<small class="text-muted">@review.CreatedAt.ToString("MMM dd, yyyy")</small>
</div>
<span class="badge bg-primary">@(review.Rating ?? 0)/5</span>
<span class="badge bg-primary">@review.Rating/5</span>
</div>
@if (!string.IsNullOrEmpty(review.Comment?.ToString()))
@if (!string.IsNullOrEmpty(review.Comment))
{
<p class="mb-2">@review.Comment</p>
}
@if (!string.IsNullOrEmpty(review.OrderReference?.ToString()))
@if (review.IsVerifiedPurchase)
{
<small class="text-muted">
<i class="fas fa-receipt"></i> Order: @review.OrderReference
<i class="fas fa-check-circle text-success"></i> Verified Purchase
</small>
}
</div>
@@ -558,7 +558,7 @@
<div class="row text-center">
<div class="col-md-6">
<strong>Average Rating</strong><br>
<span class="h4">@(productReviews.Average(r => r.Rating ?? 0).ToString("F1"))/5</span>
<span class="h4">@(productReviews.Average(r => r.Rating).ToString("F1"))/5</span>
</div>
<div class="col-md-6">
<strong>Total Reviews</strong><br>

View File

@@ -0,0 +1,260 @@
@model IEnumerable<LittleShop.Models.PushSubscription>
@{
ViewData["Title"] = "Push Subscriptions";
}
<div class="row mb-3">
<div class="col">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="@Url.Action("Index", "Dashboard")">Dashboard</a></li>
<li class="breadcrumb-item active">Push Subscriptions</li>
</ol>
</nav>
</div>
</div>
<div class="row mb-3">
<div class="col-md-8">
<h1><i class="fas fa-bell"></i> Push Subscriptions</h1>
<p class="text-muted mb-0">Manage browser push notification subscriptions for admins and customers</p>
</div>
<div class="col-md-4 text-end">
<form method="post" action="@Url.Action("CleanupExpired")" class="d-inline">
@Html.AntiForgeryToken()
<button type="submit" class="btn btn-warning"
onclick="return confirm('Remove all inactive and expired subscriptions?')">
<i class="fas fa-broom"></i> Cleanup Expired
</button>
</form>
</div>
</div>
<!-- Statistics Cards -->
<div class="row mb-4">
<div class="col-md-3">
<div class="card border-primary">
<div class="card-body">
<h6 class="text-muted mb-2">Total Subscriptions</h6>
<h3 class="mb-0">@Model.Count()</h3>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card border-success">
<div class="card-body">
<h6 class="text-muted mb-2">Active</h6>
<h3 class="mb-0 text-success">@Model.Count(s => s.IsActive)</h3>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card border-info">
<div class="card-body">
<h6 class="text-muted mb-2">Admin Users</h6>
<h3 class="mb-0">@Model.Count(s => s.UserId.HasValue)</h3>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card border-warning">
<div class="card-body">
<h6 class="text-muted mb-2">Customers</h6>
<h3 class="mb-0">@Model.Count(s => s.CustomerId.HasValue)</h3>
</div>
</div>
</div>
</div>
<!-- Subscriptions Table -->
@if (Model.Any())
{
<div class="card">
<div class="card-header bg-light">
<h5 class="mb-0"><i class="fas fa-list"></i> Subscription List</h5>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="table-light">
<tr>
<th style="width: 5%;">ID</th>
<th style="width: 15%;">Type</th>
<th style="width: 20%;">Endpoint</th>
<th style="width: 15%;">Subscribed</th>
<th style="width: 15%;">Last Used</th>
<th style="width: 15%;">Browser/Device</th>
<th style="width: 8%;">Status</th>
<th class="text-center" style="width: 7%;">Actions</th>
</tr>
</thead>
<tbody>
@foreach (var subscription in Model)
{
var daysInactive = subscription.LastUsedAt.HasValue
? (DateTime.UtcNow - subscription.LastUsedAt.Value).Days
: (DateTime.UtcNow - subscription.SubscribedAt).Days;
var statusClass = subscription.IsActive
? (daysInactive > 90 ? "warning" : "success")
: "danger";
<tr>
<td><code>@subscription.Id</code></td>
<td>
@if (subscription.UserId.HasValue)
{
<span class="badge bg-info">
<i class="fas fa-user-shield"></i> Admin User
</span>
@if (subscription.User != null)
{
<br><small class="text-muted">@subscription.User.Username</small>
}
}
else if (subscription.CustomerId.HasValue)
{
<span class="badge bg-warning">
<i class="fas fa-user"></i> Customer
</span>
@if (subscription.Customer != null)
{
<br><small class="text-muted">@subscription.Customer.TelegramDisplayName</small>
}
}
else
{
<span class="badge bg-secondary">
<i class="fas fa-question"></i> Unknown
</span>
}
</td>
<td>
<small class="font-monospace text-break"
data-bs-toggle="tooltip"
title="@subscription.Endpoint">
@(subscription.Endpoint.Length > 40 ? subscription.Endpoint.Substring(0, 40) + "..." : subscription.Endpoint)
</small>
@if (!string.IsNullOrEmpty(subscription.IpAddress))
{
<br><span class="badge bg-secondary"><i class="fas fa-network-wired"></i> @subscription.IpAddress</span>
}
</td>
<td>
@subscription.SubscribedAt.ToString("MMM dd, yyyy")
<br><small class="text-muted">@subscription.SubscribedAt.ToString("HH:mm")</small>
</td>
<td>
@if (subscription.LastUsedAt.HasValue)
{
@subscription.LastUsedAt.Value.ToString("MMM dd, yyyy")
<br><small class="text-muted">@subscription.LastUsedAt.Value.ToString("HH:mm")</small>
@if (daysInactive > 0)
{
<br><span class="badge bg-@(daysInactive > 90 ? "danger" : daysInactive > 30 ? "warning" : "info")">
@daysInactive days ago
</span>
}
}
else
{
<span class="text-muted">Never</span>
}
</td>
<td>
@if (!string.IsNullOrEmpty(subscription.UserAgent))
{
var ua = subscription.UserAgent;
var browser = ua.Contains("Chrome") ? "Chrome" :
ua.Contains("Firefox") ? "Firefox" :
ua.Contains("Safari") ? "Safari" :
ua.Contains("Edge") ? "Edge" : "Unknown";
var os = ua.Contains("Windows") ? "Windows" :
ua.Contains("Mac") ? "macOS" :
ua.Contains("Linux") ? "Linux" :
ua.Contains("Android") ? "Android" :
ua.Contains("iOS") ? "iOS" : "Unknown";
<span class="badge bg-secondary">@browser</span>
<span class="badge bg-dark">@os</span>
<br><small class="text-muted"
data-bs-toggle="tooltip"
title="@subscription.UserAgent">
@(ua.Length > 30 ? ua.Substring(0, 30) + "..." : ua)
</small>
}
else
{
<span class="text-muted">Not available</span>
}
</td>
<td class="text-center">
<span class="badge bg-@statusClass">
@if (subscription.IsActive)
{
<i class="fas fa-check-circle"></i> <text>Active</text>
}
else
{
<i class="fas fa-times-circle"></i> <text>Inactive</text>
}
</span>
</td>
<td class="text-center">
<form method="post" action="@Url.Action("Delete", new { id = subscription.Id })" class="d-inline">
@Html.AntiForgeryToken()
<button type="submit"
class="btn btn-sm btn-danger"
onclick="return confirm('Are you sure you want to delete this push subscription?')"
title="Delete Subscription">
<i class="fas fa-trash"></i>
</button>
</form>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
}
else
{
<div class="alert alert-info">
<i class="fas fa-info-circle"></i>
<strong>No push subscriptions yet</strong>
<p class="mb-0">Push notification subscriptions will appear here when users enable browser notifications.</p>
</div>
}
<!-- Information Card -->
<div class="row mt-4">
<div class="col">
<div class="card border-info">
<div class="card-header bg-info text-white">
<h6 class="mb-0"><i class="fas fa-info-circle"></i> About Push Subscriptions</h6>
</div>
<div class="card-body">
<ul class="mb-0">
<li><strong>Active Status:</strong> Subscriptions marked as active can receive push notifications</li>
<li><strong>IP Address Storage:</strong> IP addresses are stored for security and duplicate detection purposes</li>
<li><strong>Cleanup:</strong> Expired subscriptions (inactive for >90 days) can be removed using the cleanup button</li>
<li><strong>User Agent:</strong> Browser and device information helps identify subscription sources</li>
<li><strong>Privacy:</strong> Subscription data contains encryption keys required for Web Push API</li>
</ul>
</div>
</div>
</div>
</div>
@section Scripts {
<script>
// Initialize Bootstrap tooltips
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl)
});
</script>
}

View File

@@ -37,6 +37,7 @@
<link href="/_content/Radzen.Blazor/css/material-base.css" rel="stylesheet">
<link href="/css/modern-admin.css" rel="stylesheet">
<link href="/css/mobile-admin.css" rel="stylesheet">
<link href="/css/enhanced-navigation.css?v=20251114c" rel="stylesheet">
@await RenderSectionAsync("Head", required: false)
</head>
<body>
@@ -64,65 +65,106 @@
</a>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<!-- Dashboard (Always Visible) -->
<li class="nav-item">
<a class="nav-link" href="@Url.Action("Index", "Dashboard", new { area = "Admin" })">
<a class="nav-link @(ViewContext.RouteData.Values["controller"]?.ToString() == "Dashboard" ? "active" : "")" href="@Url.Action("Index", "Dashboard", new { area = "Admin" })">
<i class="fas fa-tachometer-alt"></i> Dashboard
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="@Url.Action("Index", "Categories", new { area = "Admin" })">
<i class="fas fa-tags"></i> Categories
<!-- Catalog Dropdown -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle @(new[]{"Products","Categories","VariantCollections"}.Contains(ViewContext.RouteData.Values["controller"]?.ToString()) ? "active" : "")" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fas fa-store"></i> Catalog
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="@Url.Action("Index", "Products", new { area = "Admin" })">
<i class="fas fa-box"></i> Products
</a></li>
<li><a class="dropdown-item" href="@Url.Action("Index", "Categories", new { area = "Admin" })">
<i class="fas fa-tags"></i> Categories
</a></li>
<li><a class="dropdown-item" href="@Url.Action("Index", "VariantCollections", new { area = "Admin" })">
<i class="fas fa-layer-group"></i> Variant Collections
</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="@Url.Action("Import", "Products", new { area = "Admin" })">
<i class="fas fa-upload"></i> Import Products
</a></li>
<li><a class="dropdown-item" href="@Url.Action("Export", "Products", new { area = "Admin" })">
<i class="fas fa-download"></i> Export Products
</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="@Url.Action("Index", "Products", new { area = "Admin" })">
<i class="fas fa-box"></i> Products
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="@Url.Action("Index", "VariantCollections", new { area = "Admin" })">
<i class="fas fa-layer-group"></i> Variants
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="@Url.Action("Index", "Orders", new { area = "Admin" })">
<!-- Orders & Fulfillment -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle @(new[]{"Orders","Customers","Payments","ShippingRates"}.Contains(ViewContext.RouteData.Values["controller"]?.ToString()) ? "active" : "")" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fas fa-shopping-cart"></i> Orders
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="@Url.Action("Index", "Orders", new { area = "Admin" })">
<i class="fas fa-clipboard-list"></i> All Orders
</a></li>
<li><a class="dropdown-item" href="@Url.Action("Index", "Customers", new { area = "Admin" })">
<i class="fas fa-users"></i> Customers
</a></li>
<li><a class="dropdown-item" href="@Url.Action("Index", "Payments", new { area = "Admin" })">
<i class="fas fa-wallet"></i> Payment Transactions
</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="@Url.Action("Index", "Orders", new { area = "Admin", tab = "pending" })">
<i class="fas fa-clock"></i> Pending Payment
</a></li>
<li><a class="dropdown-item" href="@Url.Action("Index", "Orders", new { area = "Admin", tab = "accept" })">
<i class="fas fa-check-circle"></i> Ready to Accept
</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="@Url.Action("Index", "ShippingRates", new { area = "Admin" })">
<i class="fas fa-truck"></i> Shipping Rates
</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="@Url.Action("Index", "Reviews", new { area = "Admin" })">
<i class="fas fa-star"></i> Reviews
<!-- Customer Communication -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle @(new[]{"Reviews","Messages","BotActivity"}.Contains(ViewContext.RouteData.Values["controller"]?.ToString()) ? "active" : "")" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fas fa-comments"></i> Customers
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="@Url.Action("Index", "Reviews", new { area = "Admin" })">
<i class="fas fa-star"></i> Reviews
</a></li>
<li><a class="dropdown-item" href="@Url.Action("Index", "Messages", new { area = "Admin" })">
<i class="fas fa-envelope"></i> Messages
</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="@Url.Action("LiveView", "BotActivity", new { area = "Admin" })">
<i class="fas fa-satellite-dish"></i> Live Activity
</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="@Url.Action("Index", "Messages", new { area = "Admin" })">
<i class="fas fa-comments"></i> Messages
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="@Url.Action("Index", "ShippingRates", new { area = "Admin" })">
<i class="fas fa-truck"></i> Shipping
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="@Url.Action("Index", "Users", new { area = "Admin" })">
<i class="fas fa-users"></i> Users
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="@Url.Action("Index", "Bots", new { area = "Admin" })">
<i class="fas fa-robot"></i> Bots
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="@Url.Action("LiveView", "BotActivity", new { area = "Admin" })">
<i class="fas fa-satellite-dish"></i> Live Activity
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="@Url.Action("Index", "SystemSettings", new { area = "Admin" })">
<!-- Settings -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle @(new[]{"Users","Bots","PushSubscriptions","SystemSettings"}.Contains(ViewContext.RouteData.Values["controller"]?.ToString()) ? "active" : "")" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fas fa-cog"></i> Settings
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="@Url.Action("Index", "Users", new { area = "Admin" })">
<i class="fas fa-users"></i> Users
</a></li>
<li><a class="dropdown-item" href="@Url.Action("Index", "Bots", new { area = "Admin" })">
<i class="fas fa-robot"></i> Bots
</a></li>
<li><a class="dropdown-item" href="@Url.Action("Index", "PushSubscriptions", new { area = "Admin" })">
<i class="fas fa-bell"></i> Push Subscriptions
</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="@Url.Action("Index", "SystemSettings", new { area = "Admin" })">
<i class="fas fa-sliders-h"></i> System Settings
</a></li>
</ul>
</li>
</ul>
<ul class="navbar-nav">