Add track detail page with clickable cards

This commit is contained in:
daniel-c-harvey
2026-06-06 16:33:57 -04:00
parent 1bb6e29e47
commit 0dd33a5dfc
6 changed files with 371 additions and 11 deletions
@@ -0,0 +1,45 @@
using DeepDrftModels.DTOs;
using DeepDrftPublic.Client.Services;
namespace DeepDrftPublic.Client.ViewModels;
public class TrackDetailViewModel
{
public ITrackDataService TrackData { get; }
public TrackDto? Track { get; set; }
public bool IsLoading { get; set; } = true;
public bool NotFound { get; set; }
public TrackDetailViewModel(ITrackDataService trackData)
{
TrackData = trackData;
}
public async Task Load(string entryKey)
{
// Idempotent across navigations: the scoped instance may be reused, so reset
// every flag before the fetch rather than relying on construction defaults.
IsLoading = true;
NotFound = false;
Track = null;
try
{
var result = await TrackData.GetTrack(entryKey);
if (result.Success && result.Value is not null)
{
Track = result.Value;
}
else
{
NotFound = true;
}
}
finally
{
IsLoading = false;
}
}
}