Refactor currency handling and UI updates

Updated currency handling to use dynamic symbols, defaulting to "€". Adjusted UI components to reflect these changes. Introduced `GetCurrencySymbol` and `NormalizeCurrencySymbol` methods for consistency. Reintroduced QR code parsing/serialization methods. Updated models and services to align with the new currency symbol logic.
This commit is contained in:
Arne Moerman
2026-05-19 22:05:10 +02:00
parent 89c439f80b
commit 9f3ae1051c
6 changed files with 96 additions and 70 deletions
@@ -103,7 +103,7 @@ else
<InputNumber class="form-control" @bind-Value="ItemModel.PriceAmount" />
</div>
<div class="col-md-2">
<label class="form-label">Currency</label>
<label class="form-label">Currency symbol</label>
<InputText class="form-control" @bind-Value="ItemModel.CurrencyCode" />
</div>
<div class="col-md-2">
@@ -304,7 +304,7 @@ else
<InputDate class="form-control" @bind-Value="SettingsModel.BirthDate" />
</div>
<div class="col-md-2">
<label class="form-label">Currency</label>
<label class="form-label">Currency symbol</label>
<InputText class="form-control" @bind-Value="SettingsModel.CurrencyCode" />
</div>
<div class="col-md-3">
@@ -21,11 +21,11 @@ else
<div class="card p-3">
@if (RepresentableAmounts.Count == 0)
{
<p class="text-muted mb-0">No representable amount can be formed from configured QR codes up to 200.</p>
<p class="text-muted mb-0">No representable amount can be formed from configured QR codes up to @GetCurrencySymbol()200.</p>
}
else
{
<label class="form-label">Select amount: @SelectedAmount</label>
<label class="form-label">Select amount: @GetCurrencySymbol()@SelectedAmount</label>
<input type="range"
class="form-range"
min="0"
@@ -45,7 +45,7 @@ else
<ul class="mb-3">
@foreach (var suggestion in Suggestions)
{
<li>@suggestion.RepeatCount x @suggestion.Amount</li>
<li>@suggestion.RepeatCount x @GetCurrencySymbol()@suggestion.Amount</li>
}
</ul>
@@ -55,7 +55,7 @@ else
@for (var i = 0; i < suggestion.RepeatCount; i++)
{
<div>
<div class="small mb-1">@suggestion.Amount</div>
<div class="small mb-1">@GetCurrencySymbol()@suggestion.Amount</div>
<img src="@BuildQrImageUrl(suggestion.QrCodeUrl)" alt="QR code @suggestion.Amount" class="img-fluid" style="max-height: 220px;" />
<div class="small text-muted text-break">
<a href="@suggestion.QrCodeUrl" target="_blank" rel="noopener noreferrer">Open payment link</a>
@@ -207,4 +207,11 @@ public partial class RegistryContributionAmount : ComponentBase
public string QrCodeUrl { get; init; } = string.Empty;
public int RepeatCount { get; init; }
}
protected string GetCurrencySymbol()
{
return string.IsNullOrWhiteSpace(Registry?.CurrencyCode)
? "€"
: Registry.CurrencyCode;
}
}
@@ -87,7 +87,18 @@ else
}
@if (item.ParticipationAllowed && GetParticipationTotalAmount(item).HasValue)
{
<p class="mb-2"><strong>Participation:</strong> €@item.MoneyFulfilledAmount.ToString("0.00") out of €@GetParticipationTotalAmount(item)!.Value.ToString("0.00") fulfilled</p>
<p class="mb-2">
<strong>Participation:</strong>
@item.CurrencyCode@item.MoneyFulfilledAmount.ToString("0.00")
@if (GetParticipationTotalAmount(item)!.Value > 0)
{
<span> out of @item.CurrencyCode@GetParticipationTotalAmount(item)!.Value.ToString("0.00") fulfilled</span>
}
else
{
<span> fulfilled</span>
}
</p>
}
@if (item.Purchasers.Count > 0 || item.Contributors.Count > 0)