From 98601e0cb641f341775d804967af3ed659e692b3 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Thu, 23 Feb 2023 21:27:02 -0800 Subject: [PATCH] Adds ezcater fikes. --- src/clj/auto_ap/ezcater/core.clj | 12 ++++++---- src/cljc/auto_ap/ssr_routes.cljc | 2 +- .../auto_ap/views/pages/transactions.cljs | 23 +++++++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/clj/auto_ap/ezcater/core.clj b/src/clj/auto_ap/ezcater/core.clj index 45111f71..d16f4116 100644 --- a/src/clj/auto_ap/ezcater/core.clj +++ b/src/clj/auto_ap/ezcater/core.clj @@ -7,7 +7,6 @@ [clojure.string :as str] [clojure.data.json :as json] [clj-time.coerce :as coerce] - [clojure.tools.logging :as log] [clj-time.core :as time] [clojure.set :as set] [auto-ap.time :as atime] @@ -95,6 +94,7 @@ :eventKey 'cancelled}} [[:subscription [:parentId :parentEntity :eventEntity :eventKey]]]]]}))))) + #_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn upsert-ezcater ([] (upsert-ezcater (get-integrations))) @@ -108,7 +108,8 @@ :integration-status/last-updated (coerce/to-date (time/now))}) (catch Exception e - (log/warn e) + (alog/warn ::cant-upsert-ezcater + :exception e) (mark-integration-status integration {:integration-status/state :integration-state/failed :integration-status/message (.getMessage e)})))))) @@ -277,6 +278,7 @@ (update-in [:sales-order/charges 0 :charge/date] coerce/to-date))]))) (defn upsert-recent [] + (upsert-ezcater) (let [last-sunday (coerce/to-date (time/plus (second (->> (time/today) (iterate #(time/plus % (time/days -1))) (filter #(= 7 (time/day-of-week %))))) @@ -293,7 +295,8 @@ [?c2 :ezcater-caterer/uuid ?uuid]] (d/db conn) last-sunday) - :let [_ (log/info "Considering updating " order) + :let [_ (alog/info ::considering + :order order) id (last (str/split order #"/")) id (str/join "-" (drop 2 (str/split order #"-"))) lookup-map {"id" "bf3dcf5c-a68f-42d9-9084-049133e03d3d", @@ -341,7 +344,8 @@ :when (not= updated-order extant-order)] updated-order))] - (log/info "Found these orders to update:" orders-to-update) + (alog/info :found-orders-to-update + :orders orders-to-update) @(d/transact conn orders-to-update))) diff --git a/src/cljc/auto_ap/ssr_routes.cljc b/src/cljc/auto_ap/ssr_routes.cljc index 31948675..7607dc0c 100644 --- a/src/cljc/auto_ap/ssr_routes.cljc +++ b/src/cljc/auto_ap/ssr_routes.cljc @@ -10,7 +10,7 @@ "/active" {:put :active-client} "/1099" :company-1099 "/1099/table" {:get :company-1099-vendor-table} - "/1099/vendor-dialog" {["/" [#"\d+" :vendor-id]] {:get :company-1099-vendor-dialog + "/1099/vendor-dialog" {["/" [#"\d+" :vendor-id]] {:get :company-1099-vendor-dialog :post :company-1099-vendor-save}}}}) diff --git a/src/cljs/auto_ap/views/pages/transactions.cljs b/src/cljs/auto_ap/views/pages/transactions.cljs index 795045f0..fcce5d4d 100644 --- a/src/cljs/auto_ap/views/pages/transactions.cljs +++ b/src/cljs/auto_ap/views/pages/transactions.cljs @@ -45,6 +45,29 @@ ;; this catches an error where you choose a parameter, change to invoices page, then change to voided invoices (println "Error!" e))))) +(re-frame/reg-event-fx + ::unset-selected + (fn [cofx [_ params suppress]] + (let [checked @(re-frame/subscribe [::data-page/checked ::page]) + checked-params (get checked "header") + specific-transactions (map :id (vals (dissoc checked "header")))] + {:db (-> (:db cofx) + (assoc-in [:status :loading] true)) + :graphql {:token (-> cofx :db :user) + :owns-state {:single ::delete-selected} + :query-obj + {:venia/operation {:operation/type :mutation + :operation/name "DeleteTransactions"} + :venia/queries [{:query/data + [:delete-transactions + {:filters (some-> checked-params data-params->query-params) + :ids specific-transactions + :suppress suppress} + [:message]]}]} + :on-success (fn [_] + [::params-change params])} + :dispatch-n [[::data-page/reset-checked ::page] + [::modal/modal-closed]]}))) (re-frame/reg-event-fx ::delete-selected (fn [cofx [_ params suppress]]