2026-03-09 14:47:50 +00:00
|
|
|
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}
|
integrate R module and add url editor ui
Replaces hardcoded paths with R module throughout:
- Shop components: layout nav, cart, product links
- Controllers: cart, checkout, contact, seo, order lookup
- Shop pages: collection, product, search, checkout success, etc.
- Site context: nav item url resolution
Admin URL management:
- Settings page: prefix editor with validation feedback
- Page renderer: url_editor component for page URLs
- CSS for url editor styling
Test updates for cache isolation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-01 00:36:17 +01:00
|
|
|
alias BerrypodWeb.R
|
2026-03-09 14:47:50 +00:00
|
|
|
|
|
|
|
|
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
|
integrate R module and add url editor ui
Replaces hardcoded paths with R module throughout:
- Shop components: layout nav, cart, product links
- Controllers: cart, checkout, contact, seo, order lookup
- Shop pages: collection, product, search, checkout success, etc.
- Site context: nav item url resolution
Admin URL management:
- Settings page: prefix editor with validation feedback
- Page renderer: url_editor component for page URLs
- CSS for url editor styling
Test updates for cache isolation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-01 00:36:17 +01:00
|
|
|
{:noreply, push_patch(socket, to: R.search() <> "?q=#{query}")}
|
2026-03-09 14:47:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def handle_event(_event, _params, _socket), do: :cont
|
|
|
|
|
end
|