improved toggle publish company category feedback
This commit is contained in:
@@ -184,11 +184,10 @@ func (h *Handler) Search(c echo.Context) error {
|
|||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param id path string true "Category ID"
|
// @Param id path string true "Category ID"
|
||||||
// @Success 200 {object} response.APIResponse "Category publish status updated successfully"
|
// @Success 200 {object} response.APIResponse{data=map[string]bool} "Company category published/unpublished successfully"
|
||||||
// @Failure 400 {object} response.APIResponse "Bad request - Invalid input data"
|
// @Failure 400 {object} response.APIResponse "Bad request - Invalid category ID"
|
||||||
// @Failure 404 {object} response.APIResponse "Not found - Category not found"
|
// @Failure 404 {object} response.APIResponse "Not found - Company category not found"
|
||||||
// @Failure 422 {object} response.APIResponse "Validation error - Invalid request data"
|
// @Failure 500 {object} response.APIResponse "Internal server error - Failed to update published status"
|
||||||
// @Failure 500 {object} response.APIResponse "Internal server error"
|
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Router /admin/v1/company-categories/{id}/publish [patch]
|
// @Router /admin/v1/company-categories/{id}/publish [patch]
|
||||||
func (h *Handler) TogglePublish(c echo.Context) error {
|
func (h *Handler) TogglePublish(c echo.Context) error {
|
||||||
@@ -197,17 +196,25 @@ func (h *Handler) TogglePublish(c echo.Context) error {
|
|||||||
published, err := h.service.TogglePublish(c.Request().Context(), id)
|
published, err := h.service.TogglePublish(c.Request().Context(), id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err.Error() == "category not found" {
|
if err.Error() == "category not found" {
|
||||||
return response.NotFound(c, "Category not found")
|
return response.NotFound(c, "Company category not found")
|
||||||
}
|
}
|
||||||
return response.InternalServerError(c, "Failed to toggle category publish status")
|
h.logger.Error("Failed to update Company category published status", map[string]interface{}{
|
||||||
|
"error": err.Error(),
|
||||||
|
"category_id": id,
|
||||||
|
})
|
||||||
|
return response.InternalServerError(c, "Failed to update Company category published status. Please try again or contact support if the problem persists.")
|
||||||
|
}
|
||||||
|
|
||||||
|
message := "Company category unpublished successfully"
|
||||||
|
if published {
|
||||||
|
message = "Company category published successfully"
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.Success(
|
return response.Success(
|
||||||
c,
|
c,
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"message": "Category publish status updated successfully",
|
|
||||||
"published": published,
|
"published": published,
|
||||||
},
|
},
|
||||||
"Category publish status updated successfully",
|
message,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user