@page "/"

@inherits ProductsBase

@if (Products == null)
{
    <DisplaySpinner />
}
else
{
    //<h3 class="mb-5">Products</h3>

    var productCount = Products.Count();

    @if (productCount > 0)
    {
        @foreach (var prodGroup in GetGroupedProductsByCategory())
        {
            <div class="row mt-3">
                <h4>@prodGroup.FirstOrDefault(pg=>pg.CategoryId == prodGroup.Key).CategoryName</h4>
                <DisplayProducts Products="@prodGroup.Take(4)"></DisplayProducts>
            </div>
            <hr class="mb-3" />
        }
    }

}
