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:
377
LittleShop/Pages/Admin/Products/ProductsBlazor.razor
Normal file
377
LittleShop/Pages/Admin/Products/ProductsBlazor.razor
Normal file
@@ -0,0 +1,377 @@
|
||||
@page "/blazor/admin/products"
|
||||
@page "/blazor/admin/products/{ProductId:guid}"
|
||||
@layout AdminLayout
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using Microsoft.AspNetCore.Components.Forms
|
||||
@inject IProductService ProductService
|
||||
@inject ICategoryService CategoryService
|
||||
@inject NavigationManager Navigation
|
||||
@attribute [Authorize(Policy = "AdminOnly")]
|
||||
|
||||
<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($"/blazor/admin/products/{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);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Error saving product: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OnSaveAndAddNew()
|
||||
{
|
||||
await OnSubmit();
|
||||
InitializeNewProduct();
|
||||
selectedTab = "details";
|
||||
Navigation.NavigateTo("/blazor/admin/products", false);
|
||||
}
|
||||
|
||||
private void OnCancel()
|
||||
{
|
||||
Navigation.NavigateTo("/Admin/Products");
|
||||
}
|
||||
|
||||
private async Task CreateQuickMultiBuy(int quantity, decimal discountPercent)
|
||||
{
|
||||
Console.WriteLine($"Creating multi-buy: {quantity} items with {discountPercent}% discount");
|
||||
}
|
||||
}
|
||||
22
LittleShop/Pages/Shared/AdminLayout.razor
Normal file
22
LittleShop/Pages/Shared/AdminLayout.razor
Normal file
@@ -0,0 +1,22 @@
|
||||
@inherits LayoutComponentBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IJSRuntime JSRuntime
|
||||
|
||||
<div class="blazor-admin-wrapper">
|
||||
@Body
|
||||
|
||||
<div id="blazor-error-ui">
|
||||
<environment include="Staging,Production">
|
||||
An error has occurred. This application may no longer respond until reloaded.
|
||||
</environment>
|
||||
<environment include="Development">
|
||||
An unhandled exception has occurred. See browser dev tools for details.
|
||||
</environment>
|
||||
<a href="" class="reload">Reload</a>
|
||||
<a class="dismiss">🗙</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
}
|
||||
5
LittleShop/Pages/Shared/MainLayout.razor
Normal file
5
LittleShop/Pages/Shared/MainLayout.razor
Normal file
@@ -0,0 +1,5 @@
|
||||
@inherits LayoutComponentBase
|
||||
|
||||
<div class="blazor-container">
|
||||
@Body
|
||||
</div>
|
||||
14
LittleShop/Pages/_Host.cshtml
Normal file
14
LittleShop/Pages/_Host.cshtml
Normal file
@@ -0,0 +1,14 @@
|
||||
@page "/blazor"
|
||||
@namespace LittleShop.Pages
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@{
|
||||
Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
|
||||
ViewData["Title"] = "Admin";
|
||||
}
|
||||
|
||||
<component type="typeof(App)" render-mode="ServerPrerendered" />
|
||||
|
||||
@section Scripts {
|
||||
<script src="/_framework/blazor.server.js"></script>
|
||||
<script src="/_content/Radzen.Blazor/Radzen.Blazor.js"></script>
|
||||
}
|
||||
Reference in New Issue
Block a user