berrypod/lib/berrypod_web/live/shop/contact.ex
jamey 01ff8decd5
All checks were successful
deploy / deploy (push) Successful in 1m17s
add order status lookup for customers
Magic link flow on contact page: customer enters email, gets a
time-limited signed link, clicks through to /orders showing all their
paid orders and full detail pages with thumbnails and product links.

- OrderLookupController generates/verifies Phoenix.Token signed links
- Contact LiveView handles lookup_orders + reset_tracking events
- Orders and OrderDetail LiveViews gated by session email
- Order detail shows thumbnails, links to products still available
- .themed-button gets base padding/font-weight so all usages are consistent
- order-summary-card sticky scoped to .cart-grid (was leaking to orders list)
- 27 new tests (1095 total)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 08:40:08 +00:00

50 lines
1.2 KiB
Elixir

defmodule BerrypodWeb.Shop.Contact do
use BerrypodWeb, :live_view
alias Berrypod.Orders
alias Berrypod.Orders.OrderNotifier
alias BerrypodWeb.OrderLookupController
@impl true
def mount(_params, _session, socket) do
{:ok,
socket
|> assign(:page_title, "Contact")
|> assign(
:page_description,
"Get in touch with us for any questions or help with your order."
)
|> assign(:og_url, BerrypodWeb.Endpoint.url() <> "/contact")
|> assign(:tracking_state, :idle)}
end
@impl true
def handle_event("lookup_orders", %{"email" => email}, socket) do
orders = Orders.list_orders_by_email(email)
state =
if orders == [] do
:not_found
else
token = OrderLookupController.generate_token(email)
link = BerrypodWeb.Endpoint.url() <> ~p"/orders/verify/#{token}"
OrderNotifier.deliver_order_lookup(email, link)
:sent
end
{:noreply, assign(socket, :tracking_state, state)}
end
@impl true
def handle_event("reset_tracking", _params, socket) do
{:noreply, assign(socket, :tracking_state, :idle)}
end
@impl true
def render(assigns) do
~H"""
<BerrypodWeb.PageTemplates.contact {assigns} />
"""
end
end