Spaces:
Sleeping
Sleeping
Yuyuqt commited on
Commit ·
244fdfb
1
Parent(s): 1723ad3
add: thousand seperator, User balance
Browse files
Frontend/Controllers/BorrowingsController.cs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
using Frontend.Models.Dtos;
|
| 2 |
using Frontend.Services;
|
| 3 |
using Microsoft.AspNetCore.Authorization;
|
|
@@ -39,7 +40,15 @@ namespace Frontend.Controllers
|
|
| 39 |
public async Task<IActionResult> Rewards()
|
| 40 |
{
|
| 41 |
var rewards = await _apiClient.GetActiveRewardsAsync();
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
}
|
| 44 |
|
| 45 |
[Authorize(Roles = "Librarian")]
|
|
|
|
| 1 |
+
using Frontend.Models;
|
| 2 |
using Frontend.Models.Dtos;
|
| 3 |
using Frontend.Services;
|
| 4 |
using Microsoft.AspNetCore.Authorization;
|
|
|
|
| 40 |
public async Task<IActionResult> Rewards()
|
| 41 |
{
|
| 42 |
var rewards = await _apiClient.GetActiveRewardsAsync();
|
| 43 |
+
var account = await _apiClient.GetMyLoyaltyAccountAsync();
|
| 44 |
+
|
| 45 |
+
var viewModel = new RewardsViewModel
|
| 46 |
+
{
|
| 47 |
+
Rewards = rewards,
|
| 48 |
+
Account = account
|
| 49 |
+
};
|
| 50 |
+
|
| 51 |
+
return View(viewModel);
|
| 52 |
}
|
| 53 |
|
| 54 |
[Authorize(Roles = "Librarian")]
|
Frontend/Models/RewardsViewModel.cs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using Frontend.Models.Dtos;
|
| 2 |
+
|
| 3 |
+
namespace Frontend.Models
|
| 4 |
+
{
|
| 5 |
+
public class RewardsViewModel
|
| 6 |
+
{
|
| 7 |
+
public IEnumerable<LoyaltyRewardDto> Rewards { get; set; } = Enumerable.Empty<LoyaltyRewardDto>();
|
| 8 |
+
public LoyaltyAccountDto? Account { get; set; }
|
| 9 |
+
}
|
| 10 |
+
}
|
Frontend/Views/Borrowings/Rewards.cshtml
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
@model
|
| 2 |
@{
|
| 3 |
ViewData["Title"] = "Loyalty Rewards";
|
| 4 |
}
|
|
@@ -15,15 +15,14 @@
|
|
| 15 |
</div>
|
| 16 |
<div>
|
| 17 |
<p class="text-[10px] font-bold text-amber-600 uppercase tracking-widest mb-0.5">Your Balance</p>
|
| 18 |
-
|
| 19 |
-
<p class="text-2xl font-black text-slate-900">Points</p>
|
| 20 |
</div>
|
| 21 |
</div>
|
| 22 |
</div>
|
| 23 |
</div>
|
| 24 |
|
| 25 |
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
|
| 26 |
-
@if (!Model.Any())
|
| 27 |
{
|
| 28 |
<div class="col-span-full py-20 text-center bg-slate-50 rounded-3xl border-2 border-dashed border-slate-200">
|
| 29 |
<div class="text-slate-400 mb-4">
|
|
@@ -33,7 +32,7 @@
|
|
| 33 |
</div>
|
| 34 |
}
|
| 35 |
|
| 36 |
-
@foreach (var reward in Model)
|
| 37 |
{
|
| 38 |
<div class="group relative card p-6 hover:shadow-2xl hover:-translate-y-1 transition-all duration-300 border-t-4 border-amber-400">
|
| 39 |
<div class="flex justify-between items-start mb-6">
|
|
@@ -41,7 +40,7 @@
|
|
| 41 |
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 3v4M3 5h4M6 17v4m-2-2h4m5-16l2.286 6.857L21 12l-5.714 2.143L13 21l-2.286-6.857L5 12l5.714-2.143L13 3z"></path></svg>
|
| 42 |
</div>
|
| 43 |
<div class="text-right">
|
| 44 |
-
<span class="text-3xl font-black text-slate-900">@reward.PointCost</span>
|
| 45 |
<span class="text-[10px] block font-bold text-slate-400 uppercase tracking-tighter">Points Required</span>
|
| 46 |
</div>
|
| 47 |
</div>
|
|
|
|
| 1 |
+
@model Frontend.Models.RewardsViewModel
|
| 2 |
@{
|
| 3 |
ViewData["Title"] = "Loyalty Rewards";
|
| 4 |
}
|
|
|
|
| 15 |
</div>
|
| 16 |
<div>
|
| 17 |
<p class="text-[10px] font-bold text-amber-600 uppercase tracking-widest mb-0.5">Your Balance</p>
|
| 18 |
+
<p class="text-2xl font-black text-slate-900">@(Model.Account?.CurrentBalance.ToString("N0") ?? "0") Points</p>
|
|
|
|
| 19 |
</div>
|
| 20 |
</div>
|
| 21 |
</div>
|
| 22 |
</div>
|
| 23 |
|
| 24 |
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
|
| 25 |
+
@if (!Model.Rewards.Any())
|
| 26 |
{
|
| 27 |
<div class="col-span-full py-20 text-center bg-slate-50 rounded-3xl border-2 border-dashed border-slate-200">
|
| 28 |
<div class="text-slate-400 mb-4">
|
|
|
|
| 32 |
</div>
|
| 33 |
}
|
| 34 |
|
| 35 |
+
@foreach (var reward in Model.Rewards)
|
| 36 |
{
|
| 37 |
<div class="group relative card p-6 hover:shadow-2xl hover:-translate-y-1 transition-all duration-300 border-t-4 border-amber-400">
|
| 38 |
<div class="flex justify-between items-start mb-6">
|
|
|
|
| 40 |
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 3v4M3 5h4M6 17v4m-2-2h4m5-16l2.286 6.857L21 12l-5.714 2.143L13 21l-2.286-6.857L5 12l5.714-2.143L13 3z"></path></svg>
|
| 41 |
</div>
|
| 42 |
<div class="text-right">
|
| 43 |
+
<span class="text-3xl font-black text-slate-900">@reward.PointCost.ToString("N0")</span>
|
| 44 |
<span class="text-[10px] block font-bold text-slate-400 uppercase tracking-tighter">Points Required</span>
|
| 45 |
</div>
|
| 46 |
</div>
|