summaryrefslogtreecommitdiff
path: root/pages/shop/cart/remove.fnl
blob: 0cdc4177eb69b82c21883c9503ed6a1f28ae46c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
(local lib (require :lib))
(local shop (require :shop))

(fn render [request db]
  (if (= request.method "POST")
    (let [order-id (shop.order-id request)]
      (if (and order-id request.body)
        (do
          (local body-values (lib.parse-values request.body))
          (shop.delete-order-line db body-values.id)
          (values
            302
            {:Location (_G.must
                         (luna.http.decode-url
                           (or body-values.redirect-url "/shop")))}
            ""))
        (values 400 {} "bad body")))
    (values 404 {} "not found")))

{: render}