126 lines
4.8 KiB
Plaintext
126 lines
4.8 KiB
Plaintext
@page "/profile/subscriptions"
|
|
@using Moonlight.App.Services
|
|
@using Moonlight.Shared.Components.Navigations
|
|
@using Moonlight.App.Database.Entities
|
|
@using Moonlight.App.Helpers
|
|
|
|
@inject SubscriptionService SubscriptionService
|
|
@inject SmartTranslateService SmartTranslateService
|
|
@inject NavigationManager NavigationManager
|
|
|
|
<ProfileNavigation Index="1"/>
|
|
|
|
<LazyLoader @ref="LazyLoader" Load="Load">
|
|
<div class="card mb-5 mb-xl-10">
|
|
<div class="card-body">
|
|
@if (User.Subscription != null)
|
|
{
|
|
<div class="row">
|
|
<div class="col-lg-7">
|
|
<h3 class="mb-2">
|
|
<TL>Active until</TL> @(Formatter.FormatDate(User.SubscriptionSince!.Value.AddDays(User.SubscriptionDuration)))
|
|
</h3>
|
|
<p class="fs-6 text-gray-600 fw-semibold mb-6 mb-lg-15">
|
|
<TL>We will send you a notification upon subscription expiration</TL>
|
|
</p>
|
|
</div>
|
|
<div class="col-lg-5">
|
|
<div class="d-flex justify-content-end pb-0 px-0">
|
|
<WButton Text="@(SmartTranslateService.Translate("Cancel Subscription"))"
|
|
WorkingText="@(SmartTranslateService.Translate("Working"))"
|
|
CssClasses="btn-danger btn-active-light-danger me-2"
|
|
OnClick="Cancel">
|
|
</WButton>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
else
|
|
{
|
|
<div class="row g-3">
|
|
<div class="col-auto">
|
|
<input @bind="Code" type="text" class="form-control">
|
|
</div>
|
|
<div class="col-auto">
|
|
<WButton Text="@(SmartTranslateService.Translate("Apply"))"
|
|
WorkingText="@(SmartTranslateService.Translate("Applying code"))"
|
|
CssClasses="btn-success"
|
|
OnClick="ApplyCode">
|
|
</WButton>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mt-5 row gx-9 gy-6">
|
|
@if (Available.Any())
|
|
{
|
|
@foreach (var sub in Available)
|
|
{
|
|
<div class="col-xl-6">
|
|
<div class="card card-dashed h-xl-100 flex-row flex-stack flex-wrap p-6">
|
|
<div class="d-flex flex-column py-2">
|
|
<div class="d-flex align-items-center fs-4 fw-bold mb-5">
|
|
@(sub.Name)
|
|
</div>
|
|
<div class="d-flex align-items-center">
|
|
<div class="fs-6 fw-semibold">@(sub.Description)</div>
|
|
</div>
|
|
</div>
|
|
<div class="d-flex align-items-center py-2">
|
|
<WButton Text="@(SmartTranslateService.Translate("Buy"))"
|
|
WorkingText="@(SmartTranslateService.Translate("Redirecting"))"
|
|
CssClasses="btn-primary"
|
|
OnClick="() => Buy(sub)">
|
|
</WButton>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
}
|
|
else
|
|
{
|
|
<div class="alert alert-primary">
|
|
<TL>No subscription available</TL>
|
|
</div>
|
|
}
|
|
</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
</LazyLoader>
|
|
|
|
@code
|
|
{
|
|
[CascadingParameter]
|
|
public User User { get; set; }
|
|
|
|
private Subscription? Subscription;
|
|
private Subscription[] Available;
|
|
|
|
private string Code = "";
|
|
|
|
private LazyLoader LazyLoader;
|
|
|
|
private async Task Load(LazyLoader lazyLoader)
|
|
{
|
|
Subscription = await SubscriptionService.Get();
|
|
Available = await SubscriptionService.GetAvailable();
|
|
}
|
|
|
|
private async Task Cancel()
|
|
{
|
|
await SubscriptionService.Cancel();
|
|
}
|
|
|
|
private async Task Buy(Subscription subscription)
|
|
{
|
|
var url = await SubscriptionService.GenerateBuyUrl(subscription);
|
|
|
|
NavigationManager.NavigateTo(url);
|
|
}
|
|
|
|
private async Task ApplyCode()
|
|
{
|
|
await SubscriptionService.ApplyCode(Code);
|
|
await LazyLoader.Reload();
|
|
}
|
|
} |