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/state.fnl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 pages/shop/order/state.fnl (limited to 'pages/shop/order/state.fnl') 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} -- cgit v1.2.3