diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-08-24 06:20:52 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-08-24 06:20:52 +0000 |
| commit | 5c659d9046add8c77bd7699961a910505dcb4bc2 (patch) | |
| tree | 8bde9a62d98d2a21f030d4c6cbd3ceecb9a7adf8 /internal/handlers/shopping.go | |
| parent | c46c135f52090a082660cb06131282796f5cd592 (diff) | |
From the sitemap audit: /tabs/meals (same dead-tab pattern as the
removed /tabs/conditions, only reachable via ?tab=meals with no nav
button), /partials/lists (superseded by inline .Lists rendering in
trello-board.html), /shopping/toggle and /shopping/mode/{store}/toggle
(superseded by the one-way complete/filter model), plus the orphaned
trello-boards.html and error-banner.html templates that nothing
rendered or included. Rewrote the meals grouping test to exercise
groupMeals() directly since that logic is still live via the timeline.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GMEkHeqKz6FLkmizowBTK
Diffstat (limited to 'internal/handlers/shopping.go')
| -rw-r--r-- | internal/handlers/shopping.go | 83 |
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") |
