@page "/wishlist" @using LibraryManagement.Shared.Models @using BlazorWebAssembly.Services @inject LibraryApiClient ApiClient @inject WishlistService WishlistService @inject NavigationManager Navigation @inject IJSRuntime JS

My Wishlist

A curated collection of books you're waiting for. We'll notify you as soon as they're back on the shelf.

@if (_isLoading) {
@for (int i = 0; i < 3; i++) {
}
} else if (!_wishlistItems.Any()) {

Your wishlist is empty

Found a book that's currently borrowed? Add it to your wishlist!

Go to Catalog
} else {
@foreach (var book in _wishlistItems) {
@if (!string.IsNullOrEmpty(book.CoverUrl)) { @book.Title } else { }

@book.Title

@book.Author

@(book.AvailableCopies > 0 ? "Available" : "Waiting")
}
}
@code { private bool _isLoading = true; private List _wishlistItems = new(); protected override async Task OnInitializedAsync() { await LoadData(); } private async Task LoadData() { _isLoading = true; try { _wishlistItems = await WishlistService.GetWishlistAsync(); } catch { } finally { _isLoading = false; } } private async Task RemoveFromWishlistAsync(int bookId) { await WishlistService.RemoveFromWishlistAsync(bookId); await LoadData(); await JS.InvokeVoidAsync("alert", "Removed from wishlist"); } }