diff --git a/ShopAdmin/Components/CreateProduct.razor b/ShopAdmin/Components/CreateProduct.razor index 227a2f9..ea6b2bd 100644 --- a/ShopAdmin/Components/CreateProduct.razor +++ b/ShopAdmin/Components/CreateProduct.razor @@ -93,6 +93,7 @@
+ @if (string.IsNullOrEmpty(ProductModel.ImageUrl)) { diff --git a/ShopAdmin/Components/CreateProduct.razor.cs b/ShopAdmin/Components/CreateProduct.razor.cs index a8b7565..87cbfa6 100644 --- a/ShopAdmin/Components/CreateProduct.razor.cs +++ b/ShopAdmin/Components/CreateProduct.razor.cs @@ -1,4 +1,5 @@ using LiteCharms.Features.S3.Abstractions; +using LiteCharms.Features.Shop.Products.Models; using static LiteCharms.Features.S3.Constants; namespace ShopAdmin.Components; @@ -8,7 +9,6 @@ public partial class CreateProduct([FromKeyedServices(BookshopBucketName)] IS3Se private bool isCalendarOpen = false; private DateTime calendarViewingMonth = DateTime.Today; private List calendarDays = new(); - private string currentCalendarMonthYearText => calendarViewingMonth.ToString("MMMM yyyy"); private readonly CancellationTokenSource cancellationTokenSource = new(); private CancellationToken cancellationToken; @@ -185,37 +185,4 @@ public partial class CreateProduct([FromKeyedServices(BookshopBucketName)] IS3Se isCalendarOpen = false; // Collapse popup smoothly on successful selection StateHasChanged(); } -} - -public class CreateProductModel -{ - [Required(ErrorMessage = "Product name is required.")] - public string? Name { get; set; } - - [Required(ErrorMessage = "Summary is required.")] - public string? Summary { get; set; } - - [Required(ErrorMessage = "Description is required.")] - public string? Description { get; set; } - - [Range(0.01, double.MaxValue, ErrorMessage = "Price must be greater than zero.")] - public decimal Price { get; set; } - - [Required(ErrorMessage = "Author metadata is required.")] - public string? Author { get; set; } - - [Required(ErrorMessage = "Publication Date is required.")] - public DateTime PublishDate { get; set; } = DateTime.Today; - - [Required(ErrorMessage = "Copyright Information field is required.")] - public string? CopyrightInfo { get; set; } - - [Required(ErrorMessage = "ISBN code is required.")] - [RegularExpression(@"^(?=(?:\D*\d){10}(?:(?:\D*\d){3})?$)[\d-]+$", ErrorMessage = "Please enter a valid ISBN-10 or ISBN-13 string.")] - public string? Isbn { get; set; } - - [Required(ErrorMessage = "Primary image is required.")] - public string? ImageUrl { get; set; } - - public List Thumbnails { get; set; } = []; } \ No newline at end of file diff --git a/ShopAdmin/ShopAdmin.csproj b/ShopAdmin/ShopAdmin.csproj index 7ec4ff7..dadf1c8 100644 --- a/ShopAdmin/ShopAdmin.csproj +++ b/ShopAdmin/ShopAdmin.csproj @@ -16,7 +16,7 @@ - +