Merge branch 'worktree-sx-loop-cleanup' into macros
# Conflicts: # blog/sx/sx_components.py # federation/sx/profile.sx # federation/sx/sx_components.py # orders/sx/sx_components.py
This commit is contained in:
@@ -120,6 +120,57 @@
|
||||
(<> auth (~header-child-sx :id "auth-header-child" :inner
|
||||
(<> orders (~header-child-sx :id "orders-header-child" :inner order))))))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; Data-driven order rows (replaces Python loop)
|
||||
;; ---------------------------------------------------------------------------
|
||||
|
||||
(defcomp ~order-rows-from-data (&key orders page total-pages next-url)
|
||||
(<>
|
||||
(map (lambda (o)
|
||||
(<>
|
||||
(~order-row-desktop :oid (get o "oid") :created (get o "created")
|
||||
:desc (get o "desc") :total (get o "total")
|
||||
:pill (get o "pill_desktop") :status (get o "status") :url (get o "url"))
|
||||
(~order-row-mobile :oid (get o "oid") :created (get o "created")
|
||||
:total (get o "total") :pill (get o "pill_mobile")
|
||||
:status (get o "status") :url (get o "url"))))
|
||||
(or orders (list)))
|
||||
(if next-url
|
||||
(~infinite-scroll :url next-url :page page :total-pages total-pages
|
||||
:id-prefix "orders" :colspan 5)
|
||||
(~order-end-row))))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; Data-driven order items (replaces Python loop)
|
||||
;; ---------------------------------------------------------------------------
|
||||
|
||||
(defcomp ~order-items-from-data (&key items)
|
||||
(~order-items-panel
|
||||
:items (<> (map (lambda (item)
|
||||
(let* ((img (if (get item "product_image")
|
||||
(~order-item-image :src (get item "product_image") :alt (or (get item "product_title") "Product image"))
|
||||
(~order-item-no-image))))
|
||||
(~order-item-row
|
||||
:href (get item "href") :img img
|
||||
:title (or (get item "product_title") "Unknown product")
|
||||
:pid (str "Product ID: " (get item "product_id"))
|
||||
:qty (str "Qty: " (get item "quantity"))
|
||||
:price (get item "price"))))
|
||||
(or items (list))))))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; Data-driven calendar entries (replaces Python loop)
|
||||
;; ---------------------------------------------------------------------------
|
||||
|
||||
(defcomp ~order-calendar-from-data (&key entries)
|
||||
(~order-calendar-section
|
||||
:items (<> (map (lambda (e)
|
||||
(~order-calendar-entry
|
||||
:name (get e "name") :pill (get e "pill")
|
||||
:status (get e "status") :date-str (get e "date_str")
|
||||
:cost (get e "cost")))
|
||||
(or entries (list))))))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; Checkout error screens
|
||||
;; ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user