Skip to content

Commit

Permalink
implemented ListSubscriptions page
Browse files Browse the repository at this point in the history
  • Loading branch information
suxrobGM committed Dec 2, 2023
1 parent a3961c9 commit 1f615d7
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Client/Logistics.AdminApp/Layout/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<RadzenPanelMenuItem Text="Tenants" Icon="business" Path="/tenants"/>
<RadzenPanelMenuItem Text="Subscriptions" Icon="subscriptions">
<RadzenPanelMenuItem Text="Plans" Icon="cases" Path="/subscription-plans"/>
<RadzenPanelMenuItem Text="Subscription customers" Icon="account_balance"/>
<RadzenPanelMenuItem Text="Subscription customers" Icon="account_balance" Path="/subscriptions"/>
</RadzenPanelMenuItem>
<RadzenPanelMenuItem Text="Users" Icon="group"/>
</RadzenPanelMenu>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<RadzenButton class="mb-3" Click="@(() => Navigation.NavigateTo("/tenants/add"))">Add</RadzenButton>

<RadzenGrid Data="_subscriptionPlans"
LoadData="LoadTenants"
LoadData="LoadData"
Count="_totalRecords"
AllowPaging="true"
AllowSorting="true"
Expand All @@ -26,7 +26,7 @@
Property="Price"
Title="Price">
<Template Context="subscriptionPlan">
<FinancialFormatter Value="subscriptionPlan.Price"/>
<CurrencyText Value="subscriptionPlan.Price"/>
</Template>
</RadzenGridColumn>
<RadzenGridColumn TItem="SubscriptionPlanDto" Title="Action">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public partial class ListSubscriptionPlans : PageBase

#endregion

private async void LoadTenants(LoadDataArgs e)

private async void LoadData(LoadDataArgs e)
{
var page = (e.Skip ?? 0) + 1;
var pageSize = e.Top ?? 10;
Expand All @@ -27,9 +28,4 @@ private async void LoadTenants(LoadDataArgs e)
_totalRecords = pagedData?.TotalItems ?? 0;
StateHasChanged();
}

private void OpenEditPage(SubscriptionPlanDto subscriptionPlan)
{
Navigation.NavigateTo($"subscription-plans/{subscriptionPlan.Id}");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
@page "/subscriptions"
@inherits PageBase

<RadzenText TextStyle="TextStyle.H3">Subscription Plans</RadzenText>
<hr/>

<RadzenButton class="mb-3" Click="@(() => Navigation.NavigateTo("/tenants/add"))">Add</RadzenButton>

<RadzenGrid Data="_subscriptions"
LoadData="LoadData"
Count="_totalRecords"
AllowPaging="true"
AllowSorting="true"
PageSizeOptions="new[] { 10, 25, 50 }"
PageSize="10">
<Columns>
<RadzenGridColumn TItem="SubscriptionDto"
Property="Tenant"
Title="Tenant">
<Template Context="subscription">
<RadzenText Text="@subscription.Tenant.Name" />
</Template>
</RadzenGridColumn>
<RadzenGridColumn TItem="SubscriptionDto"
Property="Tenant"
Title="Company">
<Template Context="subscription">
<RadzenText Text="@subscription.Tenant.CompanyName" />
</Template>
</RadzenGridColumn>
<RadzenGridColumn TItem="SubscriptionDto"
Property="Plan"
Title="Subscription Plan">
<Template Context="subscription">
<RadzenText Text="@subscription.Plan.Name" />
</Template>
</RadzenGridColumn>
<RadzenGridColumn TItem="SubscriptionDto"
Property="Status"
Title="Status">
</RadzenGridColumn>
<RadzenGridColumn TItem="SubscriptionDto"
Property="StartDate"
Title="Start Date">
</RadzenGridColumn>
<RadzenGridColumn TItem="SubscriptionDto"
Property="NextPaymentDate"
Title="Next Payment Date">
</RadzenGridColumn>
<RadzenGridColumn TItem="SubscriptionDto"
Property="TrialEndDate"
Title="Trial End Date">
</RadzenGridColumn>
<RadzenGridColumn TItem="SubscriptionDto"
Property="EndDate"
Title="End Date">
</RadzenGridColumn>
<RadzenGridColumn TItem="SubscriptionDto" Title="Action">
<Template Context="subscription">
<RadzenButton Click="@(() => Navigation.NavigateTo($"subscriptions/{subscription.Id}"))">Edit</RadzenButton>
</Template>
</RadzenGridColumn>
</Columns>
</RadzenGrid>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Logistics.Shared;
using Logistics.Shared.Models;
using Microsoft.AspNetCore.Components;
using Radzen;

namespace Logistics.AdminApp.Pages.Subscription;

public partial class ListSubscriptions : PageBase
{
private IEnumerable<SubscriptionDto>? _subscriptions;
private int _totalRecords = 10;


#region Injectable services

[Inject]
private NavigationManager Navigation { get; set; } = default!;

#endregion


private async void LoadData(LoadDataArgs e)
{
var page = (e.Skip ?? 0) + 1;
var pageSize = e.Top ?? 10;
var pagedData = await CallApiAsync(api => api.GetSubscriptionsAsync(new PagedQuery(page, pageSize)));
_subscriptions = pagedData?.Items;
_totalRecords = pagedData?.TotalItems ?? 0;
StateHasChanged();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Logistics.AdminApp.Shared;

public partial class FinancialFormatter
public partial class CurrencyText
{
private string FormattedValue => FormatValueAsCurrency(Value);

Expand Down

0 comments on commit 1f615d7

Please sign in to comment.