using Microsoft.AspNetCore.Components.Authorization;
using Sandbox.Models.ViewModels;

namespace Sandbox.App.Services.AuthService;

public class AuthService : IAuthService
{
    private readonly HttpClient _http;
    //private readonly AuthenticationStateProvider _authenticationStateProvider;

    // public AuthService(HttpClient httpClient, AuthenticationStateProvider authenticationStateProvider)
    public AuthService(HttpClient httpClient)
    {
        _http = httpClient;
        //_authenticationStateProvider = authenticationStateProvider;
    }

    public async Task<ServiceResponse<int>> Register(UserRegister request)
    {
        var result = await _http.PostAsJsonAsync("api/auth/register", request);
        return await result.Content.ReadFromJsonAsync<ServiceResponse<int>>();
    }

    // public async Task<ServiceResponse<string>> Login(UserLogin request)
    // {
    //     var result = await _http.PostAsJsonAsync("api/auth/login", request);
    //     return await result.Content.ReadFromJsonAsync<ServiceResponse<string>>();
    // }
    //
    // public async Task<ServiceResponse<bool>> ChangePassword(UserChangePassword request)
    // {
    //     var result = await _http.PostAsJsonAsync("api/auth/change-password", request.Password);
    //     return await result.Content.ReadFromJsonAsync<ServiceResponse<bool>>();
    // }

    // public async Task<bool> IsUserAuthenticated()
    // {
    //     return (await _authenticationStateProvider.GetAuthenticationStateAsync()).User.Identity.IsAuthenticated;
    // }
}