lots of improvements.
This commit is contained in:
@@ -25,6 +25,9 @@
|
|||||||
id (or (:db/id client) "new-client")
|
id (or (:db/id client) "new-client")
|
||||||
_ (println id)
|
_ (println id)
|
||||||
_ (println edit_client)
|
_ (println edit_client)
|
||||||
|
_ (when client
|
||||||
|
@(d/transact (d/connect uri)
|
||||||
|
(mapv (fn [lm] [:db/retractEntity (:db/id lm)]) (:client/location-matches client))))
|
||||||
transactions [(remove-nils {:db/id id
|
transactions [(remove-nils {:db/id id
|
||||||
:client/code (if (str/blank? (:client/code client))
|
:client/code (if (str/blank? (:client/code client))
|
||||||
(:code edit_client)
|
(:code edit_client)
|
||||||
@@ -64,7 +67,16 @@
|
|||||||
})]
|
})]
|
||||||
result @(d/transact (d/connect uri) transactions)]
|
result @(d/transact (d/connect uri) transactions)]
|
||||||
(println result "ID" id)
|
(println result "ID" id)
|
||||||
(-> result :tempids (get id) (or id) d-clients/get-by-id ->graphql)))
|
(-> result :tempids (get id) (or id) d-clients/get-by-id
|
||||||
|
(update :client/location-matches
|
||||||
|
(fn [lms]
|
||||||
|
(mapcat (fn [lm]
|
||||||
|
(map (fn [m]
|
||||||
|
{:location-match/match m
|
||||||
|
:location-match/location (:location-match/location lm)})
|
||||||
|
(:location-match/matches lm)))
|
||||||
|
lms)))
|
||||||
|
->graphql)))
|
||||||
|
|
||||||
|
|
||||||
(defn get-client [context args value]
|
(defn get-client [context args value]
|
||||||
|
|||||||
@@ -20,16 +20,19 @@
|
|||||||
|
|
||||||
(defmethod parse-csv :mama-lus
|
(defmethod parse-csv :mama-lus
|
||||||
[rows]
|
[rows]
|
||||||
(println "MAMA LU")
|
(println "MAMA LU4")
|
||||||
(transduce
|
(transduce
|
||||||
(comp (drop 1)
|
(comp (drop 1)
|
||||||
(map (fn [[_ po-number despatch-number invoice-number invoice-date customer value :as row]]
|
(map (fn [[_ po-number despatch-number invoice-number invoice-date customer value :as row]]
|
||||||
{:vendor-code "Mama Lu's Foods"
|
{:vendor-code "Mama Lu's Foods"
|
||||||
:customer-identifier customer
|
:customer-identifier customer
|
||||||
:invoice-number (str po-number "-" invoice-number )
|
:invoice-number (str po-number "-" invoice-number )
|
||||||
:date (u/parse-value :clj-time "MM/dd/yy HH:ss" invoice-date)
|
:date (try (u/parse-value :clj-time "M/d/yyyy HH:ss" invoice-date)
|
||||||
:total value
|
(catch Exception _
|
||||||
:text (str/join " " row)})))
|
(u/parse-value :clj-time "M/d/yyyy" invoice-date)))
|
||||||
|
:total (str/replace value #"," "")
|
||||||
|
:text (str/join " " row)
|
||||||
|
:full-text (str/join " " row)})))
|
||||||
conj
|
conj
|
||||||
[]
|
[]
|
||||||
rows))
|
rows))
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
(defroutes routes
|
(defroutes routes
|
||||||
(GET "/oauth" {{:strs [code]} :query-params :keys [scheme] :as r {:strs [host]} :headers}
|
(GET "/oauth" {{:strs [code]} :query-params :keys [scheme] :as r {:strs [host]} :headers}
|
||||||
|
(println "Authenticating with" r "..." code)
|
||||||
(try
|
(try
|
||||||
(let [auth (-> "https://accounts.google.com/o/oauth2/token"
|
(let [auth (-> "https://accounts.google.com/o/oauth2/token"
|
||||||
(http/post
|
(http/post
|
||||||
@@ -44,17 +45,19 @@
|
|||||||
|
|
||||||
;; TODO - these namespaces are not being transmitted/deserialized properly
|
;; TODO - these namespaces are not being transmitted/deserialized properly
|
||||||
(if (and token user)
|
(if (and token user)
|
||||||
{:status 301
|
(let [jwt (jwt/sign (doto {:user (:name profile)
|
||||||
:headers {"Location" (str "/?jwt=" (jwt/sign (doto {:user (:name profile)
|
:exp (time/plus (time/now) (time/days 30))
|
||||||
:exp (time/plus (time/now) (time/days 30))
|
:user/clients (map (fn [c]
|
||||||
:user/clients (map (fn [c]
|
(dissoc c :client/bank-accounts :client/location-matches))
|
||||||
(dissoc c :client/bank-accounts ))
|
(:user/clients user))
|
||||||
(:user/clients user))
|
:user/role (name (:user/role user))
|
||||||
:user/role (name (:user/role user))
|
:user/name (:name profile)}
|
||||||
:user/name (:name profile)}
|
println)
|
||||||
println)
|
(:jwt-secret env)
|
||||||
(:jwt-secret env)
|
{:alg :hs512})]
|
||||||
{:alg :hs512}))}}
|
(println "authenticated. using jwt" jwt)
|
||||||
|
{:status 301
|
||||||
|
:headers {"Location" (str "/?jwt=" jwt)}})
|
||||||
{:status 401
|
{:status 401
|
||||||
:body "Couldn't authenticate"}))
|
:body "Couldn't authenticate"}))
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
::edit-client-clicked
|
::edit-client-clicked
|
||||||
(fn [{:keys [db]} [_ client-id]]
|
(fn [{:keys [db]} [_ client-id]]
|
||||||
{:db (-> db
|
{:db (-> db
|
||||||
|
(forms/stop-form ::new-client)
|
||||||
(forms/start-form ::new-client (get (:clients db) client-id)))}))
|
(forms/start-form ::new-client (get (:clients db) client-id)))}))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
@@ -120,6 +121,18 @@
|
|||||||
(update :location-matches conj (:location-match client))
|
(update :location-matches conj (:location-match client))
|
||||||
(dissoc :location-match))))
|
(dissoc :location-match))))
|
||||||
|
|
||||||
|
(re-frame/reg-event-db
|
||||||
|
::remove-location-match
|
||||||
|
[(forms/in-form ::new-client) (re-frame/path [:data])]
|
||||||
|
(fn [client [_ i]]
|
||||||
|
(-> client
|
||||||
|
(update :location-matches (fn [lm]
|
||||||
|
(->> lm
|
||||||
|
(map vector (range))
|
||||||
|
(filter (fn [[index item]]
|
||||||
|
(not= index i)))
|
||||||
|
(map second)))))))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::add-new-bank-account
|
::add-new-bank-account
|
||||||
[(forms/in-form ::new-client) (re-frame/path [:data])]
|
[(forms/in-form ::new-client) (re-frame/path [:data])]
|
||||||
@@ -402,9 +415,11 @@
|
|||||||
:event change-event
|
:event change-event
|
||||||
:subscription new-client}]]]
|
:subscription new-client}]]]
|
||||||
[:p.control [:button.button.is-primary {:on-click (dispatch-event [::add-new-location-match])} "Add"]]]
|
[:p.control [:button.button.is-primary {:on-click (dispatch-event [::add-new-location-match])} "Add"]]]
|
||||||
|
|
||||||
[:ul
|
[:ul
|
||||||
(for [{:keys [location match]} (:location-matches new-client)]
|
(for [[index {:keys [location match]}] (map vector (range) (:location-matches new-client))]
|
||||||
^{:key location} [:li match "->" location ])]]]
|
^{:key index} [:li match "->" location [:a {:on-click (dispatch-event [::remove-location-match index])} [:span.icon
|
||||||
|
[:span.fa.fa-times]]]])]]]
|
||||||
|
|
||||||
[:div {:style {:padding-bottom "0.75em" :padding-top "0.75em"}}
|
[:div {:style {:padding-bottom "0.75em" :padding-top "0.75em"}}
|
||||||
[:h2.subtitle "Address"]
|
[:h2.subtitle "Address"]
|
||||||
|
|||||||
Reference in New Issue
Block a user