<MudStack class="pb-20 font-iranyekan">
    <BasePartDivider Index="2" Title="تاریخچه بیماری فعلی ( PI )" />

    <MudAlert Severity="Severity.Info">شما میتوانید سوال های هر بخش ها را به صورت کامل تنظیم نمایید</MudAlert>

    @foreach (var item in Questions)
    {
        <MedicalHistoryQuestionTemplateItemTemplate QuestionRemoved="RemoveQuestion" />
    }

    <MudSelect @bind-Value="@_questionType" T="MedicalHistoryQuestionType" Label="نوع سوال" Variant="Variant.Outlined">

        <MudSelectItem Value="@MedicalHistoryQuestionType.Hourly" />
        <MudSelectItem Value="@MedicalHistoryQuestionType.Interrogatively" />
        <MudSelectItem Value="@MedicalHistoryQuestionType.YesOrNo" />
    </MudSelect>
    <MudTextField @bind-Value="@_questionTitle" Margin="Margin.None" T="string" Label="عنوان سوال" Lines="1"
        Variant="Variant.Outlined" />
    <MudAutocomplete T="string" Label="وابستگی به سوال قبلی" Variant="Variant.Outlined" />

    <MudButton @onclick="AddQuestion" Variant="Variant.Filled" IconSize="Size.Large" DisableElevation="true"
        class="font-extrabold text-lg rounded-md py-4 bg-[--color-medicalhistory] text-gray-800">
        + افزودن
    </MudButton>

</MudStack>


@code
{
    private MedicalHistoryQuestionType _questionType;
    private string EnumConvertFunc() => string.Empty;
    private string _questionTitle = string.Empty;


    public List<MedicalHistoryQuestion> Questions { get; set; } = new();

    private void RemoveQuestion(MedicalHistoryQuestion question)
    {
        Questions.Remove(question);
    }
    private void AddQuestion()
    {
        Questions.Add(new MedicalHistoryQuestion
            {
                Title = _questionTitle,
                Type = _questionType
            });
    }
}