zmena barvz do kosiku
This commit is contained in:
@@ -20,8 +20,6 @@ else if (product == null)
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
{
|
||||
<div class="detail-container">
|
||||
<a href="/katalog" class="back-link">← Zpět do katalogu</a>
|
||||
|
||||
@@ -56,9 +54,7 @@ else
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<button class="detail-cart-button"
|
||||
<button class="product-cart-button"
|
||||
disabled="@(product.StockQuantity <= 0)"
|
||||
@onclick="() => HandleAddToCart(product)">
|
||||
🛒 Přidat do košíku
|
||||
@@ -67,7 +63,6 @@ else
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
@code {
|
||||
@@ -76,6 +71,20 @@ else
|
||||
|
||||
private Product? product;
|
||||
private bool loading = true;
|
||||
private string? cartToken;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (!ApplicationState.TryTakeFromJson<string>(
|
||||
"CartToken", out cartToken)
|
||||
|| string.IsNullOrWhiteSpace(cartToken))
|
||||
{
|
||||
var context = HttpContextAccessor.HttpContext;
|
||||
|
||||
cartToken = context?.Items["CartToken"] as string
|
||||
?? context?.Request.Cookies["CartToken"];
|
||||
}
|
||||
}
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
@@ -87,23 +96,9 @@ else
|
||||
|
||||
loading = false;
|
||||
}
|
||||
private string? cartToken;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (!ApplicationState.TryTakeFromJson<string>(
|
||||
"CartToken", out cartToken)
|
||||
|| string.IsNullOrWhiteSpace(cartToken))
|
||||
private async Task HandleAddToCart(Product product)
|
||||
{
|
||||
var context = HttpContextAccessor.HttpContext;
|
||||
|
||||
cartToken = context?.Items["CartToken"] as string
|
||||
?? context?.Request.Cookies["CartToken"];
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandleAddToCart(Product product)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(cartToken))
|
||||
return;
|
||||
|
||||
@@ -147,5 +142,5 @@ private async Task HandleAddToCart(Product product)
|
||||
cart.UpdatedAt = DateTime.UtcNow;
|
||||
|
||||
await DbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user