@page "/membership" @using LibraryManagement.Shared.Models @using BlazorWebAssembly.Services @inject LibraryApiClient ApiClient @inject NavigationManager Navigation @inject IJSRuntime JS

Pricing Plans

Choose Your
Journey.

From casual readers to devoted bookworms, we have a plan that perfectly matches your literary appetite.

@if (_isLoading) {
@for (int i = 0; i < 3; i++) {
}
} else { @if (_currentSub != null) {
@(_currentSub.MembershipType?[..1].ToUpper())

@_currentSub.MembershipType Plan

Active until @_currentSub.ExpiryDate.ToString("MMMM dd, yyyy")

Active Status Auto-renews monthly
}

Loyalty Points

@(_loyaltyAccount?.CurrentBalance.ToString("N0") ?? "0")

Wallet Balance

@_walletBalance.ToString("N0") MMK

@if (_queuedRewards.Any()) {

Queued Rewards

@foreach (var sub in _queuedRewards) {

@sub.MembershipType

Starts on @sub.StartDate.ToString("MMM dd, yyyy")

Approved

Queued in Pipeline

}
}
@foreach (var plan in _memberships) {
@if (plan.Price > 20 && !IsCurrentPlan(plan.Id)) {
Most Popular
} @if (IsCurrentPlan(plan.Id)) {
Your Current Plan
}

@plan.Type

@plan.Price.ToString("N0") mmk
/ @plan.DurationMonths mo
Borrow @plan.MaxBooks books
@plan.BorrowingDays Day period
Digital access included
Loyalty point multiplier
@if (!IsCurrentPlan(plan.Id)) { }
}

All plans include 24/7 support and access to our community events.

Secure Payment Cancel Anytime No Hidden Fees
}
@code { private bool _isLoading = true; private List _memberships = new(); private SubscriptionDto? _currentSub; private List _queuedRewards = new(); private decimal _walletBalance; private LoyaltyAccountDto? _loyaltyAccount; protected override async Task OnInitializedAsync() { await LoadData(); } private async Task LoadData() { _isLoading = true; try { _memberships = (await ApiClient.GetMembershipsAsync()).ToList(); _currentSub = await ApiClient.GetMySubscriptionAsync(); var allSubs = await ApiClient.GetMyAllSubscriptionsAsync(); _queuedRewards = allSubs .Where(s => !string.IsNullOrEmpty(s.ExternalRedemptionId) && s.StartDate > DateTime.UtcNow) .OrderBy(s => s.StartDate) .ToList(); _walletBalance = await ApiClient.GetWalletBalanceAsync(); _loyaltyAccount = await ApiClient.GetMyLoyaltyAccountAsync(); } catch { } finally { _isLoading = false; } } private bool IsCurrentPlan(int id) => _currentSub?.MembershipId == id; private async Task SubscribeAsync(MembershipDto plan) { bool confirmed = await JS.InvokeAsync("confirm", $"Are you sure you want to subscribe to {plan.Type} for {plan.Price:N0} mmk? Please pay the cash at the library counter to activate."); if (!confirmed) return; var result = await ApiClient.SubscribeAsync(new SubscribeRequest { MembershipId = plan.Id }); if (result != null) { await JS.InvokeVoidAsync("alert", "Request submitted! Please visit the librarian to pay and activate."); await LoadData(); } } private async Task BuyWithWallet(MembershipDto plan) { try { var preview = await ApiClient.GetUpgradePreviewAsync(plan.Id); if (preview == null || !preview.CanUpgrade) { await JS.InvokeVoidAsync("alert", preview?.Message ?? "Cannot upgrade to this plan."); return; } string confirmMsg = $"Purchase {plan.Type} membership?\n\n" + $"Price: {preview.OriginalPrice:N0} MMK\n"; if (preview.DiscountAmount > 0) { confirmMsg += $"Upgrade Discount: -{preview.DiscountAmount:N0} MMK\n"; } confirmMsg += $"Total: {preview.FinalPrice:N0} MMK\n\n" + $"Your Balance: {_walletBalance:N0} MMK"; bool confirmed = await JS.InvokeAsync("confirm", confirmMsg); if (!confirmed) return; if (_walletBalance < preview.FinalPrice) { await JS.InvokeVoidAsync("alert", "Insufficient wallet balance. Please top up at the library counter."); return; } var result = await ApiClient.SubscribeWithWalletAsync(new SubscribeRequest { MembershipId = plan.Id }); if (result != null) { await JS.InvokeVoidAsync("alert", "Subscription purchased successfully!"); await LoadData(); } else { await JS.InvokeVoidAsync("alert", "Failed to complete purchase."); } } catch (Exception ex) { await JS.InvokeVoidAsync("alert", "Error: " + ex.Message); } } }