Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sales module sections and pages to Boilerplate (#9678) #9706

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@
"modifiers": [
{
"copyOnly": [
"**/HomePage.razor",
"**/*.svg",
"**/*.png",
"**/*.sh"
Expand Down Expand Up @@ -424,15 +423,25 @@
"condition": "(module != Admin)",
"exclude": [
"src/Shared/Dtos/Dashboard/**",
"src/Server/Boilerplate.Server.Api/Controllers/Products/**",
"src/Server/Boilerplate.Server.Api/Controllers/Dashboard/**",
"src/Server/Boilerplate.Server.Api/Controllers/Categories/**",
"src/Server/Boilerplate.Server.Api/Controllers/Products/ProductController.cs",
"src/Shared/Controllers/Dashboard/**",
"src/Shared/Controllers/Categories/**",
"src/Shared/Controllers/Products/IProductController.cs",
"src/Client/Boilerplate.Client.Core/Components/Pages/Authorized/Dashboard/**",
"src/Client/Boilerplate.Client.Core/Components/Pages/Authorized/Categories/**",
"src/Client/Boilerplate.Client.Core/Components/Pages/Authorized/Products/**"
]
},
{
"condition": "(module != Sales)",
"exclude": [
"src/Server/Boilerplate.Server.Api/Controllers/Products/ProductViewController.cs",
"src/Shared/Controllers/Products/IProductViewController.cs",
"src/Client/Boilerplate.Client.Core/Components/Pages/ProductPage.*"
]
},
{
"condition": "(module != Admin && module != Sales)",
"exclude": [
Expand All @@ -443,9 +452,7 @@
"src/Server/Boilerplate.Server.Api/Mappers/CategoriesMapper.cs",
"src/Server/Boilerplate.Server.Api/Mappers/ProductsMapper.cs",
"src/Server/Boilerplate.Server.Api/Models/Categories/**",
"src/Server/Boilerplate.Server.Api/Models/Products/**",
"src/Shared/Controllers/Categories/**",
"src/Shared/Controllers/Products/**"
"src/Server/Boilerplate.Server.Api/Models/Products/**"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
}
else if (isAuthenticated is true)
{
<BitNavPanel @bind-IsOpen="isNavPanelOpen" Items="navPanelItems" />
<BitNavPanel @bind-IsOpen="isNavPanelOpen"
Items="navPanelItems"
IconUrl="_content/Boilerplate.Client.Core/images/bit-logo.svg" />
}

<div class="stack">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
@attribute [Route(Urls.HomePage)]
@*+:cnd:noEmit*@
@attribute [Route(Urls.HomePage)]
@attribute [Route("{culture:nonfile?}" + Urls.HomePage)]
@attribute [AppResponseCache(SharedMaxAge = 3600 * 24)]
@inherits AppPageBase

<PageTitle>@Localizer[nameof(AppStrings.HomePageTitle)]</PageTitle>

<section>
<BitStack Alignment="BitAlignment.Center" Gap="2rem" Class="stack">
<BitStack Alignment="BitAlignment.Center" Gap="2rem" Class="root-stack">
<BitText Typography="BitTypography.H4" Align="BitTextAlign.Center">
@Localizer[nameof(AppStrings.HomePanelTitle)]
<br />
Expand All @@ -16,9 +17,56 @@
<BitText Typography="BitTypography.H6" Align="BitTextAlign.Center">
@Localizer[nameof(AppStrings.HomeMessage)]
</BitText>

<br />

@*#if (module == "Sales")*@
@if (carouselProducts is not null)
{
<BitCard FullWidth>
<BitCarousel Class="carousel" AutoPlay AutoPlayInterval="5000" HideNextPrev InfiniteScrolling>
@foreach (var product in carouselProducts)
{
<BitCarouselItem>
<BitStack Horizontal Class="carousel-stack">
<ProductImage Src="@GetProductImageUrl(product)" Width="50%" />
<BitStack AutoHeight>
<BitLink Href="@($"/product/{product.Id}")" NoUnderline>
<BitText Typography="BitTypography.H1">@product.Name</BitText>
</BitLink>
<BitText Typography="BitTypography.H6" Class="carousel-desc">@product.Description</BitText>
<BitText Typography="BitTypography.H4">@product.Price.ToString("C")</BitText>

</BitStack>
</BitStack>
</BitCarouselItem>
}
</BitCarousel>
</BitCard>
}
<br />
<BitInfiniteScrolling ItemsProvider="LoadProducts" Class="products-inf-scr" ScrollerSelector="body" LastElementHeight="96px">
<ItemTemplate Context="product">
<BitLink Href="@($"/product/{product.Id}")" NoUnderline Class="product-item">
<BitCard FullSize>
<BitStack Class="product-stack">
<ProductImage Src="@GetProductImageUrl(product)" Width="100%" />
<BitText>@product.Name</BitText>
<BitText Typography="BitTypography.Body2">@product.Description</BitText>
<BitText Typography="BitTypography.H6">@product.Price.ToString("C")</BitText>
</BitStack>
</BitCard>
</BitLink>
</ItemTemplate>
<LoadingTemplate>
<BitStack Alignment="BitAlignment.Center">
<BitEllipsisLoading />
</BitStack>
</LoadingTemplate>
</BitInfiniteScrolling>
@*#endif*@

@*#if (module != "Sales")*@
<CascadingValue Value="BitDir.Ltr">
<BitCard FullWidth Style="padding:2rem">
<BitStack>
Expand Down Expand Up @@ -78,11 +126,13 @@
</BitStack>
<BitStack Horizontal>
<BitText>Repo:</BitText>
@*-:cnd:noEmit*@
<BitLink Target="_blank"
Href="https://github.com/bitfoundation/bitplatform/tree/develop/src/Templates/Boilerplate">
<BitImage Alt="bitplatform GitHub stars"
Src="https://img.shields.io/github/stars/bitfoundation/bitplatform?style=social&label=Github%20%E2%9C%A8" />
</BitLink>
@*+:cnd:noEmit*@
</BitStack>
</BitStack>
}
Expand All @@ -96,6 +146,7 @@
</BitCard>
</CascadingValue>
<br />
@*#endif*@

<BitCard FullWidth Style="padding:4rem">
<BitStack HorizontalAlign="BitAlignment.Center">
Expand All @@ -113,7 +164,7 @@
</BitStack>
</BitCard>

<BitStack Horizontal Gap="2rem" Class="products-stack">
<BitStack Horizontal Gap="2rem" Class="bit-products-stack">
<BitCard Style="padding:3rem" FullWidth>
<BitStack HorizontalAlign="BitAlignment.Center">
<BitText Typography="BitTypography.H5">bit BlazorUI</BitText>
Expand Down Expand Up @@ -150,5 +201,6 @@
</BitStack>
</BitCard>
</BitStack>
@*#endif*@
</BitStack>
</section>
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using Boilerplate.Shared.Controllers.Statistics;
//+:cnd:noEmit
using Boilerplate.Shared.Dtos.Products;
using Boilerplate.Shared.Dtos.Statistics;
using Boilerplate.Shared.Controllers.Products;
using Boilerplate.Shared.Controllers.Statistics;

namespace Boilerplate.Client.Core.Components.Pages;

Expand All @@ -8,19 +11,29 @@ public partial class HomePage
protected override string? Title => Localizer[nameof(AppStrings.Home)];
protected override string? Subtitle => string.Empty;


[CascadingParameter] private BitDir? currentDir { get; set; }

[AutoInject] private IStatisticsController statisticsController = default!;

//#if(module != "Sales")
[AutoInject] private IStatisticsController statisticsController = default!;
private bool isLoadingGitHub = true;
private bool isLoadingNuget = true;
private GitHubStats? gitHubStats;
private NugetStatsDto? nugetStats;
//#endif

//#if(module == "Sales")
[AutoInject] private IProductViewController productViewController = default!;
private IEnumerable<ProductDto>? carouselProducts;
//#endif


protected override async Task OnInitAsync()
{
await base.OnInitAsync();

//#if(module != "Sales")
// If required, you should typically manage the authorization header for external APIs in **AuthDelegatingHandler.cs**
// and handle error extraction from failed responses in **ExceptionDelegatingHandler.cs**.

Expand All @@ -31,8 +44,16 @@ protected override async Task OnInitAsync()
// effectively addresses most scenarios.

await Task.WhenAll(LoadNuget(), LoadGitHub());
//#endif

//#if(module == "Sales")
carouselProducts = (await PrerenderStateService.GetValue(() => HttpClient.GetFromJsonAsync("api/ProductView/GetHomeCarouselProducts",
JsonSerializerOptions.GetTypeInfo<List<ProductDto>>(),
CurrentCancellationToken)))!;
//#endif
}

//#if(module != "Sales")
private async Task LoadNuget()
{
try
Expand Down Expand Up @@ -68,4 +89,16 @@ private async Task LoadGitHub()
await InvokeAsync(StateHasChanged);
}
}
//#endif

//#if(module == "Sales")
private async ValueTask<IEnumerable<ProductDto>> LoadProducts(BitInfiniteScrollingItemsProviderRequest request)
{
productViewController.AddQueryString(new ODataQuery { Top = 10, Skip = request.Skip });

return await productViewController.Get(CurrentCancellationToken);
}

private string? GetProductImageUrl(ProductDto product) => product.GetProductImageUrl(AbsoluteServerAddress);
//#endif
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import '../../Styles/abstracts/_media-queries.scss';
//+:cnd:noEmit
@import '../../Styles/abstracts/_media-queries.scss';

section {
width: 100%;
Expand All @@ -7,11 +8,53 @@ section {
}

::deep {
.stack {
.root-stack {
max-width: 60rem;
}
//#if(module == "Sales")

.products-stack {
.carousel {
height: 350px;

@include lt-sm {
height: 500px;
}
}

.carousel-stack {
display: flex !important;

@include lt-sm {
flex-direction: column !important;

.carousel-desc {
overflow: hidden;
max-height: 60px;
}
}
}

.products-inf-scr {
gap: 1rem;
display: flex;
flex-wrap: wrap;
position: relative;
}

.product-item {
width: calc(25% - 0.75rem);

@include lt-md {
width: calc(33% - 0.67rem);
}

@include lt-sm {
width: calc(50% - 0.5rem);
}
}
//#endif

.bit-products-stack {
@include lt-sm {
flex-wrap: wrap;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<BitImage Src="@(Src ?? "_content/Boilerplate.Client.Core/images/product-placeholder.png")" Width="@Width" />

@code {
[Parameter] public string? Src { get; set; }
[Parameter] public string? Width { get; set; }
}
Loading
Loading