Move market composition from Python to .sx defcomps (Phase 8)

Convert 5 market page helpers from returning sx_call() strings to
returning data dicts. Defpages now use :data + :content pattern.
Admin panel uses inline map/fn for CRUD item composition.
Removed market-admin-content helper (placeholder inlined in defpage).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 02:08:09 +00:00
parent 1560207097
commit 877e776977
2 changed files with 132 additions and 104 deletions

View File

@@ -1,4 +1,5 @@
;; Market app defpage declarations.
;; All helpers return data dicts — markup composition in SX.
;;
;; all-markets-index: / — global view across all pages
;; page-markets-index: /<slug>/ — markets for a single page
@@ -10,28 +11,64 @@
:path "/"
:auth :public
:layout :root
:content (all-markets-content))
:data (all-markets-data)
:content (if no-markets
(~empty-state :icon "fa fa-store" :message "No markets available"
:cls "px-3 py-12 text-center text-stone-400")
(~market-markets-grid
:cards (~market-cards-content
:markets market-data :page market-page
:has-more has-more :next-url next-url))))
(defpage page-markets-index
:path "/<slug>/"
:auth :public
:layout :post
:content (page-markets-content))
:data (page-markets-data)
:content (if no-markets
(~empty-state :message "No markets for this page"
:cls "px-3 py-12 text-center text-stone-400")
(~market-markets-grid
:cards (~market-cards-content
:markets market-data :page market-page
:has-more has-more :next-url next-url))))
(defpage page-admin
:path "/<slug>/admin/"
:auth :admin
:layout (:post-admin :selected "markets")
:content (page-admin-content))
:data (page-admin-data)
:content (~market-admin-content-wrap
:inner (~crud-panel
:list-id "markets-list"
:form (when can-create
(~crud-create-form
:create-url create-url :csrf csrf
:errors-id "market-create-errors" :list-id "markets-list"
:placeholder "e.g. Suma, Craft Fair" :btn-label "Add market"))
:list (if admin-markets
(<> (map (fn (m)
(~crud-item
:href (get m "href") :name (get m "name") :slug (get m "slug")
:del-url (get m "del-url") :csrf-hdr (get m "csrf-hdr")
:list-id "markets-list"
:confirm-title "Delete market?"
:confirm-text "Products will be hidden (soft delete)"))
admin-markets))
(~empty-state
:message "No markets yet. Create one above."
:cls "text-gray-500 mt-4")))))
(defpage market-home
:path "/<page_slug>/<market_slug>/"
:auth :public
:layout :market
:content (market-home-content))
:data (market-home-data)
:content (~market-landing-from-data
:excerpt excerpt :feature-image feature-image :html html))
(defpage market-admin
:path "/<page_slug>/<market_slug>/admin/"
:auth :admin
:layout (:market-admin :selected "markets")
:content (market-admin-content))
:content "market admin")