Updated delete logic for voice works.
All checks were successful
ci / build-test (push) Successful in 3m1s
ci / publish-image (push) Successful in 1m58s

This commit is contained in:
2026-05-09 00:51:10 -04:00
parent 9c9e33ebec
commit 5eecba7eec
10 changed files with 124 additions and 16 deletions

View File

@@ -1,4 +1,5 @@
@using AntDesign
@using JSMR.Application.VoiceWorks.Commands.Delete
@using JSMR.Application.VoiceWorks.Commands.SetFavorite
@using JSMR.Application.VoiceWorks.Queries.Search
@using JSMR.Domain.Enums
@@ -136,6 +137,9 @@
[Parameter]
public required VoiceWorkSearchResult Product { get; set; }
[Parameter]
public EventCallback ProductDeleted { get; set; }
private string GetCardClasses(VoiceWorkSearchResult voiceWork)
{
List<string> classNames = ["j-card", "j-voice-work-card"];
@@ -240,7 +244,38 @@
{
Title = "Are you sure you want to delete the following product?",
Icon = icon,
Content = Product.ProductName
Content = Product.ProductName,
Centered = true,
OnOk = async (e) =>
{
DeleteVoiceWorkRequest request = new(
VoiceWorkIds: [Product.VoiceWorkId]
);
try
{
DeleteVoiceWorkResponse? response = await Client.DeleteVoiceWorkAsync(request);
if (response is null || response.Results[Product.VoiceWorkId] != DeleteVoiceWorkStatus.Deleted)
return;
await ProductDeleted.InvokeAsync();
}
catch (Exception ex)
{
AntDesign.ConfirmOptions errorOptions = new()
{
Title = "Unable to delete product",
Content = "Something went wrong while deleting this product. The product was not deleted. Check the API logs for details.",
Centered = true,
//Width = "70vw",
};
await ModalService.ErrorAsync(errorOptions);
e.Cancel = true;
}
}
};
await ModalService.ConfirmAsync(options);

View File

@@ -13,7 +13,7 @@ else
<div class="j-product-items-container">
@foreach (var product in Products)
{
<JProduct Product="@product"></JProduct>
<JProduct Product="@product" ProductDeleted="OnProductDeleted"></JProduct>
}
</div>
}
@@ -21,4 +21,12 @@ else
@code {
[Parameter]
public VoiceWorkSearchResult[]? Products { get; set; }
[Parameter]
public EventCallback ProductDeleted { get; set; }
private async Task OnProductDeleted()
{
await ProductDeleted.InvokeAsync();
}
}