using Insight.Web.Constants;
using Insight.Web.Middleware;
using Microsoft.AspNetCore.Components;
using MudBlazor;

namespace Insight.Web.Pages.Account;

//[Route(Navigation.Account.LoginTFA)]
public partial class LoginTFA
{
    [Parameter] public Guid Key { get; set; }

    [Inject] private NavigationManager NavigationManager { get; init; } = default!;
    [Inject] private ISnackbar Snackbar { get; init; } = default!;

    private readonly string _title = "Login｜Insight";

    private void Submit(string? code)
    {
        if (string.IsNullOrWhiteSpace(code))
        {
            Notification.Information(Snackbar, "Enter Authenticator Code");
            return;
        }

        IdentityMiddleware.Logins[Key].TwoFactorToken = code;
        NavigationManager.NavigateTo(Navigation.Account.SignInTFAHref(Key), true);
    }
}