@namespace QuantEngine.Web.Client.Components
@inject IDialogService DialogService

@code {
    public static async Task<bool> Show(IDialogService dialogService, string title, string message, string confirmText = "확인", string cancelText = "취소")
    {
        var options = new DialogOptions
        {
            CloseButton = false,
            MaxWidth = MaxWidth.Small,
            FullWidth = true,
            BackdropClick = false
        };

        var parameters = new DialogParameters<ConfirmDialog>
        {
            { x => x.Title, title },
            { x => x.Message, message },
            { x => x.ConfirmText, confirmText },
            { x => x.CancelText, cancelText }
        };

        var dialog = await dialogService.ShowAsync<ConfirmDialog>(title, parameters, options);
        var result = await dialog.Result;

        return !result.Canceled && (bool?)result.Data == true;
    }
}

<MudDialog>
    <DialogContent>
        <MudStack Spacing="2">
            <MudText Typo="Typo.h6">@Title</MudText>
            <MudText Typo="Typo.body2">@Message</MudText>
        </MudStack>
    </DialogContent>
    <DialogActions>
        <MudButton OnClick="Cancel" Color="Color.Default">@CancelText</MudButton>
        <MudButton OnClick="Confirm" Color="Color.Primary" Variant="Variant.Filled">@ConfirmText</MudButton>
    </DialogActions>
</MudDialog>

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

    [Parameter]
    public string Title { get; set; } = "확인";

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

    [Parameter]
    public string ConfirmText { get; set; } = "확인";

    [Parameter]
    public string CancelText { get; set; } = "취소";

    private void Confirm() => MudDialog.Close(DialogResult.Ok(true));
    private void Cancel() => MudDialog.Cancel();
}
