Updated delete logic for voice works.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user