diff --git a/src/clj/auto_ap/db/invoices.clj b/src/clj/auto_ap/db/invoices.clj index 7679dd2d..aa3fde7a 100644 --- a/src/clj/auto_ap/db/invoices.clj +++ b/src/clj/auto_ap/db/invoices.clj @@ -11,6 +11,9 @@ (map db->clj (j/query conn "SELECT * FROM invoices"))) +(defn approve [] + (map db->clj (j/update! conn :invoices {:imported true} [] ))) + (defn get-unpaid [] (map db->clj (j/query conn "SELECT * FROM invoices WHERE imported=true"))) diff --git a/src/clj/auto_ap/handler.clj b/src/clj/auto_ap/handler.clj index df56920d..03fa829f 100644 --- a/src/clj/auto_ap/handler.clj +++ b/src/clj/auto_ap/handler.clj @@ -35,6 +35,12 @@ {:status 200 :body (pr-str (invoices/get-all)) :headers {"Content-Type" "application/edn"}}) + (POST "/api/invoices/approve" [] + (invoices/approve) + (println (invoices/get-pending)) + {:status 200 + :body (pr-str (invoices/get-pending)) + :headers {"Content-Type" "application/edn"}}) (POST "/pdf-upload" {{ files "file"} :params :as params} (let [{:keys [filename tempfile]} files] diff --git a/src/cljs/auto_ap/core.cljs b/src/cljs/auto_ap/core.cljs index e8e960de..71bc522e 100644 --- a/src/cljs/auto_ap/core.cljs +++ b/src/cljs/auto_ap/core.cljs @@ -5,11 +5,11 @@ [auto-ap.views :as views] [auto-ap.config :as config] [auto-ap.routes :as routes] + [auto-ap.effects :as effects] [pushy.core :as pushy] [bidi.bidi :as bidi])) (defn- parse-url [url] - (.log js/console "test" (bidi/match-route routes/routes url)) (bidi/match-route routes/routes url)) (defn- dispatch-route [matched-route] diff --git a/src/cljs/auto_ap/effects.cljs b/src/cljs/auto_ap/effects.cljs new file mode 100644 index 00000000..726b1a15 --- /dev/null +++ b/src/cljs/auto_ap/effects.cljs @@ -0,0 +1,24 @@ +(ns auto-ap.effects + (:require-macros [cljs.core.async.macros :refer [go]]) + (:require [re-frame.core :as re-frame] + [reagent.core :as reagent] + [auto-ap.subs :as subs] + [auto-ap.events :as events] + [cljs.reader :as edn] + [cljsjs.dropzone :as dz] + [auto-ap.routes :as routes] + [bidi.bidi :as bidi] + [cljs-http.client :as http] + [cljs.core.async :refer [> (http/request {:method method + :url uri}) + (> (