history fix

This commit is contained in:
Adam 2024-08-05 14:17:18 +02:00
parent e0163353ef
commit a7e8831ff9
2 changed files with 27 additions and 34 deletions

View File

@ -14,23 +14,20 @@
@using TIAMWebApp.Shared.Application.Models.PageModels
@using TIAMWebApp.Shared.Application.Services
@inject IServiceProviderDataService ServiceProviderDataService
@inject IUserDataService UserDataService;
@inject AdminSignalRClient AdminSignalRClient;
@inject IJSRuntime JsRuntime;
@inject NavigationManager NavManager;
@inject IUserDataService UserDataService
@inject AdminSignalRClient AdminSignalRClient
@inject IJSRuntime JsRuntime
@inject NavigationManager NavManager
<div class="e-card cw-480">
<div class="e-main d-flex align-items-center">
@* <div class="flex-shrink-0">
<img class="e-photo" src="_content/TIAMSharedUI/images/defaultavatar_60.png" alt="" />
</div> *@
<div class="flex-shrink-0">
<a href="api/pictures/1" download="data:image/png;base64,@ImageSource" target="_top">
<img class="align-self-center img-fluid"
src="data:image/png;base64,@ImageSource" width="128" />
<img class="align-self-center img-fluid" src="data:image/png;base64,@ImageSource" width="128" />
</a>
<br />
<DxButton Context="ButtonContext" CssClass="btn-primary" Click="DownloadImage"><i class="fa-solid fa-download"></i> Download QR</DxButton>
</div>
<div class="e-info flex-grow-1 ms-3">
@ -45,7 +42,6 @@
<div class="row">
<div class="col-12 col-md-3">
<h4>Information</h4>
@RenderDetailsItem("fa-solid fa-user", "Contact Name", productProfile.FullName)
@RenderDetailsItem("fa-solid fa-circle-info", "Description", Context.Description)
</div>
@ -59,18 +55,12 @@
<p>Use this link to send it in an email to the client</p>
<a href="@_url" target="_blank">@_url</a>
<DxButton Context="ButtonContext" CssClass="btn-primary" Click="() => CopyUrl(_url)"><i class="fa-solid fa-copy"></i></DxButton>
// <DxButton CssClass="btn btn-primary" Click="() => CopyUrl(_url)">Copy referral url</DxButton>
}
}
</div>
<div class="col-12 col-md-6">
</div>
<div class="col-12 col-md-6"></div>
<div class="col-12">
<div class="row py-3">
<div class="col-4">
@ -89,15 +79,11 @@
</div>
<div class="col-4">
@{
if (!isAddressTransferDestination)
{
// <p>Address:</p>
// <p>@(((Product)context.DataItem).Profile.Address.AddressText)</p>
<DxButton Click="() => SaveAsDestination(productProfile.Address, Context)" Text="Save as destination" RenderStyle="ButtonRenderStyle.Primary" />
}
}
</div>
<div class="col-4"></div>
</div>
@ -114,6 +100,15 @@
alert('Could not copy text: ' + err);
});
}
function downloadImage(base64String, filename) {
const link = document.createElement('a');
link.href = base64String;
link.download = filename;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
</script>
@code {
@ -126,17 +121,21 @@
AccordionExpandCollapseAction ExpandCollapseAction { get; set; } = AccordionExpandCollapseAction.HeaderClick;
private Profile productProfile = new Profile();
private List<TransferDestination> destinations = [];
private List<TransferDestination> destinations = new List<TransferDestination>();
string msg;
private bool isSaveActive = false;
private bool isAddressTransferDestination = false;
private async Task CopyUrl(string url)
{
await JsRuntime.InvokeVoidAsync("copyToClipboard", url);
}
private async Task DownloadImage()
{
await JsRuntime.InvokeVoidAsync("downloadImage", $"data:image/png;base64,{ImageSource}", "QRCode.jpg");
}
protected override async Task OnInitializedAsync()
{
var productOwner = await AdminSignalRClient.GetByIdAsync<List<Company>>(SignalRTags.GetCompaniesById, Context.ServiceProviderId);
@ -158,7 +157,6 @@
protected override async Task OnParametersSetAsync()
{
await base.OnParametersSetAsync();
}
@ -177,8 +175,6 @@
private bool CheckDestinations(Guid addressId)
{
if (destinations != null)
{
if (destinations.Any(d => d.AddressId == addressId))
@ -194,7 +190,6 @@
{
return false;
}
}
private async Task SaveAsDestination(Address address, Product product)
@ -212,7 +207,7 @@
}
transferDestination.AddressId = address.Id;
transferDestination.AddressString = address.AddressText;
var result = await AdminSignalRClient.PostDataAsync<TransferDestination>(SignalRTags.CreateTransferDestination, transferDestination);
var result = await AdminSignalRClient.PostDataAsync<TransferDestination>(SignalRTags.CreateTransferDestination, transferDestination);
await InvokeAsync(StateHasChanged);
}
}

View File

@ -30,9 +30,7 @@ namespace TIAMSharedUI.Shared.Components.BaseComponents
{
base.OnInitialized();
_logger = new LoggerClient<UserBasePageComponent>(_logWriters.ToArray());
var currentUrl = _navManager.ToBaseRelativePath(_navManager.Uri);
_pageState.AddPageToHistory(currentUrl);
_logger.Debug(_pageState.GetGoBackPage());
}
}
}