Skip to content

Commit

Permalink
fix: re-wrap the error component
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie authored Aug 15, 2024
1 parent 069207d commit 68f879e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions components/toasts/toasts.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package toasts

import (
"github.com/gofiber/fiber/v2"
htmx "github.com/zeiss/fiber-htmx"
"github.com/zeiss/fiber-htmx/components/buttons"
"github.com/zeiss/pkg/errorx"
Expand Down Expand Up @@ -29,11 +30,15 @@ func Toast(p ToastProps, children ...htmx.Node) htmx.Node {
}

// Error is a component for the htmx toast extension.
func Error(props ToastsProps, err error) htmx.Node {
func Error(c *fiber.Ctx, err error) htmx.Node {
if !errorx.Empty(err) {
htmx.ReSwap(c, "none")
}

return htmx.If(
!errorx.Empty(err),
Toasts(
props,
ToastsProps{},
ToastAlertError(
ToastProps{},
htmx.Text(err.Error()),
Expand Down

0 comments on commit 68f879e

Please sign in to comment.