@using TIAMWebApp.Shared.Application.Models.PageModels;
<h3>Step 3: Password</h3>
<EditForm Model="@loginModel" OnValidSubmit="SubmitLogin">



    <DataAnnotationsValidator />


    <div class="form-field d-flex align-items-center">


        <DxTextBox @bind-Text="@loginModel.Password"
                   Id="Password"
                   Password="true"
                   CssClass="cw-320" />

    </div>
    <ValidationMessage For="@(() => loginModel.Password)" />

    <a class="btn btn-primary mt-3" @onclick="GoToPreviousStep">Previous</a>
    <button class="btn btn-primary mt-3" type="submit">
        <span class="@spinnerClass"></span>
        Next
    </button>

</EditForm>


@code {
    [Parameter]
    public LoginModel loginModel { get; set; }

    [Parameter]
    public EventCallback<LoginModel> LoginModelChanged { get; set; }

    [Parameter]
    public EventCallback<LoginModel> onPrev { get; set; }

    [Parameter]
    public EventCallback onSubmit { get; set; }

    private string spinnerClass = "";

    public async Task SubmitLogin()
    {

        spinnerClass = "spinner-border spinner-border-sm";
        await Task.Delay(500);
        spinnerClass = "";

        await LoginModelChanged.InvokeAsync(loginModel);
        await onSubmit.InvokeAsync();
    }

    private async Task GoToPreviousStep()
    {

        await onPrev.InvokeAsync();
    }
}

