@page "/"
@inject ProductAPIConsumer productService
@inject CategoryAPIConsumer categoryService
@if (CarouselData != null && CarouselData.Any())
{
}
@Loc["Production_Lines"]
@foreach (var bundle in RandomBundles)
{
}
@Loc["Our_Categories"]
@foreach (var category in RandomCategories.Take(4))
{
}
@Loc["Our_Products"]
@foreach (var product in RandomProducts.Take(3))
{
}
@code {
List RandomProducts = new();
List RandomBundles = new();
List RandomCategories = new();
List<(string Text, string ImageUrl)> CarouselData = new();
protected override async Task OnInitializedAsync()
{
// Populate Carousel with Data
CarouselData = new List<(string Text, string ImageUrl)>
{
(Loc["Welcome_to_Our_Shop"], "https://img.daisyui.com/images/stock/photo-1507358522600-9f71e620c44e.webp"),
(Loc["Best_Quality_Products"], "https://img.daisyui.com/images/stock/photo-1559181567-c3190ca9959b.webp"),
(Loc["Amazing_Deals"], "https://img.daisyui.com/images/stock/photo-1601004890684-d8cbf643f5f2.webp")
};
RandomProducts = (await productService.FetchProduct(new ProductFilter { Random = true }, new Pagination()
{
PageSize = 3,
CurrentPage = 1
})).Item1;
// Fetch real bundles
var bundleResult = (await productService.FetchProduct(new ProductFilter { IsBundle = true, Random = true }, new
Pagination
{
PageSize = 4,
CurrentPage = 1
})).Item1;
RandomBundles = bundleResult;
RandomCategories = (await categoryService.FetchCategory(new CategoryFilter { Random = true }, new Pagination()
{
CurrentPage = 1,
PageSize = 4
})).Item1;
}
}