@page "/Subscriptions"
@using Microsoft.AspNetCore.Authorization;
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
@using MyRecipes2.Shared;
@attribute [Authorize];
@inject HttpClient Http;
@inject AuthenticationStateProvider AuthenticationStateProvider;
@inject NavigationManager NavManager;
@using MyRecipes2.Client.Services;
@inject UtilityService UtilityService;
<h1>Subscriptions</h1>
@if (recipes == null)
{
<p><em>Loading...</em></p>
}
else
{
<div class="row">
@foreach (var recipe in recipes)
{
<RecipeDisplayCard recipe="recipe"></RecipeDisplayCard>
}
</div>
}
@code{
List<RecipeDto> recipes;
protected override async Task OnInitializedAsync()
{
string userId = await UtilityService.GetUserId();
recipes = await Http.GetFromJsonAsync<List<RecipeDto>>("Subscription/GetSubscriptions/" + userId);
}
protected void ClickView(RecipeDto recipe)
{
NavManager.NavigateTo($"ViewRecipe/{recipe.Id}");
}
}