This commit is contained in:
2025-10-27 17:39:18 -04:00
commit 31f723bea4
1579 changed files with 642409 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
using System.Net.Http.Json;
using Prefab.Web.Client.Models.Shared;
using Prefab.Web.Client.Pages;
namespace Prefab.Web.Client.Services;
public interface ICategoriesPageService
{
Task<Result<CategoriesPageModel>> GetPage(CancellationToken cancellationToken);
}
public sealed class CategoriesPageService(HttpClient httpClient) : ICategoriesPageService
{
public async Task<Result<CategoriesPageModel>> GetPage(CancellationToken cancellationToken)
{
using var response = await httpClient.GetAsync("bff/categories/page", cancellationToken);
var result = await response.Content.ReadFromJsonAsync<Result<CategoriesPageModel>>(cancellationToken);
if (result is not null)
{
return result;
}
var exception = new InvalidOperationException($"Response {(int)response.StatusCode} did not contain a valid payload.");
var unexpectedProblem = ResultProblem.Unexpected("Failed to retrieve categories.", exception, response.StatusCode);
return Result<CategoriesPageModel>.Failure(unexpectedProblem);
}
}