update
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
|
||||
@inject IJSRuntime JS
|
||||
@inject IDialogService DialogService
|
||||
@inject ISnackbar Snackbar
|
||||
@inject HttpClient Http
|
||||
|
||||
<MudMainContent Class="pa-0 ma-0">
|
||||
@@ -49,6 +48,7 @@
|
||||
<JsonOutputPanel @bind-OrderJson="@OrderJson"
|
||||
Copied="@copied"
|
||||
SendSuccess="@sendSuccess"
|
||||
CancelSuccess="@cancelSuccess"
|
||||
OnCopy="CopyJsonToClipboard"
|
||||
OnSend="SendOrderToServer"
|
||||
OnImport="OpenImportDialog"
|
||||
@@ -66,6 +66,7 @@
|
||||
private string OrderJson = ""; // 🔥 CACHE JSON (QUAN TRỌNG)
|
||||
private bool copied;
|
||||
private bool? sendSuccess;
|
||||
private bool? cancelSuccess;
|
||||
private CancellationTokenSource? _copyCts;
|
||||
|
||||
// ================= INIT =================
|
||||
@@ -247,35 +248,33 @@
|
||||
|
||||
async Task CancelOrder()
|
||||
{
|
||||
// reset trạng thái trước khi gửi
|
||||
cancelSuccess = null;
|
||||
StateHasChanged();
|
||||
|
||||
try
|
||||
{
|
||||
var res = await Http.PostAsync("/api/order/cancel", null);
|
||||
|
||||
sendSuccess = null; // reset trạng thái SEND
|
||||
copied = false;
|
||||
|
||||
if (res.IsSuccessStatusCode)
|
||||
{
|
||||
Snackbar.Add(
|
||||
"⛔ Order đã huỷ",
|
||||
Severity.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Add(
|
||||
"❌ Huỷ order thất bại",
|
||||
Severity.Error);
|
||||
}
|
||||
cancelSuccess = res.IsSuccessStatusCode;
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch
|
||||
{
|
||||
Snackbar.Add(
|
||||
$"❌ Lỗi: {ex.Message}",
|
||||
Severity.Error);
|
||||
cancelSuccess = false;
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
|
||||
// 🔥 AUTO RESET SAU 2 GIÂY
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(2000);
|
||||
cancelSuccess = null;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
async Task CopyJsonToClipboard()
|
||||
{
|
||||
_copyCts?.Cancel();
|
||||
|
||||
Reference in New Issue
Block a user