summaryrefslogtreecommitdiff
path: root/pages/shop
diff options
context:
space:
mode:
authorunwox <me@unwox.com>2025-09-05 10:24:45 +0600
committerunwox <me@unwox.com>2025-09-05 13:45:31 +0600
commit996f9a20ad329dfc8bb35945b44471bfae315ada (patch)
treeedcf562ab7e5a1fd1b7a8a2f50d4c1371c718416 /pages/shop
parent66c51b0e714fa8a1c80784108191270babc8525e (diff)
small fixes
Diffstat (limited to 'pages/shop')
-rw-r--r--pages/shop/order.fnl74
-rw-r--r--pages/shop/success.fnl12
2 files changed, 42 insertions, 44 deletions
diff --git a/pages/shop/order.fnl b/pages/shop/order.fnl
index 6edaf8a..50e12da 100644
--- a/pages/shop/order.fnl
+++ b/pages/shop/order.fnl
@@ -1,45 +1,47 @@
+(import-macros {:compile-html HTML} :macros)
(local lib (require :lib))
(local templates (require :templates))
-(local html (require :vendor.html))
(fn content-template [db basket basket-total]
- [[:div {:class "side"}
- (templates.header "/shop/order")]
- [:div {:class "content"}
- (if (< 0 (# basket))
- [:section {}
- [:h2 {} "Состав заказа"]
- [:div {}
- (table.unpack
- (icollect [_ item (ipairs basket)]
- (templates.basket-item item "/shop/order")))]
- [:div {} "~~~"]
- [:div {:class "basket-total"} (.. "Итого: " basket-total "₽")]]
- "")
- [:section {}
- [:h2 {} "Данные для связи"]
- [:form {:class "form" :method "POST"}
- [:div {:class "form-row"}
- [:label {:for "name"} "Имя"]
- [:input {:type "text" :id "name" :name "name" :required "required"}]]
- [:div {:class "form-row"}
- [:label {:for "contact"} "Телеграм или Email для связи"]
- [:input {:type "text" :id "contact" :name "contact" :required "required"}]]
- [:div {:class "form-row"}
- [:input {:type "checkbox" :id "everything-is-correct"
- :name "everything-is-correct" :required "required"}]
- [:label {:for "everything-is-correct"} "Данные заказа верны"]]
- [:div {:class "form-row"}
- [:input {:type "checkbox" :id "agree-to-conditions"
- :name "agree-to-conditions" :required "required"}]
- [:label {:for "agree-to-conditions"} "Согласен с условиями"]]
- [:button {:type "submit"} "Оформить заказ"]]]]])
+ [(HTML
+ [:div {:class "side"}
+ (templates.header "/shop/order")])
+ (HTML
+ [:div {:class "content"}
+ (if (< 0 (# basket))
+ [:section {}
+ [:h2 {} "Состав заказа"]
+ [:div {}
+ (table.unpack
+ (icollect [_ item (ipairs basket)]
+ (templates.basket-item item "/shop/order")))]
+ [:div {} "~~~"]
+ [:div {:class "basket-total"} (.. "Итого: " basket-total "₽")]]
+ "")
+ [:section {}
+ [:h2 {} "Данные для связи"]
+ [:form {:class "form" :method "POST"}
+ [:div {:class "form-row"}
+ [:label {:for "name"} "Имя"]
+ [:input {:type "text" :id "name" :name "name" :required "required"}]]
+ [:div {:class "form-row"}
+ [:label {:for "contact"} "Телеграм или Email для связи"]
+ [:input {:type "text" :id "contact" :name "contact" :required "required"}]]
+ [:div {:class "form-row"}
+ [:input {:type "checkbox" :id "everything-is-correct"
+ :name "everything-is-correct" :required "required"}]
+ [:label {:for "everything-is-correct"} "Данные заказа верны"]]
+ [:div {:class "form-row"}
+ [:input {:type "checkbox" :id "agree-to-conditions"
+ :name "agree-to-conditions" :required "required"}]
+ [:label {:for "agree-to-conditions"} "Согласен с условиями"]]
+ [:button {:type "submit"} "Оформить заказ"]]]])])
(fn place-order [db order-id form]
(_G.must
(luna.db.exec db
"UPDATE orders SET placement_time = ?, first_name = ?, contact = ?"
- [(os.date "%Y-%m-%d %H:%M:%S") form.name form.contact])))
+ [(lib.now) form.name form.contact])))
(fn render [request db]
(let [order-id (lib.order-id request)
@@ -51,11 +53,7 @@
(place-order db order-id (lib.parse-values request.body))
(values 302 {:Location "/shop/success"} ""))
(if (< 0 (# basket))
- (values
- 200 {}
- (html.render
- (templates.base (content-template db basket basket-total))
- true))
+ (values 200 {} (templates.base (content-template db basket basket-total)))
(values 302 {:Location "/shop"} "")))))
{: render}
diff --git a/pages/shop/success.fnl b/pages/shop/success.fnl
index 2e9abb4..b28f84d 100644
--- a/pages/shop/success.fnl
+++ b/pages/shop/success.fnl
@@ -1,15 +1,15 @@
+(import-macros {:compile-html HTML} :macros)
(local templates (require :templates))
-(local html (require :vendor.html))
(tset _G :package :loaded "pages.shop.success" nil)
(fn content []
- [[:div {:class "side"}
- (templates.header "/shop/order")]
- [:div {:class "content"}
- "Спасибо за заказ!"]])
+ [(HTML [:div {:class "side"}
+ (templates.header "/shop/order")])
+ (HTML [:div {:class "content"}
+ "Спасибо за заказ!"])])
(fn render []
- (values 200 {} (html.render (templates.base (content)) true)))
+ (values 200 {} (templates.base (content))))
{: render}