From 3f5ade2e7a139bb4405437e8fc5546aafc7b05ef Mon Sep 17 00:00:00 2001 From: unwox Date: Fri, 3 Oct 2025 11:56:37 +0600 Subject: WIP shop --- pages/shop/order/_id.fnl | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 pages/shop/order/_id.fnl (limited to 'pages/shop/order/_id.fnl') diff --git a/pages/shop/order/_id.fnl b/pages/shop/order/_id.fnl new file mode 100644 index 0000000..5c929a3 --- /dev/null +++ b/pages/shop/order/_id.fnl @@ -0,0 +1,35 @@ +(import-macros {:compile-html HTML} :macros) +(local templates (require :templates)) +(local shop (require :shop)) +(local lib (require :lib)) +(local dicts (require :dicts)) + +(local texts + {:thanks + (lib.improve-typography + "Мы получили оповещение о заказе. В ближайшее время свяжемся с вами + для уточнения деталей.")}) + +(fn content [order-lines authenticated?] + (local total (accumulate [sum 0 _ v (ipairs order-lines)] + (+ sum (* v.quantity v.price-per)))) + + [(HTML [:aside {} + (templates.header "/shop/order" authenticated?)]) + (HTML + [:div {:class "content"} + [:div {:class "back"} [:a {:href "/shop"} "⟵ Обратно к списку"]] + [:section {} + [:h2 {} "Спасибо за заказ!"] + [:p {} texts.thanks] + (templates.order-lines order-lines) + [:div {} "—"] + [:div {} [:strong {} (.. "Итого: " (lib.format-price total) "₽")]]]])]) + +(fn render [request db authenticated?] + (let [order-lines (shop.basket db request.params._id)] + (if (< 0 (# order-lines)) + (values 200 {} (templates.base (content order-lines authenticated?))) + (values 302 {:Location "/shop"} "")))) + +{: render} -- cgit v1.2.3