@using MudBlazor

<MudDialog>
    <DialogContent>
        <MudText Typo="Typo.body1" Class="mb-3">@ContentText</MudText>
        <MudTextField @bind-Value="OtpCode"
                      Label="کد تأیید"
                      Variant="Variant.Outlined"
                      InputType="InputType.Text"
                      MaxLength="6"
                      Immediate="true"
                      Required="true"
                      RequiredError="کد تایید الزامی است"
                      FullWidth="true" />
    </DialogContent>
    <DialogActions>
        <MudButton Variant="Variant.Text" OnClick="Cancel">انصراف</MudButton>
        <MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="Submit" Disabled="string.IsNullOrWhiteSpace(OtpCode)">@ButtonText</MudButton>
    </DialogActions>
</MudDialog>

@code {
    [CascadingParameter]
    private IMudDialogInstance MudDialog { get; set; }

    [Parameter] public string ContentText { get; set; } = "";
    [Parameter] public string ButtonText { get; set; } = "تأیید";

    private string? OtpCode { get; set; }

    private void Cancel() => MudDialog.Cancel();

    private void Submit() => MudDialog.Close(DialogResult.Ok(OtpCode));
}

