2026-03-09 14:47:50 +00:00
|
|
|
|
defmodule BerrypodWeb.Shop.Pages.Content do
|
|
|
|
|
|
@moduledoc """
|
|
|
|
|
|
Content page handler for the unified Shop.Page LiveView.
|
|
|
|
|
|
Handles about, delivery, privacy, and terms pages.
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
import Phoenix.Component, only: [assign: 2, assign: 3]
|
2026-02-08 10:47:54 +00:00
|
|
|
|
|
2026-02-24 13:48:49 +00:00
|
|
|
|
alias Berrypod.LegalPages
|
2026-02-26 18:29:20 +00:00
|
|
|
|
alias Berrypod.Pages
|
2026-02-18 21:23:15 +00:00
|
|
|
|
alias Berrypod.Theme.PreviewData
|
2026-02-08 10:47:54 +00:00
|
|
|
|
|
2026-03-09 14:47:50 +00:00
|
|
|
|
def init(socket, _params, _uri) do
|
|
|
|
|
|
# Content pages load in handle_params based on live_action
|
|
|
|
|
|
{:noreply, socket}
|
2026-02-08 10:47:54 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def handle_params(_params, _uri, socket) do
|
2026-03-09 14:47:50 +00:00
|
|
|
|
action = socket.assigns.live_action
|
|
|
|
|
|
slug = to_string(action)
|
2026-02-26 18:29:20 +00:00
|
|
|
|
page = Pages.get_page(slug)
|
2026-03-09 14:47:50 +00:00
|
|
|
|
{seo, content_blocks} = page_config(action)
|
2026-02-26 18:29:20 +00:00
|
|
|
|
|
|
|
|
|
|
socket =
|
|
|
|
|
|
socket
|
|
|
|
|
|
|> assign(seo)
|
|
|
|
|
|
|> assign(:page, page)
|
|
|
|
|
|
|> assign(:content_blocks, content_blocks)
|
|
|
|
|
|
|
|
|
|
|
|
{:noreply, socket}
|
2026-02-08 10:47:54 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
2026-03-09 14:47:50 +00:00
|
|
|
|
def handle_event(_event, _params, _socket), do: :cont
|
2026-02-08 10:47:54 +00:00
|
|
|
|
|
2026-02-26 18:29:20 +00:00
|
|
|
|
# Returns {seo_assigns, content_blocks} for each content page
|
2026-02-08 10:47:54 +00:00
|
|
|
|
defp page_config(:about) do
|
2026-02-26 18:29:20 +00:00
|
|
|
|
{
|
|
|
|
|
|
%{
|
|
|
|
|
|
page_title: "About",
|
2026-03-09 14:47:50 +00:00
|
|
|
|
page_description: "Your story goes here – this is sample content for the demo shop",
|
2026-02-26 18:29:20 +00:00
|
|
|
|
og_url: BerrypodWeb.Endpoint.url() <> "/about"
|
|
|
|
|
|
},
|
|
|
|
|
|
PreviewData.about_content()
|
2026-02-08 10:47:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
defp page_config(:delivery) do
|
2026-02-26 18:29:20 +00:00
|
|
|
|
{
|
|
|
|
|
|
%{
|
|
|
|
|
|
page_title: "Delivery & returns",
|
|
|
|
|
|
page_description: "Everything you need to know about shipping and returns.",
|
|
|
|
|
|
og_url: BerrypodWeb.Endpoint.url() <> "/delivery"
|
|
|
|
|
|
},
|
|
|
|
|
|
LegalPages.delivery_content()
|
2026-02-08 10:47:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
defp page_config(:privacy) do
|
2026-02-26 18:29:20 +00:00
|
|
|
|
{
|
|
|
|
|
|
%{
|
|
|
|
|
|
page_title: "Privacy policy",
|
|
|
|
|
|
page_description: "How we handle your personal information.",
|
|
|
|
|
|
og_url: BerrypodWeb.Endpoint.url() <> "/privacy"
|
|
|
|
|
|
},
|
|
|
|
|
|
LegalPages.privacy_content()
|
2026-02-08 10:47:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
defp page_config(:terms) do
|
2026-02-26 18:29:20 +00:00
|
|
|
|
{
|
|
|
|
|
|
%{
|
|
|
|
|
|
page_title: "Terms of service",
|
|
|
|
|
|
page_description: "The terms and conditions governing purchases from our shop.",
|
|
|
|
|
|
og_url: BerrypodWeb.Endpoint.url() <> "/terms"
|
|
|
|
|
|
},
|
|
|
|
|
|
LegalPages.terms_content()
|
2026-02-08 10:47:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|