|
1 | 1 | @page "/" |
2 | 2 | @using MediatR |
3 | 3 | @using Microsoft.AspNetCore.Components.Authorization |
| 4 | +@using Microsoft.AspNetCore.Components.Forms |
4 | 5 | @using EstateManagementUI.BlazorServer.Permissions |
5 | 6 | @using EstateManagementUI.BlazorServer.Requests |
6 | 7 | @using EstateManagementUI.BlazorServer.Models |
|
108 | 109 | <!-- Comparison Date Selection (moved here) --> |
109 | 110 | <div class="flex items-center gap-4 bg-white p-4 rounded-lg shadow-admin"> |
110 | 111 | <label class="text-sm font-medium text-gray-700">Compare to:</label> |
111 | | - <select value="@SelectedComparisonDate" @onchange="HandleDateSelectionChanged" class="form-control max-w-xs"> |
| 112 | + <InputSelect @bind-Value="_selectedComparisonDate" @bind-Value:after="OnComparisonDateChanged" class="form-control max-w-xs"> |
112 | 113 | @if (comparisonDates != null) |
113 | 114 | { |
114 | 115 | @foreach (var date in comparisonDates) |
115 | 116 | { |
116 | 117 | <option value="@date.Date.ToString("yyyy-MM-dd")">@date.Description</option> |
117 | 118 | } |
118 | 119 | } |
119 | | - </select> |
| 120 | + </InputSelect> |
120 | 121 | </div> |
121 | 122 |
|
122 | 123 | <!-- Comparison Cards Row 2 - Sales Data --> |
|
220 | 221 | private List<MerchantModel>? recentMerchants; |
221 | 222 | private string _selectedComparisonDate = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd"); |
222 | 223 |
|
223 | | - |
224 | | - private string SelectedComparisonDate |
225 | | - { |
226 | | - get => _selectedComparisonDate; |
227 | | - set => _selectedComparisonDate = value; |
228 | | - } |
229 | | - |
230 | 224 | protected override async Task OnInitializedAsync() |
231 | 225 | { |
232 | 226 | var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); |
|
324 | 318 | StateHasChanged(); |
325 | 319 | } |
326 | 320 | } |
327 | | - private async Task HandleDateSelectionChanged(ChangeEventArgs e) |
| 321 | + private async Task OnComparisonDateChanged() |
328 | 322 | { |
329 | | - if (e.Value != null) |
| 323 | + // This is called after _selectedComparisonDate is updated by @bind-Value |
| 324 | + if (!isAdministrator) |
330 | 325 | { |
331 | | - _selectedComparisonDate = e.Value.ToString()!; |
332 | | - if (!isAdministrator) |
333 | | - { |
334 | | - await LoadDashboardData(); |
335 | | - StateHasChanged(); |
336 | | - } |
| 326 | + await LoadDashboardData(); |
| 327 | + StateHasChanged(); |
337 | 328 | } |
338 | 329 | } |
339 | 330 |
|
|
0 commit comments