summaryrefslogtreecommitdiff
path: root/pages/shop/order/state.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/state.fnl
parentf5a70e6a446e00969adb866ef2e2d10bf33bc4a8 (diff)
WIP shop
Diffstat (limited to 'pages/shop/order/state.fnl')
-rw-r--r--pages/shop/order/state.fnl18
1 files changed, 18 insertions, 0 deletions
diff --git a/pages/shop/order/state.fnl b/pages/shop/order/state.fnl
new file mode 100644
index 0000000..1ff1ca9
--- /dev/null
+++ b/pages/shop/order/state.fnl
@@ -0,0 +1,18 @@
+(local lib (require :lib))
+(local shop (require :shop))
+
+(fn render [request db authenticated?]
+ (if (and (= request.method "POST") authenticated?)
+ (let [vals (lib.parse-values request.body)]
+ (if (and vals vals.id
+ vals.state (or (= vals.state "done")
+ (= vals.state "canceled")))
+ (do
+ (if (= "done" vals.state)
+ (shop.finish-order db vals.id)
+ (shop.cancel-order db vals.id))
+ (values 302 {:Location "/shop/order/list"} ""))
+ (values 400 {} "bad body")))
+ (values 404 {} "not found")))
+
+{: render}