Add WarningPermanent toast type and upgrade invoice failure notifications

Email delivery failures and PDF generation errors now show a permanent
warning/error toast that requires manual dismissal, so users cannot
accidentally miss critical action-blocking feedback.

- ToastHelper: WarningPermanent TempData key + Warning/WarningPermanent
  extension methods on both ITempDataDictionary and Controller
- SetNotificationResultToast: NotificationStatus.Failed now uses
  ToastWarningPermanent (previously auto-dismissed in 5 s)
- InvoicesController.Send: TempData["Warning"] → TempData["WarningPermanent"]
  when PDF generation or email dispatch fails
- InvoicesController.DownloadPdf: TempData["Error"] → TempData["ErrorPermanent"]
  with the actual exception message so root cause is visible
- _Layout.cshtml: WarningPermanent hidden div
- toast-notifications.js: WarningPermanent handler (timeOut: 0)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-27 16:02:16 -04:00
parent cad728ba66
commit 5631d1d57a
4 changed files with 35 additions and 4 deletions
+22 -1
View File
@@ -31,6 +31,9 @@ namespace PowderCoating.Web.Helpers
/// <summary>TempData key read by the layout to render a yellow warning toast.</summary>
private const string WarningKey = "Warning";
/// <summary>TempData key read by the layout to render a yellow warning toast that does not auto-dismiss.</summary>
private const string WarningPermanentKey = "WarningPermanent";
/// <summary>TempData key read by the layout to render a blue info toast.</summary>
private const string InfoKey = "Info";
@@ -67,6 +70,15 @@ namespace PowderCoating.Web.Helpers
tempData[WarningKey] = message;
}
/// <summary>
/// Stores a warning (yellow) toast that requires manual dismissal (no auto-timeout).
/// Use for critical warnings the user must not miss, such as email delivery failures.
/// </summary>
public static void WarningPermanent(this ITempDataDictionary tempData, string message)
{
tempData[WarningPermanentKey] = message;
}
/// <summary>
/// Stores an informational (blue) toast message in TempData for display on
/// the next page render after a redirect.
@@ -123,6 +135,15 @@ namespace PowderCoating.Web.Helpers
controller.TempData.Warning(message);
}
/// <summary>
/// Stores a permanent warning (yellow, no auto-dismiss) in the controller's TempData.
/// Use for failures the user must not miss — email delivery errors, PDF generation failures.
/// </summary>
public static void ToastWarningPermanent(this Controller controller, string message)
{
controller.TempData.WarningPermanent(message);
}
/// <summary>
/// Stores an informational (blue) toast in the controller's TempData.
/// Convenience wrapper around <see cref="ToastHelper.Info"/>.
@@ -165,7 +186,7 @@ namespace PowderCoating.Web.Helpers
: $"{channel} notification was skipped.");
break;
case NotificationStatus.Failed:
controller.ToastWarning(!string.IsNullOrEmpty(log.ErrorMessage)
controller.ToastWarningPermanent(!string.IsNullOrEmpty(log.ErrorMessage)
? $"{channel} delivery failed: {log.ErrorMessage}"
: $"{channel} notification failed.");
break;