@using BTCPayServer.Abstractions
@using BTCPayServer.Controllers
@using BTCPayServer.Plugins.PointOfSale.Controllers
@using Microsoft.AspNetCore.Mvc
@using Microsoft.AspNetCore.Routing
@using Microsoft.Extensions.Localization
@inject LinkGenerator LinkGenerator
@inject IStringLocalizer StringLocalizer
@if (UserEmails?.Any() is true)
{
}
@code {
[Parameter] public Dictionary UserEmails { get; set; }
[Parameter] public string BaseUrl { get; set; }
[Parameter] public string AppId { get; set; }
[Parameter(CaptureUnmatchedValues = true)]
public Dictionary Attrs { get; set; }
private string CssClass => $"form-group {(Attrs?.ContainsKey("class") is true ? Attrs["class"] : "")}".Trim();
string _qr = null;
string _posUrlAbsolute = null;
string _posPath = null;
protected override void OnParametersSet()
{
_posPath = LinkGenerator.GetPathByAction(
action: nameof(UIPointOfSaleController.ViewPointOfSale),
controller: "UIPointOfSale",
values: new { appId = AppId },
pathBase: RequestBaseUrl.FromUrl(BaseUrl).PathBase);
_posUrlAbsolute = LinkGenerator.GetUriByAction(
action: nameof(UIPointOfSaleController.ViewPointOfSale),
controller: "UIPointOfSale",
values: new { appId = AppId },
RequestBaseUrl.FromUrl(BaseUrl)
);
_qr = _posUrlAbsolute;
}
private void OnUserChanged(ChangeEventArgs e)
{
if (string.IsNullOrWhiteSpace(e.Value as string))
{
_qr = _posUrlAbsolute;
}
else
{
var loginUrl = LinkGenerator.GetUriByAction(
action: nameof(UIAccountController.Login),
controller: "UIAccount",
values: new { returnUrl = _posPath, email = (string)e.Value },
RequestBaseUrl.FromUrl(BaseUrl)
);
_qr = loginUrl;
}
}
}