diff --git a/Web-Jarmark/Web-Jarmark/Components/Pages/Katalog.razor b/Web-Jarmark/Web-Jarmark/Components/Pages/Katalog.razor index 2cca65d..e9efc9f 100644 --- a/Web-Jarmark/Web-Jarmark/Components/Pages/Katalog.razor +++ b/Web-Jarmark/Web-Jarmark/Components/Pages/Katalog.razor @@ -1,25 +1,22 @@ @page "/" @using Microsoft.EntityFrameworkCore @using Web_Jarmark.Data +@using Web_Jarmark.Components.Pages.Shared + @using Web_Jarmark.Data.Models @inject ApplicationDbContext DbContext

Katalog Produktů

+
@foreach (var product in products) { -
-
-
-
@product.Name
-

Kategorie: @product.Category.Name

-

Cena: @product.Price.ToString("C")

-

Stock: @product.StockQuantity

-
-
-
+ }
+
@code { private List products; @@ -30,4 +27,8 @@ .Include(p => p.Category) .ToListAsync(); } + private void HandleAddToCart(Product product) + { + Console.WriteLine($"Přidán produkt: {product.Name}"); + } } diff --git a/Web-Jarmark/Web-Jarmark/Components/Pages/Shared/ProductCard.razor b/Web-Jarmark/Web-Jarmark/Components/Pages/Shared/ProductCard.razor new file mode 100644 index 0000000..dcc0f3a --- /dev/null +++ b/Web-Jarmark/Web-Jarmark/Components/Pages/Shared/ProductCard.razor @@ -0,0 +1,68 @@ +@using Web_Jarmark.Data.Models + +
+ +
+ @ProductIcon + + + @Product.Category.Name + +
+ +
+ +

@Product.Name

+ +

+ @Product.Category.Name +

+ +
+ + + @if (Product.StockQuantity > 0) + { + Skladem: @Product.StockQuantity ks + } + else + { + Není skladem + } +
+ +
+ @Product.Price.ToString("C") +
+ + + +
+ +
+ +@code { + [Parameter, EditorRequired] + public Product Product { get; set; } = default!; + + [Parameter] + public EventCallback OnAddToCart { get; set; } + + private string ProductIcon => + Product.Category.Name.Contains("med", + StringComparison.OrdinalIgnoreCase) ? "🍯" : + Product.Category.Name.Contains("cuk", + StringComparison.OrdinalIgnoreCase) ? "🍪" : + Product.Category.Name.Contains("dřev", + StringComparison.OrdinalIgnoreCase) ? "🪵" : "🎁"; + + private async Task AddToCart() + { + await OnAddToCart.InvokeAsync(Product); + } +} + diff --git a/Web-Jarmark/Web-Jarmark/Web-Jarmark.csproj b/Web-Jarmark/Web-Jarmark/Web-Jarmark.csproj index e85e926..13beeb4 100644 --- a/Web-Jarmark/Web-Jarmark/Web-Jarmark.csproj +++ b/Web-Jarmark/Web-Jarmark/Web-Jarmark.csproj @@ -1,4 +1,4 @@ - + net10.0 diff --git a/Web-Jarmark/Web-Jarmark/jarmark.db-shm b/Web-Jarmark/Web-Jarmark/jarmark.db-shm index fe9ac28..e400789 100644 Binary files a/Web-Jarmark/Web-Jarmark/jarmark.db-shm and b/Web-Jarmark/Web-Jarmark/jarmark.db-shm differ diff --git a/Web-Jarmark/Web-Jarmark/jarmark.db-wal b/Web-Jarmark/Web-Jarmark/jarmark.db-wal index e69de29..90cd3d2 100644 Binary files a/Web-Jarmark/Web-Jarmark/jarmark.db-wal and b/Web-Jarmark/Web-Jarmark/jarmark.db-wal differ diff --git a/Web-Jarmark/Web-Jarmark/wwwroot/app.css b/Web-Jarmark/Web-Jarmark/wwwroot/app.css index dcd556b..3632c0a 100644 --- a/Web-Jarmark/Web-Jarmark/wwwroot/app.css +++ b/Web-Jarmark/Web-Jarmark/wwwroot/app.css @@ -334,3 +334,27 @@ h1:focus { font-size: 23px; } } + +.product-cart-button { + width: 100%; + margin-top: 15px; + padding: 12px; + border: none; + border-radius: 7px; + background: #07833e; + color: white; + font-size: 14px; + font-weight: bold; + cursor: pointer; + transition: .2s; +} + + .product-cart-button:hover:not(:disabled) { + background: #056b32; + transform: translateY(-2px); + } + + .product-cart-button:disabled { + background: #aab3bd; + cursor: not-allowed; + }