Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions EstateManagementUI.BlazorServer/Components/Pages/Merchants/View.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
@rendermode InteractiveServer
@inject IMediator Mediator
@inject NavigationManager NavigationManager
@using EstateManagementUI.BlazorServer.Models
@using EstateManagementUI.BlazorServer.Requests

<PageTitle>View Merchant</PageTitle>

Expand Down Expand Up @@ -52,6 +54,9 @@
<button @onclick='() => activeTab = "transactions"' class="@GetTabClass("transactions")">
Transaction History
</button>
<button @onclick='() => activeTab = "settlements"' class="@GetTabClass("settlements")">
Settlement History
</button>
</nav>
</div>

Expand Down Expand Up @@ -226,6 +231,73 @@
<p class="text-gray-500 text-center py-8">Transaction history will be displayed here</p>
</div>
}
else if (activeTab == "settlements")
{
<div class="space-y-4">
<h3 class="text-lg font-semibold mb-4">Settlement History</h3>

@if (loadingSettlements)
{
<div class="flex items-center justify-center py-8">
<div class="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"></div>
</div>
}
else if (settlements != null && settlements.Any())
{
<div class="mb-4 grid grid-cols-1 md:grid-cols-3 gap-4">
<div class="p-4 bg-blue-50 rounded-lg">
<p class="text-sm text-blue-600">Total Settlements</p>
<p class="text-2xl font-bold text-blue-900">@settlements.Count</p>
</div>
<div class="p-4 bg-green-50 rounded-lg">
<p class="text-sm text-green-600">Total Transactions</p>
<p class="text-2xl font-bold text-green-900">@settlements.Sum(s => s.TransactionCount).ToString("N0")</p>
</div>
<div class="p-4 bg-purple-50 rounded-lg">
<p class="text-sm text-purple-600">Total Paid</p>
<p class="text-2xl font-bold text-purple-900">@settlements.Sum(s => s.NetAmountPaid).ToString("C")</p>
</div>
</div>

<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Date</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Reference</th>
<th class="px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase">Transactions</th>
<th class="px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase">Amount</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
@foreach (var settlement in settlements.Take(10))
{
<tr class="hover:bg-gray-50">
<td class="px-4 py-3 text-sm text-gray-900">@settlement.SettlementDate.ToString("MMM dd, yyyy")</td>
<td class="px-4 py-3 text-sm font-mono text-gray-900">@settlement.SettlementReference</td>
<td class="px-4 py-3 text-sm text-gray-900 text-right">@settlement.TransactionCount.ToString("N0")</td>
<td class="px-4 py-3 text-sm text-gray-900 text-right font-semibold">@settlement.NetAmountPaid.ToString("C")</td>
</tr>
}
</tbody>
</table>
</div>

@if (settlements.Count > 10)
{
<div class="text-center mt-4">
<a href="/reporting/merchant-settlement-history" class="text-blue-600 hover:text-blue-800 text-sm font-medium">
View all @settlements.Count settlements →
</a>
</div>
}
}
else
{
<p class="text-gray-500 text-center py-8">No settlement history available</p>
}
</div>
}
</div>
</div>
}
Expand All @@ -250,11 +322,24 @@
private List<OperatorModel> assignedOperators = new();
private List<ContractModel> assignedContracts = new();
private List<string> assignedDevices = new();

// Settlement history data
private List<MerchantSettlementHistoryModel>? settlements;
private bool loadingSettlements = false;

protected override async Task OnInitializedAsync()
{
await LoadMerchant();
}

protected override async Task OnParametersSetAsync()
{
// Load settlements when the settlements tab is active
if (activeTab == "settlements" && settlements == null)
{
await LoadSettlements();
}
}

private async Task LoadMerchant()
{
Expand Down Expand Up @@ -299,6 +384,38 @@
isLoading = false;
}
}

private async Task LoadSettlements()
{
loadingSettlements = true;
try
{
var estateId = Guid.Parse("11111111-1111-1111-1111-111111111111"); // Test estate ID
var query = new Queries.GetMerchantSettlementHistoryQuery(
CorrelationIdHelper.New(),
"test-token",
estateId,
MerchantId,
DateTime.Today.AddMonths(-6),
DateTime.Today
);

var result = await Mediator.Send(query);
if (result.IsSuccess)
{
settlements = result.Data;
}
}
catch (Exception)
{
// Handle error silently for now
settlements = new List<MerchantSettlementHistoryModel>();
}
finally
{
loadingSettlements = false;
}
}

private string GetTabClass(string tab)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@
</svg>
</div>
</a>
<a href="/reporting/merchant-settlement-history" class="block p-3 bg-gray-50 rounded-lg hover:bg-gray-100 transition-colors">
<div class="flex items-center justify-between">
<span class="font-medium text-gray-900">Merchant Settlement History</span>
<svg class="w-5 h-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path>
</svg>
</div>
</a>
</div>
</div>
</div>
Expand Down
Loading