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