add pagination across all admin and shop views
All checks were successful
deploy / deploy (push) Successful in 1m38s
All checks were successful
deploy / deploy (push) Successful in 1m38s
URL-based offset pagination with ?page=N for bookmarkable pages. Admin views use push_patch, shop collection uses navigate links. Responsive on mobile with horizontal-scroll tables and stacking pagination controls. Includes dev seed script for testing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -439,10 +439,19 @@ defmodule BerrypodWeb.PageRenderer do
|
||||
# ── Collection blocks ───────────────────────────────────────────
|
||||
|
||||
defp render_block(%{block: %{"type" => "collection_header"}} = assigns) do
|
||||
count =
|
||||
if assigns[:pagination] do
|
||||
assigns.pagination.total_count
|
||||
else
|
||||
length(assigns[:products] || [])
|
||||
end
|
||||
|
||||
assigns = assign(assigns, :product_count, count)
|
||||
|
||||
~H"""
|
||||
<.collection_header
|
||||
title={assigns[:collection_title] || "All Products"}
|
||||
product_count={length(assigns[:products] || [])}
|
||||
product_count={@product_count}
|
||||
/>
|
||||
"""
|
||||
end
|
||||
@@ -525,7 +534,15 @@ defmodule BerrypodWeb.PageRenderer do
|
||||
|
||||
defp render_block(%{block: %{"type" => "product_grid"}} = assigns) do
|
||||
show_category = assigns[:current_category] in [nil, :sale]
|
||||
assigns = assign(assigns, :show_category, show_category)
|
||||
collection_slug = assigns[:collection_slug] || "all"
|
||||
current_sort = assigns[:current_sort] || "featured"
|
||||
sort_params = if current_sort != "featured", do: %{"sort" => current_sort}, else: %{}
|
||||
|
||||
assigns =
|
||||
assigns
|
||||
|> assign(:show_category, show_category)
|
||||
|> assign(:collection_slug, collection_slug)
|
||||
|> assign(:sort_params, sort_params)
|
||||
|
||||
~H"""
|
||||
<div class="page-container">
|
||||
@@ -541,6 +558,13 @@ defmodule BerrypodWeb.PageRenderer do
|
||||
<% end %>
|
||||
</.product_grid>
|
||||
|
||||
<.shop_pagination
|
||||
:if={assigns[:pagination] && assigns[:pagination].total_pages > 1}
|
||||
page={assigns[:pagination]}
|
||||
base_path={~p"/collections/#{@collection_slug}"}
|
||||
params={@sort_params}
|
||||
/>
|
||||
|
||||
<%= if (assigns[:products] || []) == [] do %>
|
||||
<div class="collection-empty">
|
||||
<p>No products found in this collection.</p>
|
||||
|
||||
Reference in New Issue
Block a user