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



    <DataAnnotationsValidator />


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


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



    </div>
    <ValidationMessage For="@(() => regModel.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 RegistrationModel regModel { get; set; }

        [Parameter]
        public EventCallback<RegistrationModel> RegModelChanged { get; set; }

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

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

        private string spinnerClass = "";

        public async Task SubmitRegistration()
        {

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

        await RegModelChanged.InvokeAsync(regModel);
        await onSubmit.InvokeAsync();
        }

    private async Task GoToPreviousStep()
    {

        await onPrev.InvokeAsync();
    }
}

