;; Cart app defpage declarations.
;; All data fetching via (service ...) IO primitives, no Python helpers.

(defpage cart-overview
  :path "/"
  :auth :public
  :layout :root
  :data (service "cart-page" "overview-data")
  :content (~cart-overview-content
    :page-groups page-groups
    :cart-url-base cart-url-base))

(defpage page-cart-view
  :path "/<page_slug>/"
  :auth :public
  :layout :cart-page
  :data (service "cart-page" "page-cart-data")
  :content (~cart-page-cart-content
    :cart-items cart-items
    :cal-entries cal-entries
    :ticket-groups ticket-groups
    :summary (~cart-summary-from-data
      :item-count (get summary "item_count")
      :grand-total (get summary "grand_total")
      :symbol (get summary "symbol")
      :is-logged-in (get summary "is_logged_in")
      :checkout-action (get summary "checkout_action")
      :login-href (get summary "login_href")
      :user-email (get summary "user_email"))))

(defpage cart-admin
  :path "/<page_slug>/admin/"
  :auth :admin
  :layout :cart-admin
  :data (service "cart-page" "admin-data")
  :content (~cart-admin-content))

(defpage cart-payments
  :path "/<page_slug>/admin/payments/"
  :auth :admin
  :layout (:cart-admin :selected "payments")
  :data (service "cart-page" "payments-admin-data")
  :content (~cart-payments-content
    :page-config page-config))
