2026-02-18 21:23:15 +00:00
|
|
|
defmodule BerrypodWeb.Shop.Contact do
|
|
|
|
|
use BerrypodWeb, :live_view
|
2026-01-17 21:52:11 +00:00
|
|
|
|
2026-02-24 08:40:08 +00:00
|
|
|
alias Berrypod.Orders
|
|
|
|
|
alias Berrypod.Orders.OrderNotifier
|
|
|
|
|
alias BerrypodWeb.OrderLookupController
|
|
|
|
|
|
2026-01-17 21:52:11 +00:00
|
|
|
@impl true
|
|
|
|
|
def mount(_params, _session, socket) do
|
2026-02-23 21:31:35 +00:00
|
|
|
{:ok,
|
|
|
|
|
socket
|
|
|
|
|
|> assign(:page_title, "Contact")
|
add canonical URLs, robots.txt, and sitemap.xml
Canonical: all shop pages now assign og_url (reusing the existing og:url
assign), which the layout renders as <link rel="canonical">. Collection
pages strip the sort param so ?sort=price_asc doesn't create a duplicate
canonical.
robots.txt: dynamic controller disallows /admin/, /api/, /users/,
/webhooks/, /checkout/. Removed robots.txt from static_paths so it
goes through the router instead of Plug.Static.
sitemap.xml: auto-generated from all visible products + categories +
static pages, served as application/xml. 8 tests.
Also updates PROGRESS.md: marks tasks 55, 58, 59, 61, 62 as done.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-23 21:47:35 +00:00
|
|
|
|> assign(
|
|
|
|
|
:page_description,
|
|
|
|
|
"Get in touch with us for any questions or help with your order."
|
|
|
|
|
)
|
2026-02-24 08:40:08 +00:00
|
|
|
|> 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)}
|
2026-01-17 21:52:11 +00:00
|
|
|
end
|
2026-01-17 22:17:59 +00:00
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
|
def render(assigns) do
|
|
|
|
|
~H"""
|
2026-02-18 21:23:15 +00:00
|
|
|
<BerrypodWeb.PageTemplates.contact {assigns} />
|
2026-01-17 22:17:59 +00:00
|
|
|
"""
|
|
|
|
|
end
|
2026-01-17 21:52:11 +00:00
|
|
|
end
|