diff --git a/internal/handlers/dashboard.go b/internal/handlers/dashboard.go index 50838cf..895e321 100644 --- a/internal/handlers/dashboard.go +++ b/internal/handlers/dashboard.go @@ -111,8 +111,8 @@ func (h *DashboardHandler) RestoreSystemCollection(c echo.Context) error { userUUID := uuid.UUID(user.ID.Bytes) var req struct { - CollectionName string `json:"collection_name"` - ResetType string `json:"reset_type"` // "full" or "keep_books" + CollectionName string `form:"collection_name" json:"collection_name"` + ResetType string `form:"reset_type" json:"reset_type"` } if err := c.Bind(&req); err != nil { @@ -146,6 +146,11 @@ func (h *DashboardHandler) RestoreSystemCollection(c echo.Context) error { return c.JSON(http.StatusInternalServerError, map[string]string{"error": "Failed to restore system collection"}) } + // Add redirect header for HTMX requests + if c.Request().Header.Get("HX-Request") == "true" { + c.Response().Header().Set("HX-Redirect", "/collections") + } + return c.JSON(http.StatusOK, map[string]string{"message": "System collection restored to defaults"}) }