using JSMR.Application.Tags.Queries.Search; using JSMR.Application.VoiceWorks.Queries.Search; using JSMR.UI.Blazor; using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using Microsoft.AspNetCore.Mvc; using MudBlazor.Services; using System.Net.Http.Json; var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add("#app"); builder.RootComponents.Add("head::after"); var apiBase = builder.Configuration["ApiBaseUrl"] ?? builder.HostEnvironment.BaseAddress; apiBase = "https://localhost:7277"; Console.WriteLine(apiBase); builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(apiBase) }); builder.Services.AddMudServices(); builder.Services.AddScoped(); await builder.Build().RunAsync(); public class VoiceWorksClient(HttpClient http) { public async Task SearchAsync(SearchVoiceWorksRequest request, CancellationToken ct = default) { using var resp = await http.PostAsJsonAsync("/api/voiceworks/search", request, ct); return await resp.Content.ReadFromJsonAsync(cancellationToken: ct); } public async Task SearchAsync(SearchTagsRequest request, CancellationToken ct = default) { using var resp = await http.PostAsJsonAsync("/api/tags/search", request, ct); return await resp.Content.ReadFromJsonAsync(cancellationToken: ct); } } public record VoiceWorkDto(string ProductId, string ProductName); // Tiny helper result type public readonly record struct Result(bool Ok, T? Value, string? Error) { public static Result Success(T v) => new(true, v, null); public static Result Failure(string e) => new(false, default, e); }