@using Models.GlobalInstances
@using System.Linq
@using Microsoft.AspNetCore.Components
@using Microsoft.JSInterop
@using ShoppingAssistantWebClient.Web.Pages
@inject NavigationManager Navigation
@inject IJSRuntime JSRuntime;
@inject IModalService Modal;
CARTAID
@code {
[Parameter] public string chatId { get; set; }
private string selectedWishlistId;
private static NavMenu _app;
public NavMenu ()
{
_app = this;
}
private async Task ShowModal()
{
var options = new ModalOptions()
{
DisableBackgroundCancel = true,
UseCustomLayout = true
};
var modalRef = Modal.Show("Settings", options);
}
[JSInvokable]
public static void Update(string wishlistId)
{
_app.LoadMenus(1,200);
_app.selectedWishlistId=wishlistId;
}
private void RedirectToPage(string itemId) {
_app.selectedWishlistId = itemId;
var url = $"/chat/{itemId}";
Navigation.NavigateTo(url);
}
private void RedirectToNewChat() {
var url = $"/";
Navigation.NavigateTo(url);
}
private void RedirectToCart(string itemId) {
var url = $"/cart/{itemId}";
Navigation.NavigateTo(url);
}
private async void DeleteWishlist(string itemId) {
var options = new ModalOptions
{
UseCustomLayout = true
};
var parameters = new ModalParameters();
var result = await Modal.Show("", parameters, options).Result;
if (!result.Cancelled)
await DeleteWish(itemId);
}
/*
private int savedScrollTop = 0;
private ElementReference wishlishtRef;
private async Task OnScroll()
{
var scrollTop = await JSRuntime.InvokeAsync("getScrollTop", wishlishtRef);
var offsetHeight = await JSRuntime.InvokeAsync("getOffsetHeight", wishlishtRef);
var scrollHeight = await JSRuntime.InvokeAsync("getScrollHeight", wishlishtRef);
if (scrollTop + offsetHeight > scrollHeight - 100)
{
savedScrollTop = scrollTop;
currentPage++;
await LoadMenus(currentPage, pageSize);
await InvokeAsync(() => JSRuntime.InvokeVoidAsync("setScrollTop", wishlishtRef, savedScrollTop));
}
}
*/
}