All checks were successful
deploy / deploy (push) Successful in 1m27s
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>
40 lines
934 B
Elixir
40 lines
934 B
Elixir
defmodule BerrypodWeb.Shop.Pages.Search do
|
|
@moduledoc """
|
|
Search page handler for the unified Shop.Page LiveView.
|
|
"""
|
|
|
|
import Phoenix.Component, only: [assign: 3]
|
|
import Phoenix.LiveView, only: [push_patch: 2]
|
|
|
|
alias Berrypod.{Pages, Search}
|
|
|
|
def init(socket, _params, _uri) do
|
|
page = Pages.get_page("search")
|
|
|
|
socket =
|
|
socket
|
|
|> assign(:page_title, "Search")
|
|
|> assign(:page, page)
|
|
|
|
{:noreply, socket}
|
|
end
|
|
|
|
def handle_params(params, _uri, socket) do
|
|
query = params["q"] || ""
|
|
results = if query != "", do: Search.search(query), else: []
|
|
|
|
socket =
|
|
socket
|
|
|> assign(:search_page_query, query)
|
|
|> assign(:search_page_results, results)
|
|
|
|
{:noreply, socket}
|
|
end
|
|
|
|
def handle_event("search_submit", %{"q" => query}, socket) do
|
|
{:noreply, push_patch(socket, to: "/search?q=#{query}")}
|
|
end
|
|
|
|
def handle_event(_event, _params, _socket), do: :cont
|
|
end
|