50 lines
1.4 KiB
Plaintext
50 lines
1.4 KiB
Plaintext
@inject HttpClient Client
|
|
@inject ISnackbar Snackbar
|
|
|
|
<MudDialog>
|
|
<TitleContent>
|
|
<MudText Typo="Typo.h6">
|
|
<MudIcon Icon="@Icons.Material.Filled.DeleteForever" Class="mr-3 mb-n1"/>
|
|
Delete card?
|
|
</MudText>
|
|
</TitleContent>
|
|
<DialogContent>
|
|
<MudText>
|
|
Do you really want to delete the card?
|
|
All the related data will also be deleted and this process cannot be undone!
|
|
</MudText>
|
|
</DialogContent>
|
|
<DialogActions>
|
|
<MudButton OnClick="Cancel">Cancel</MudButton>
|
|
<MudButton Color="Color.Error" OnClick="DeleteCard">
|
|
<MudText>Delete Card</MudText>
|
|
</MudButton>
|
|
</DialogActions>
|
|
</MudDialog>
|
|
|
|
@code {
|
|
|
|
[CascadingParameter]
|
|
MudDialogInstance MudDialog { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public User User { get; set; } = new();
|
|
|
|
private void Cancel() => MudDialog.Cancel();
|
|
|
|
private async Task DeleteCard()
|
|
{
|
|
var responseMessage = await Client.DeleteAsync($"api/Cards/{User.AccessCode}");
|
|
|
|
if (!responseMessage.IsSuccessStatusCode)
|
|
{
|
|
Snackbar.Add("Something went wrong when deleting card!", Severity.Error);
|
|
MudDialog.Close(DialogResult.Ok(false));
|
|
return;
|
|
}
|
|
|
|
Snackbar.Add("Delete success!", Severity.Success);
|
|
MudDialog.Close(DialogResult.Ok(true));
|
|
}
|
|
|
|
} |