@using Moonlight.App.Services.Users
@using Moonlight.App.Services

@inject UserService UserService
@inject IdentityService IdentityService

<div class="w-100">
    <div class="card-body">
        @if (HasBeenSend)
        {
            <div class="text-start mb-8">
                <h1 class="text-dark mb-3 fs-3x">
                    Email verification sent
                </h1>
                <div class="text-gray-400 fw-semibold fs-6">
                    You should receive an email shortly. If you see no email in your inbox, look inside your spam folder
                </div>
            </div>
        }
        else
        {
            <div class="text-start mb-8">
                <h1 class="text-dark mb-3 fs-3x">
                    Verify your email address
                </h1>
                <div class="text-gray-400 fw-semibold fs-6">
                    We will sent you an email to verify your account
                </div>
            </div>
        
            <WButton OnClick="Send" Text="Continue" CssClasses="btn btn-primary me-2 flex-shrink-0" />
        }
    </div>
</div>

@code
{
    private bool HasBeenSend = false;

    private async Task Send()
    {
        await UserService.Auth.SendVerification(IdentityService.CurrentUser);
        HasBeenSend = true;
        await InvokeAsync(StateHasChanged);
    }
}
