blob: 03ec0a9cd2b609594033b992b488187256f070fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
(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?)
(templates.address-block)
(templates.conditions-block)
(templates.contact-block)])
(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}
|