berrypod/lib/berrypod_web/live/shop/pages/cart.ex
jamey bb5d220079
All checks were successful
deploy / deploy (push) Successful in 1m27s
consolidate shop pages into unified LiveView for editor state persistence
Replace individual shop LiveViews with a single Shop.Page that dispatches
to page modules based on live_action. This enables patch navigation between
pages, preserving socket state (including editor state) across transitions.

Changes:
- Add Shop.Page unified LiveView with handle_params dispatch
- Extract page logic into Shop.Pages.* modules (Home, Product, Collection, etc.)
- Update router to use Shop.Page with live_action for all shop routes
- Change navigate= to patch= in shop component links
- Add maybe_sync_editing_blocks to reload editor state when page changes
- Track editor_page_slug to detect cross-page navigation while editing
- Fix picture element height when hover image disabled
- Extract ThemeEditor components for shared use

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-09 14:47:50 +00:00

32 lines
707 B
Elixir

defmodule BerrypodWeb.Shop.Pages.Cart do
@moduledoc """
Cart page handler for the unified Shop.Page LiveView.
"""
import Phoenix.Component, only: [assign: 3]
alias Berrypod.Pages
def init(socket, _params, _uri) do
page = Pages.get_page("cart")
socket =
socket
|> assign(:page_title, "Cart")
|> assign(:page, page)
{:noreply, socket}
end
def handle_params(_params, _uri, socket) do
{:noreply, socket}
end
def handle_event(_event, _params, _socket), do: :cont
# Called from render to compute the subtotal
def compute_assigns(assigns) do
Map.put(assigns, :cart_page_subtotal, Berrypod.Cart.calculate_subtotal(assigns.cart_items))
end
end