summaryrefslogtreecommitdiff
path: root/internal/handlers/shopping.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/handlers/shopping.go')
-rw-r--r--internal/handlers/shopping.go83
1 files changed, 0 insertions, 83 deletions
diff --git a/internal/handlers/shopping.go b/internal/handlers/shopping.go
index e8e80da..1c58126 100644
--- a/internal/handlers/shopping.go
+++ b/internal/handlers/shopping.go
@@ -73,47 +73,6 @@ func (h *Handler) HandleShoppingQuickAdd(w http.ResponseWriter, r *http.Request)
}{allStores, grouped})
}
-// HandleShoppingToggle toggles a shopping item's checked state
-func (h *Handler) HandleShoppingToggle(w http.ResponseWriter, r *http.Request) {
- if err := r.ParseForm(); err != nil {
- JSONError(w, http.StatusBadRequest, "Failed to parse form", err)
- return
- }
-
- id := r.FormValue("id")
- source := r.FormValue("source")
- checked := r.FormValue("checked") == "true"
-
- switch source {
- case "user":
- var userID int64
- if _, err := fmt.Sscanf(id, "user-%d", &userID); err != nil {
- JSONError(w, http.StatusBadRequest, "Invalid user item ID", err)
- return
- }
- if err := h.store.ToggleUserShoppingItem(userID, checked); err != nil {
- JSONError(w, http.StatusInternalServerError, "Failed to toggle item", err)
- return
- }
- case "trello", "plantoeat":
- // Store checked state locally for external sources
- if err := h.store.SetShoppingItemChecked(source, id, checked); err != nil {
- JSONError(w, http.StatusInternalServerError, "Failed to toggle item", err)
- return
- }
- default:
- JSONError(w, http.StatusBadRequest, "Unknown source", nil)
- return
- }
-
- // Return refreshed shopping tab
- stores := h.aggregateShoppingLists(r.Context())
- HTMLResponse(w, h.renderer, "shopping-tab", struct {
- Stores []models.ShoppingStore
- Grouped bool
- }{stores, true})
-}
-
// HandleShoppingMode renders the focused shopping mode for a single store
func (h *Handler) HandleShoppingMode(w http.ResponseWriter, r *http.Request) {
storeName := chi.URLParam(r, "store")
@@ -143,48 +102,6 @@ func (h *Handler) HandleShoppingMode(w http.ResponseWriter, r *http.Request) {
HTMLResponse(w, h.renderer, "shopping-mode.html", data)
}
-// HandleShoppingModeToggle toggles an item in shopping mode and returns updated list
-func (h *Handler) HandleShoppingModeToggle(w http.ResponseWriter, r *http.Request) {
- storeName := chi.URLParam(r, "store")
- if err := r.ParseForm(); err != nil {
- JSONError(w, http.StatusBadRequest, "Failed to parse form", err)
- return
- }
-
- id := r.FormValue("id")
- source := r.FormValue("source")
- checked := r.FormValue("checked") == "true"
-
- // Toggle the item
- switch source {
- case "user":
- var userID int64
- if _, err := fmt.Sscanf(id, "user-%d", &userID); err != nil {
- JSONError(w, http.StatusBadRequest, "Invalid user item ID", err)
- return
- }
- if err := h.store.ToggleUserShoppingItem(userID, checked); err != nil {
- JSONError(w, http.StatusInternalServerError, "Failed to toggle item", err)
- return
- }
- case "trello", "plantoeat":
- if err := h.store.SetShoppingItemChecked(source, id, checked); err != nil {
- JSONError(w, http.StatusInternalServerError, "Failed to toggle item", err)
- return
- }
- }
-
- // URL decode the store name
- storeName, _ = url.QueryUnescape(storeName)
-
- // Return updated item list partial
- allStores := h.aggregateShoppingLists(r.Context())
- HTMLResponse(w, h.renderer, "shopping-mode-items", struct {
- StoreName string
- Items []models.UnifiedShoppingItem
- }{storeName, models.FlattenItemsForStore(allStores, storeName)})
-}
-
// HandleShoppingModeComplete removes an item from the shopping list
func (h *Handler) HandleShoppingModeComplete(w http.ResponseWriter, r *http.Request) {
storeName := chi.URLParam(r, "store")