@namespace OpenArchival.Blazor.AdminPages.Shared
@using MudBlazor

<MudCard Outlined="true">
    <MudCardContent>
        <MudTextField @bind-Value="FieldName"
                      @bind-Value:after="OnNameChanged"
                      Label="Field Name"
                      Variant="Variant.Filled"
                      Immediate="true" 
                      />

        <MudTextField @bind-Value="FieldDescription"
                      @bind-Value:after="OnDescriptionChanged"
                      Label="Field Description"
                      Variant="Variant.Filled"
                      Lines="2"
                      Class="mt-3"
                      Immediate="true" 
                      />
    </MudCardContent>
</MudCard>

@code {
    [Parameter] public int Index { get; set; }

    [Parameter] public string FieldName { get; set; } = "";
    [Parameter] public string FieldDescription { get; set; } = "";

    [Parameter] public EventCallback<(int Index, string NewValue)> OnNameUpdate { get; set; }
    [Parameter] public EventCallback<(int Index, string NewValue)> OnDescriptionUpdate { get; set; }

    private async Task OnNameChanged()
    {
        await OnNameUpdate.InvokeAsync((Index, FieldName));
    }

    private async Task OnDescriptionChanged()
    {
        await OnDescriptionUpdate.InvokeAsync((Index, FieldDescription));
    }
}