@page "/units"
@using ZeroSpace.Model
@using ZeroSpace.Web.Services
@using Telerik.Blazor
@using Telerik.Blazor.Components
@inject IUnitsApiClient UnitsApiClient
Units
@if (isLoading)
{
}
else if (errorMessage != null)
{
Error: @errorMessage
}
else if (gearNotes == null || gearNotes.Count == 0)
{
No units found.
}
else
{
}
@code {
private List? gearNotes;
private bool isLoading = true;
private string? errorMessage;
protected override async Task OnInitializedAsync()
{
await LoadUnitsAsync();
}
private async Task LoadUnitsAsync()
{
isLoading = true;
errorMessage = null;
try
{
var units = await UnitsApiClient.GetUnitsAsync();
gearNotes = units.ToList();
}
catch (Exception ex)
{
errorMessage = $"Failed to load units: {ex.Message}";
}
finally
{
isLoading = false;
}
}
}