Refactor payment verification to manual workflow and add comprehensive cleanup tools

Major changes:
• Remove BTCPay Server integration in favor of SilverPAY manual verification
• Add test data cleanup mechanisms (API endpoints and shell scripts)
• Fix compilation errors in TestController (IdentityReference vs CustomerIdentity)
• Add deployment automation scripts for Hostinger VPS
• Enhance integration testing with comprehensive E2E validation
• Add Blazor components and mobile-responsive CSS for admin interface
• Create production environment configuration scripts

Key Features Added:
• Manual payment verification through Admin panel Order Details
• Bulk test data cleanup with proper cascade handling
• Deployment automation with systemd service configuration
• Comprehensive E2E testing suite with SilverPAY integration validation
• Mobile-first admin interface improvements

Security & Production:
• Environment variable configuration for production secrets
• Proper JWT and VAPID key management
• SilverPAY API integration with live credentials
• Database cleanup and maintenance tools

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-25 19:29:00 +01:00
parent 1588c79df0
commit 127be759c8
46 changed files with 3470 additions and 971 deletions

View File

@@ -0,0 +1,377 @@
@page "/admin/products/blazor"
@page "/admin/products/blazor/{ProductId:guid}"
@using Microsoft.AspNetCore.Components.Forms
@inject IProductService ProductService
@inject ICategoryService CategoryService
@inject NavigationManager Navigation
<div class="container-fluid">
<div class="row mb-4">
<div class="col">
<h1><i class="fas fa-box"></i> Products - Enhanced UI</h1>
</div>
</div>
<div class="nav nav-tabs nav-tabs-mobile mb-4">
<button class="nav-link @(selectedTab == "details" ? "active" : "")"
@onclick="@(() => SetActiveTab("details"))">
<i class="fas fa-edit"></i>
Product Details
</button>
<button class="nav-link @(selectedTab == "variants" ? "active" : "")"
@onclick="@(() => SetActiveTab("variants"))"
disabled="@isNewProduct">
<i class="fas fa-layer-group"></i>
Variants
</button>
<button class="nav-link @(selectedTab == "multibuys" ? "active" : "")"
@onclick="@(() => SetActiveTab("multibuys"))"
disabled="@isNewProduct">
<i class="fas fa-percentage"></i>
Multi-Buys
</button>
<button class="nav-link @(selectedTab == "photos" ? "active" : "")"
@onclick="@(() => SetActiveTab("photos"))"
disabled="@isNewProduct">
<i class="fas fa-camera"></i>
Photos
</button>
</div>
@if (selectedTab == "details")
{
<div class="card">
<div class="card-body">
<EditForm Model="product" OnValidSubmit="OnSubmit">
<DataAnnotationsValidator />
<ValidationSummary />
<div class="row">
<div class="col-md-8">
<div class="mb-3">
<label class="form-label">Product Name</label>
<InputText @bind-Value="product.Name" class="form-control" />
<ValidationMessage For="() => product.Name" />
</div>
<div class="mb-3">
<label class="form-label">Description</label>
<InputTextArea @bind-Value="product.Description" class="form-control" rows="4" />
<ValidationMessage For="() => product.Description" />
</div>
<div class="row">
<div class="col-md-4">
<div class="mb-3">
<label class="form-label">Price (£)</label>
<InputNumber @bind-Value="product.Price" class="form-control" />
<ValidationMessage For="() => product.Price" />
</div>
</div>
<div class="col-md-4">
<div class="mb-3">
<label class="form-label">Stock Quantity</label>
<InputNumber @bind-Value="product.StockQuantity" class="form-control" />
<ValidationMessage For="() => product.StockQuantity" />
</div>
</div>
<div class="col-md-4">
<div class="mb-3">
<label class="form-label">Category</label>
<InputSelect @bind-Value="product.CategoryId" class="form-select">
<option value="">Select a category</option>
@foreach (var category in categories)
{
<option value="@category.Id">@category.Name</option>
}
</InputSelect>
<ValidationMessage For="() => product.CategoryId" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="mb-3">
<label class="form-label">Weight/Volume</label>
<InputNumber @bind-Value="product.Weight" class="form-control" />
<ValidationMessage For="() => product.Weight" />
</div>
</div>
<div class="col-md-6">
<div class="mb-3">
<label class="form-label">Unit</label>
<InputSelect @bind-Value="product.WeightUnit" class="form-select">
@foreach (var unit in Enum.GetValues<ProductWeightUnit>())
{
<option value="@unit">@unit.ToString()</option>
}
</InputSelect>
</div>
</div>
</div>
<div class="mb-3">
<div class="form-check">
<InputCheckbox @bind-Value="product.IsActive" class="form-check-input" />
<label class="form-check-label">Active (visible in catalog)</label>
</div>
</div>
<div class="btn-group-mobile">
<button type="submit" class="btn btn-primary">
<i class="fas fa-save"></i> Save
</button>
<button type="button" class="btn btn-success" @onclick="OnSaveAndAddNew">
<i class="fas fa-plus"></i> Save + Add New
</button>
<button type="button" class="btn btn-secondary" @onclick="OnCancel">
<i class="fas fa-times"></i> Cancel
</button>
</div>
</div>
<div class="col-md-4">
<div class="card">
<div class="card-header">
<h5>Quick Actions</h5>
</div>
<div class="card-body">
@if (!isNewProduct)
{
<p><strong>Product ID:</strong> @ProductId</p>
<button class="btn btn-outline-primary btn-sm w-100 mb-2"
@onclick="@(() => SetActiveTab("variants"))">
<i class="fas fa-layer-group"></i> Manage Variants
</button>
<button class="btn btn-outline-success btn-sm w-100 mb-2"
@onclick="@(() => SetActiveTab("multibuys"))">
<i class="fas fa-percentage"></i> Setup Multi-Buys
</button>
<button class="btn btn-outline-info btn-sm w-100"
@onclick="@(() => SetActiveTab("photos"))">
<i class="fas fa-camera"></i> Manage Photos
</button>
}
else
{
<div class="alert alert-info">
<small>Save the product first to enable variants, multi-buys, and photo management.</small>
</div>
}
</div>
</div>
</div>
</div>
</EditForm>
</div>
</div>
}
@if (selectedTab == "variants" && !isNewProduct)
{
<div class="card">
<div class="card-header">
<h5><i class="fas fa-layer-group"></i> Product Variants</h5>
</div>
<div class="card-body">
<p class="text-info">This is where product variants would be managed. Integration pending with existing variation system.</p>
<button class="btn btn-primary">
<i class="fas fa-plus"></i> Add Variant
</button>
</div>
</div>
}
@if (selectedTab == "multibuys" && !isNewProduct)
{
<div class="card">
<div class="card-header">
<h5><i class="fas fa-percentage"></i> Multi-Buy Offers</h5>
</div>
<div class="card-body">
<div class="row mb-3">
<div class="col-md-4">
<button class="btn btn-outline-secondary w-100 mb-2" @onclick="() => CreateQuickMultiBuy(2, 10)">
Buy 2 Get 10% Off
</button>
</div>
<div class="col-md-4">
<button class="btn btn-outline-secondary w-100 mb-2" @onclick="() => CreateQuickMultiBuy(3, 15)">
Buy 3 Get 15% Off
</button>
</div>
<div class="col-md-4">
<button class="btn btn-outline-secondary w-100 mb-2" @onclick="() => CreateQuickMultiBuy(5, 20)">
Buy 5 Get 20% Off
</button>
</div>
</div>
</div>
</div>
}
@if (selectedTab == "photos" && !isNewProduct)
{
<div class="card">
<div class="card-header">
<h5><i class="fas fa-camera"></i> Product Photos</h5>
</div>
<div class="card-body">
<p class="text-info">Photo management integration pending.</p>
<input type="file" class="form-control" accept="image/*" multiple />
<small class="form-text text-muted">Select multiple images to upload.</small>
</div>
</div>
}
</div>
@code {
[Parameter] public Guid? ProductId { get; set; }
private ProductFormModel product = new();
private List<CategoryDto> categories = new();
private string selectedTab = "details";
private bool isNewProduct => ProductId == null || ProductId == Guid.Empty;
public class ProductFormModel
{
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public decimal Price { get; set; } = 0.01m;
public int StockQuantity { get; set; } = 0;
public Guid CategoryId { get; set; } = Guid.Empty;
public decimal Weight { get; set; } = 0.01m;
public ProductWeightUnit WeightUnit { get; set; } = ProductWeightUnit.Unit;
public bool IsActive { get; set; } = true;
}
protected override async Task OnInitializedAsync()
{
await LoadCategories();
if (!isNewProduct)
{
await LoadProduct();
}
else
{
InitializeNewProduct();
}
}
private void InitializeNewProduct()
{
product = new ProductFormModel
{
Name = string.Empty,
Description = string.Empty,
Price = 0.01m,
StockQuantity = 0,
CategoryId = Guid.Empty,
Weight = 0.01m,
WeightUnit = ProductWeightUnit.Unit,
IsActive = true
};
}
private async Task LoadCategories()
{
categories = (await CategoryService.GetAllCategoriesAsync()).ToList();
}
private async Task LoadProduct()
{
try
{
var existingProduct = await ProductService.GetProductByIdAsync(ProductId!.Value);
if (existingProduct != null)
{
product = new ProductFormModel
{
Name = existingProduct.Name,
Description = existingProduct.Description,
Price = existingProduct.Price,
StockQuantity = existingProduct.StockQuantity,
CategoryId = existingProduct.CategoryId,
Weight = existingProduct.Weight,
WeightUnit = existingProduct.WeightUnit,
IsActive = existingProduct.IsActive
};
}
}
catch (Exception ex)
{
Console.WriteLine($"Error loading product: {ex.Message}");
}
}
private void SetActiveTab(string tab)
{
selectedTab = tab;
}
private async Task OnSubmit()
{
try
{
if (isNewProduct)
{
var createDto = new CreateProductDto
{
Name = product.Name,
Description = product.Description,
Price = product.Price,
StockQuantity = product.StockQuantity,
CategoryId = product.CategoryId,
Weight = product.Weight,
WeightUnit = product.WeightUnit
};
var newProduct = await ProductService.CreateProductAsync(createDto);
Navigation.NavigateTo($"/admin/products/blazor/{newProduct.Id}", false);
}
else
{
var updateDto = new UpdateProductDto
{
Name = product.Name,
Description = product.Description,
Price = product.Price,
StockQuantity = product.StockQuantity,
CategoryId = product.CategoryId,
Weight = product.Weight,
WeightUnit = product.WeightUnit,
IsActive = product.IsActive
};
await ProductService.UpdateProductAsync(ProductId!.Value, updateDto);
// Show success message or stay on current view
}
}
catch (Exception ex)
{
Console.WriteLine($"Error saving product: {ex.Message}");
}
}
private async Task OnSaveAndAddNew()
{
await OnSubmit();
// Reset form for new product
InitializeNewProduct();
selectedTab = "details";
Navigation.NavigateTo("/admin/products/blazor", false);
}
private void OnCancel()
{
Navigation.NavigateTo("/Admin/Products");
}
private async Task CreateQuickMultiBuy(int quantity, decimal discountPercent)
{
// TODO: Implement multi-buy creation
Console.WriteLine($"Creating multi-buy: {quantity} items with {discountPercent}% discount");
}
}

View File

@@ -27,11 +27,17 @@ public class ProductsController : Controller
Response.Headers.Add("Cache-Control", "no-cache, no-store, must-revalidate");
Response.Headers.Add("Pragma", "no-cache");
Response.Headers.Add("Expires", "0");
var products = await _productService.GetAllProductsAsync();
return View(products);
}
public IActionResult Blazor(Guid? id)
{
ViewData["ProductId"] = id;
return View();
}
public async Task<IActionResult> Create()
{
var categories = await _categoryService.GetAllCategoriesAsync();

View File

@@ -0,0 +1,35 @@
@{
ViewData["Title"] = "Products Management";
Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}
<div id="blazor-products-container" data-blazor-component="products">
<component type="typeof(LittleShop.Areas.Admin.Components.Products.ProductsBlazorSimple)"
render-mode="ServerPrerendered"
param-ProductId="@ViewData["ProductId"]" />
</div>
@section Scripts {
<script>
// Initialize Blazor Server
window.addEventListener('DOMContentLoaded', function () {
if (window.Blazor && window.Blazor.start) {
console.log('Starting Blazor...');
window.Blazor.start();
} else {
console.log('Blazor not available, attempting manual start...');
// Fallback - load the blazor script if not already loaded
if (!document.querySelector('script[src*="blazor.server.js"]')) {
var script = document.createElement('script');
script.src = '/_framework/blazor.server.js';
script.onload = function() {
if (window.Blazor) {
window.Blazor.start();
}
};
document.head.appendChild(script);
}
}
});
</script>
}

View File

@@ -10,14 +10,17 @@
</div>
<div class="col-auto">
<div class="btn-group">
<a href="@Url.Action("Blazor")" class="btn btn-success">
<i class="fas fa-rocket"></i> <span class="d-none d-sm-inline">New</span> Blazor UI
</a>
<a href="@Url.Action("Create")" class="btn btn-primary">
<i class="fas fa-plus"></i> Add Product
<i class="fas fa-plus"></i> <span class="d-none d-sm-inline">Add Product</span>
</a>
<a href="@Url.Action("Import")" class="btn btn-outline-success">
<i class="fas fa-upload"></i> Import CSV
<i class="fas fa-upload"></i> <span class="d-none d-sm-inline">Import</span>
</a>
<a href="@Url.Action("Export")" class="btn btn-outline-info">
<i class="fas fa-download"></i> Export CSV
<i class="fas fa-download"></i> <span class="d-none d-sm-inline">Export</span>
</a>
</div>
</div>

View File

@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<base href="/" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover" />
<title>@ViewData["Title"] - TeleShop Admin</title>
@@ -33,7 +34,10 @@
<link href="/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/lib/fontawesome/css/all.min.css" rel="stylesheet">
<link href="/lib/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
<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">
@await RenderSectionAsync("Head", required: false)
</head>
<body>
<header>
@@ -131,9 +135,130 @@
<script src="/lib/jquery/jquery.min.js"></script>
<script src="/lib/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="/_framework/blazor.server.js" autostart="false"></script>
<script src="/_content/Radzen.Blazor/Radzen.Blazor.js"></script>
<script src="/js/pwa.js"></script>
<script src="/js/notifications.js"></script>
<script src="/js/modern-mobile.js"></script>
<script src="/js/blazor-integration.js"></script>
@await RenderSectionAsync("Scripts", required: false)
<!-- Mobile Bottom Navigation -->
<nav class="mobile-bottom-nav">
<ul class="mobile-bottom-nav-items">
<li class="mobile-nav-item">
<a href="@Url.Action("Index", "Orders", new { area = "Admin" })" class="mobile-nav-link @(ViewContext.RouteData.Values["controller"]?.ToString() == "Orders" ? "active" : "")">
<i class="fas fa-shopping-cart"></i>
<span>Orders</span>
<span class="mobile-nav-badge" id="mobile-orders-badge" style="display: none;">0</span>
</a>
</li>
<li class="mobile-nav-item">
<a href="@Url.Action("Index", "Reviews", new { area = "Admin" })" class="mobile-nav-link @(ViewContext.RouteData.Values["controller"]?.ToString() == "Reviews" ? "active" : "")">
<i class="fas fa-star"></i>
<span>Reviews</span>
</a>
</li>
<li class="mobile-nav-item">
<a href="@Url.Action("Index", "Messages", new { area = "Admin" })" class="mobile-nav-link @(ViewContext.RouteData.Values["controller"]?.ToString() == "Messages" ? "active" : "")">
<i class="fas fa-comments"></i>
<span>Messages</span>
<span class="mobile-nav-badge" id="mobile-messages-badge" style="display: none;">0</span>
</a>
</li>
<li class="mobile-nav-item">
<a href="@Url.Action("LiveView", "BotActivity", new { area = "Admin" })" class="mobile-nav-link @(ViewContext.RouteData.Values["controller"]?.ToString() == "BotActivity" ? "active" : "")">
<i class="fas fa-satellite-dish"></i>
<span>Live</span>
</a>
</li>
<li class="mobile-nav-item">
<a href="#" class="mobile-nav-link" onclick="toggleSettingsDrawer(); return false;">
<i class="fas fa-cog"></i>
<span>Settings</span>
</a>
</li>
</ul>
</nav>
<!-- Settings Drawer -->
<div class="drawer-overlay" onclick="toggleSettingsDrawer()"></div>
<div class="settings-drawer" id="settingsDrawer">
<div class="settings-drawer-header">
<h5>Settings</h5>
<button class="settings-drawer-close" onclick="toggleSettingsDrawer()">
<i class="fas fa-times"></i>
</button>
</div>
<ul class="settings-menu-list">
<li class="settings-menu-item">
<a href="@Url.Action("Index", "Dashboard", new { area = "Admin" })" class="settings-menu-link">
<i class="fas fa-tachometer-alt"></i>
Dashboard
</a>
</li>
<li class="settings-menu-item">
<a href="@Url.Action("Index", "Categories", new { area = "Admin" })" class="settings-menu-link">
<i class="fas fa-tags"></i>
Categories
</a>
</li>
<li class="settings-menu-item">
<a href="@Url.Action("Index", "Products", new { area = "Admin" })" class="settings-menu-link">
<i class="fas fa-box"></i>
Products
</a>
</li>
<li class="settings-menu-item">
<a href="@Url.Action("Index", "ShippingRates", new { area = "Admin" })" class="settings-menu-link">
<i class="fas fa-truck"></i>
Shipping
</a>
</li>
<li class="settings-menu-item">
<a href="@Url.Action("Index", "Users", new { area = "Admin" })" class="settings-menu-link">
<i class="fas fa-users"></i>
Users
</a>
</li>
<li class="settings-menu-item">
<a href="@Url.Action("Index", "Bots", new { area = "Admin" })" class="settings-menu-link">
<i class="fas fa-robot"></i>
Bots
</a>
</li>
<li class="settings-menu-item">
<a href="@Url.Action("Index", "SystemSettings", new { area = "Admin" })" class="settings-menu-link">
<i class="fas fa-sliders-h"></i>
System Settings
</a>
</li>
<li class="settings-menu-item">
<form method="post" action="@Url.Action("Logout", "Account", new { area = "Admin" })">
<button type="submit" class="settings-menu-link" style="width: 100%; border: none; background: none; text-align: left;">
<i class="fas fa-sign-out-alt"></i>
Logout
</button>
</form>
</li>
</ul>
</div>
<script>
// Settings Drawer Toggle
function toggleSettingsDrawer() {
const drawer = document.getElementById('settingsDrawer');
const overlay = document.querySelector('.drawer-overlay');
drawer.classList.toggle('open');
overlay.classList.toggle('show');
// Prevent body scroll when drawer is open
if (drawer.classList.contains('open')) {
document.body.style.overflow = 'hidden';
} else {
document.body.style.overflow = '';
}
}
</script>
</body>
</html>