using DbFirst.Contracts.Dashboards;

namespace DbFirst.BlazorWebApp.Services;

public class DashboardApiClient : IDashboardApiClient
{
    private readonly HttpClient _httpClient;
    private const string Endpoint = "api/dashboard/dashboards";

    public DashboardApiClient(HttpClient httpClient)
    {
        _httpClient = httpClient;
    }

    public async Task<List<DashboardInfoDto>> GetAllAsync(CancellationToken ct = default)
    {
        var result = await _httpClient.GetFromJsonAsync<List<DashboardInfoDto>>(Endpoint, ct);
        return result ?? [];
    }
}
