using Microsoft.JSInterop;

namespace DiunaBI.UI.Shared.Services;

/// <summary>
/// Web implementation of Google authentication using JavaScript SDK
/// </summary>
public class WebGoogleAuthService : IGoogleAuthService
{
    private readonly IJSRuntime _jsRuntime;

    public WebGoogleAuthService(IJSRuntime jsRuntime)
    {
        _jsRuntime = jsRuntime;
    }

    public async Task<bool> SignInAsync()
    {
        try
        {
            await _jsRuntime.InvokeVoidAsync("requestGoogleSignIn");
            return true;
        }
        catch (Exception ex)
        {
            Console.WriteLine($"❌ Web Google Sign-In error: {ex.Message}");
            return false;
        }
    }
}
