219 lines
7.9 KiB
Plaintext
219 lines
7.9 KiB
Plaintext
@using BlazorAnimation
|
|
@using TIAM.Core.Enums
|
|
@using TIAM.Entities.Addresses
|
|
@using TIAM.Entities.Products
|
|
@using TIAM.Entities.Profiles
|
|
@using TIAM.Entities.ServiceProviders
|
|
@using TIAM.Entities.Transfers
|
|
@using TIAM.Entities.Users
|
|
@using TIAM.Models.Dtos.Users
|
|
@using TIAM.Services
|
|
@using TIAMSharedUI.Shared.Components.Cards
|
|
@using TIAMWebApp.Shared.Application.Interfaces
|
|
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI
|
|
@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;
|
|
|
|
<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" />
|
|
</a>
|
|
</div>
|
|
|
|
<div class="e-info flex-grow-1 ms-3">
|
|
<div class="e-name">@($"{Context.Name}")</div>
|
|
<p class="e-title"><i class="fa-solid fa-at"></i> @Context.Profile.EmailAddress</p>
|
|
<p class="e-title"><i class="fa-solid fa-location-dot"></i> @Context.Profile.Address.AddressText</p>
|
|
</div>
|
|
</div>
|
|
|
|
<hr class="hr" />
|
|
|
|
<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>
|
|
|
|
<div class="col-12 col-md-9">
|
|
<h4>Affiliate information</h4>
|
|
@{
|
|
if (Context.ServiceProviderId != null)
|
|
{
|
|
var _url = $"{Setting.BaseUrl}/public/transfer/{Context.ServiceProvider.AffiliateId}/{Context.Id}";
|
|
<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">
|
|
<div class="row py-3">
|
|
<div class="col-4">
|
|
@{
|
|
if (Context.ProductType == TIAM.Core.Enums.ProductType.Hotel)
|
|
{
|
|
string url = $"user/hoteladmin/{Context.Id}";
|
|
<DxButton class="btn-primary" Click="() => NavManager.NavigateTo(url)">Manage</DxButton>
|
|
}
|
|
else if (Context.ProductType == TIAM.Core.Enums.ProductType.Transfer)
|
|
{
|
|
string url = $"user/transferadmin/{Context.Id}";
|
|
<DxButton class="btn btn-primary" Click="() => NavManager.NavigateTo(url)">Manage</DxButton>
|
|
}
|
|
}
|
|
</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>
|
|
</div>
|
|
<p>@msg</p>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function copyToClipboard(text) {
|
|
navigator.clipboard.writeText(text).then(function () {
|
|
console.log('Copied to clipboard successfully!');
|
|
}, function (err) {
|
|
alert('Could not copy text: ' + err);
|
|
});
|
|
}
|
|
</script>
|
|
|
|
@code {
|
|
[Parameter] public Product Context { get; set; }
|
|
|
|
[Parameter] public EventCallback<string> DataChanged { get; set; }
|
|
|
|
public string ImageSource { get; set; } = "";
|
|
AccordionExpandMode ExpandMode { get; set; } = AccordionExpandMode.SingleOrNone;
|
|
AccordionExpandCollapseAction ExpandCollapseAction { get; set; } = AccordionExpandCollapseAction.HeaderClick;
|
|
|
|
private Profile productProfile = new Profile();
|
|
private List<TransferDestination> destinations = [];
|
|
string msg;
|
|
private bool isSaveActive = false;
|
|
private bool isAddressTransferDestination = false;
|
|
|
|
private async Task CopyUrl(string url)
|
|
{
|
|
|
|
await JsRuntime.InvokeVoidAsync("copyToClipboard", url);
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
var productOwner = await AdminSignalRClient.GetByIdAsync<List<Company>>(SignalRTags.GetCompaniesById, Context.ServiceProviderId);
|
|
var ProductProfiles = await AdminSignalRClient.GetByIdAsync<List<Profile>>(SignalRTags.GetProfileById, Context.ProfileId);
|
|
await AdminSignalRClient.GetAllIntoAsync<TransferDestination>(destinations, SignalRTags.GetAllTransferDestinations);
|
|
if (productOwner != null)
|
|
{
|
|
ImageSource = await ServiceProviderDataService.GetQRCodeByProductIdAndOwnerAffiliateIdAsync(new Guid[] { productOwner[0].AffiliateId, Context.Id });
|
|
}
|
|
if (ProductProfiles != null)
|
|
{
|
|
productProfile = ProductProfiles[0];
|
|
var AddressId = productProfile.AddressId;
|
|
isAddressTransferDestination = CheckDestinations(AddressId);
|
|
}
|
|
|
|
await base.OnInitializedAsync();
|
|
}
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
|
|
await base.OnParametersSetAsync();
|
|
}
|
|
|
|
RenderFragment RenderDetailsItem(string iconCssClass, string caption, string value)
|
|
{
|
|
return @<div class="d-flex m-1 align-items-center">
|
|
<div class="icon-container flex-shrink-0">
|
|
<span class="dxbl-image m-1 @iconCssClass"></span>
|
|
</div>
|
|
<div class="text-container m-1 flex-grow-1 ms-2">
|
|
<label>@caption:</label>
|
|
<div>@value</div>
|
|
</div>
|
|
</div>;
|
|
}
|
|
|
|
private bool CheckDestinations(Guid addressId)
|
|
{
|
|
|
|
|
|
if (destinations != null)
|
|
{
|
|
if (destinations.Any(d => d.AddressId == addressId))
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
private async Task SaveAsDestination(Address address, Product product)
|
|
{
|
|
TransferDestination transferDestination = new TransferDestination();
|
|
transferDestination.Id = Guid.NewGuid();
|
|
transferDestination.Name = product.Name;
|
|
if (!string.IsNullOrEmpty(product.Profile.Description))
|
|
{
|
|
transferDestination.Description = product.Profile.Description;
|
|
}
|
|
else
|
|
{
|
|
transferDestination.Description = "No description available";
|
|
}
|
|
transferDestination.AddressId = address.Id;
|
|
transferDestination.AddressString = address.AddressText;
|
|
var result = await AdminSignalRClient.PostDataAsync<TransferDestination>(SignalRTags.CreateTransferDestination, transferDestination);
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
}
|