This commit is contained in:
2025-10-27 17:39:18 -04:00
commit 31f723bea4
1579 changed files with 642409 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
using Prefab.Web.Client.ViewModels.Catalog;
namespace Prefab.Web.Client.Models.Catalog;
public sealed class ProductListingModel
{
public ProductCategoryModel Category { get; set; } = new();
public IReadOnlyList<ProductCardModel> Products { get; set; } = Array.Empty<ProductCardModel>();
public int Total { get; set; }
public int Page { get; set; }
public int PageSize { get; set; }
public string Sort { get; set; } = "name:asc";
public string View { get; set; } = "grid";
}
public sealed class ProductCategoryModel
{
public Guid Id { get; set; }
public string Name { get; set; } = string.Empty;
public string Slug { get; set; } = string.Empty;
public string? Description { get; set; }
public string? HeroImageUrl { get; set; }
public string? Icon { get; set; }
}

View File

@@ -0,0 +1,10 @@
namespace Prefab.Web.Client.Models;
public class CategoryListItemModel
{
public Guid Id { get; set; }
public string Name { get; set; } = string.Empty;
public string ParentName { get; set; } = string.Empty;
}

View File

@@ -0,0 +1,14 @@
namespace Prefab.Web.Client.Models;
public class CategoryModel
{
public Guid Id { get; set; }
public Guid? ParentId { get; set; }
public string Name { get; set; } = string.Empty;
public string ParentName { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
}

View File

@@ -0,0 +1,10 @@
using Prefab.Web.Client.ViewModels.Catalog;
namespace Prefab.Web.Client.Models.Home;
public sealed class HomePageModel
{
public IReadOnlyList<ProductCardModel> FeaturedProducts { get; set; } = Array.Empty<ProductCardModel>();
public IReadOnlyList<CategoryCardModel> LatestCategories { get; set; } = Array.Empty<CategoryCardModel>();
}

View File

@@ -0,0 +1,12 @@
namespace Prefab.Web.Client.Models.Shared;
/// <summary>
/// Represents a monetary amount with its associated currency.
/// </summary>
public sealed class MoneyModel
{
public decimal Amount { get; set; }
public string Currency { get; set; } = "USD";
}

View File

@@ -0,0 +1,28 @@
namespace Prefab.Web.Client.Models.Shared;
/// <summary>
/// Represents the navigation menu payload exposed by the gateway.
/// </summary>
/// <param name="Depth">Requested depth used when building the menu.</param>
/// <param name="MaxItemsPerColumn">Maximum number of child links per column.</param>
/// <param name="Columns">Menu columns sourced from root categories.</param>
public sealed record NavMenuModel(int Depth, int MaxItemsPerColumn, IReadOnlyList<NavMenuColumnModel> Columns);
/// <summary>
/// Represents an individual column in the navigation menu.
/// </summary>
/// <param name="Root">The root category anchoring the column.</param>
/// <param name="Items">Featured child categories.</param>
/// <param name="HasMore">Whether additional children exist beyond the truncated list.</param>
/// <param name="SeeAllUrl">Link to view the full set of categories for the root.</param>
public sealed record NavMenuColumnModel(NavMenuLinkModel Root, IReadOnlyList<NavMenuLinkModel> Items, bool HasMore, string SeeAllUrl);
/// <summary>
/// Represents a navigable link within the menu.
/// </summary>
/// <param name="Id">Identifier of the item.</param>
/// <param name="Name">Display name.</param>
/// <param name="Slug">Slug used for routing.</param>
/// <param name="IsLeaf">True when the link represents a terminal category.</param>
/// <param name="Url">Absolute or relative navigation target.</param>
public sealed record NavMenuLinkModel(string Id, string Name, string Slug, bool IsLeaf, string Url);

View File

@@ -0,0 +1,71 @@
namespace Prefab.Web.Client.Models.Shared;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using FluentValidation;
public sealed class ResultProblem
{
public string? Title { get; init; }
public string? Detail { get; init; }
public int? StatusCode { get; init; }
public IReadOnlyDictionary<string, string[]>? Errors { get; init; }
public static ResultProblem FromValidation(ValidationException exception)
{
var errors = exception.Errors
.GroupBy(error => string.IsNullOrWhiteSpace(error.PropertyName) ? string.Empty : error.PropertyName)
.ToDictionary(
group => group.Key,
group => group.Select(error => error.ErrorMessage ?? string.Empty).ToArray());
return new ResultProblem
{
Title = "Validation failed.",
Detail = "Request did not satisfy validation rules.",
StatusCode = (int)HttpStatusCode.BadRequest,
Errors = errors
};
}
public static ResultProblem Unexpected(string title, Exception exception, HttpStatusCode statusCode = HttpStatusCode.InternalServerError) =>
new()
{
Title = title,
Detail = exception.Message,
StatusCode = (int)statusCode
};
}
/// <summary>
/// Represents the outcome of an operation that produces a value of type <typeparamref name="T"/>.
/// </summary>
/// <typeparam name="T">The payload type returned when the operation succeeds.</typeparam>
public sealed class Result<T>
{
public Result()
{
}
public bool IsSuccess => Problem is null;
public ResultProblem? Problem { get; init; }
public int? StatusCode => Problem?.StatusCode;
public T? Value { get; init; }
public static Result<T> Success(T value) => new()
{
Value = value ?? throw new ArgumentNullException(nameof(value))
};
public static Result<T> Failure(ResultProblem problem) => new()
{
Problem = problem ?? throw new ArgumentNullException(nameof(problem))
};
}

View File

@@ -0,0 +1,11 @@
namespace Prefab.Web.Client.Models;
public class Slide
{
public int Number { get; set; }
public string Text { get; set; } = string.Empty;
public string TextWidth { get; set; } = string.Empty;
public string TextPosition { get; set; } = string.Empty;
public string AltText { get; set; } = string.Empty;
public string GoToUrl { get; set; } = string.Empty;
}