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



    <DataAnnotationsValidator />


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


        <DxMaskedInput @bind-Value="@auctionBidModel.BidAmount"
                       CssClass="cw-320"
                       Mask="@NumericMask.WholeNumber">
            <DxNumericMaskProperties Culture="@CultureInfo.GetCultureInfo("en-US")" />
        </DxMaskedInput>



    </div>
    <ValidationMessage For="@(() => auctionBidModel.BidAmount)" />

    <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 AuctionBidModel auctionBidModel { get; set; }

        [Parameter]
        public EventCallback<AuctionBidModel> AuctionBidModelChanged { get; set; }

        [Parameter]
        public EventCallback<string> 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 AuctionBidModelChanged.InvokeAsync(auctionBidModel);
        await onSubmit.InvokeAsync();
        }

    private async Task GoToPreviousStep()
    {

        await onPrev.InvokeAsync();
    }

    
    

    
}

