summaryrefslogtreecommitdiff
path: root/pages/shop/order/_id.fnl
diff options
context:
space:
mode:
authorunwox <me@unwox.com>2025-10-03 11:56:37 +0600
committerunwox <me@unwox.com>2025-10-13 23:11:01 +0600
commit3f5ade2e7a139bb4405437e8fc5546aafc7b05ef (patch)
tree77c437958d74b591f11ec207d16749cf207a51e3 /pages/shop/order/_id.fnl
parentf5a70e6a446e00969adb866ef2e2d10bf33bc4a8 (diff)
WIP shop
Diffstat (limited to 'pages/shop/order/_id.fnl')
-rw-r--r--pages/shop/order/_id.fnl35
1 files changed, 35 insertions, 0 deletions
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}