Files
mono/market/sxc/pages/market.sx
giles 877e776977 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>
2026-03-05 02:10:55 +00:00

75 lines
2.5 KiB
Plaintext

;; 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
;; page-admin: /<slug>/admin/ — post-level admin for markets
;; market-home: /<page_slug>/<market_slug>/ — market landing page
;; market-admin: /<page_slug>/<market_slug>/admin/ — market admin
(defpage all-markets-index
:path "/"
:auth :public
:layout :root
: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
: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")
: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
: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")