Close to supporting bulk upload

This commit is contained in:
2022-09-30 16:58:17 -07:00
parent ae1500be9a
commit 556d6311ff
2 changed files with 42 additions and 13 deletions

View File

@@ -255,11 +255,12 @@
Consumer
["status" "can-submit" "fullwidth?"]
(fn [status can-submit fullwidth?]
[:button.button.is-medium.is-primary {:disabled (or (status/disabled-for status)
(not can-submit))
:class (cond-> (or class [])
(status/class-for status) (into (status/class-for status))
fullwidth? (conj "is-fullwidth")) }
[:button.button.is-primary {:disabled (or (status/disabled-for status)
(not can-submit))
:class (cond-> (or class [])
(status/class-for status) (into (status/class-for status))
fullwidth? (conj "is-fullwidth")
(not= "is-small" class) (conj "is-medium")) }
child]))))
(defn hidden-submit-button []

View File

@@ -9,11 +9,15 @@
[auto-ap.views.utils :refer [dispatch-event with-user]]
[clojure.set :as set]
[re-frame.core :as re-frame]
[vimsical.re-frame.fx.track :as track]))
[vimsical.re-frame.fx.track :as track]
[auto-ap.forms.builder :as form-builder]
[vimsical.re-frame.cofx.inject :as inject]
[auto-ap.forms :as forms]
[clojure.string :as str]))
(def default-read [:name :start-date :end-date :status])
(def job-types [:yodlee2 :yodlee2-accounts :intuit :plaid])
(def job-types [:yodlee2 :yodlee2-accounts :intuit :plaid :bulk-journal-import])
(re-frame/reg-event-fx
::params-change
@@ -48,16 +52,24 @@
(re-frame/reg-event-fx
::request
[with-user ]
(fn [{:keys [user]} [_ which]]
{:graphql {:token user
[with-user
(re-frame/inject-cofx ::inject/sub [::forms/form ::bulk-journal-form])
]
(fn [{:keys [user] ::forms/keys [form]} [_ which]]
{:graphql {:token user
:owns-state {:single which}
:query-obj
{:venia/operation {:operation/type :mutation
:operation/name "RequestJob"}
:venia/variables [{:variable/name "args"
:variable/type :String
:variable/default (when (= which :bulk-journal-import)
(str/replace (pr-str (:data form))
"\"" "\\\""))}]
:venia/queries [{:query/data
[:request-job
{:which (name which)}
{:which (name which)
:args :$args}
[:message]]}]}
:on-success [::success]}}))
@@ -84,7 +96,7 @@
(defn job-button [{:keys [which]} content]
(let [status @(re-frame/subscribe [::status/single which])]
(println status)
[:button.button.is-primary-two {:type "button"
[:button.button.is-primary.is-small {:type "button"
:on-click (dispatch-event [::request which])
:disabled (status/disabled-for status)
:class (status/class-for status)}
@@ -107,6 +119,20 @@
:else
nil)]))])
(defn bulk-journal-import-button []
[form-builder/builder {:submit-event [::request :bulk-journal-import]
:id ::bulk-journal-form}
[:p.field.has-addons
[:p.control
[:a.button.is-static.is-small
"s3://data.prod.app.integreatconsult.com/bulk-import/"]]
[:p.control
[form-builder/raw-field-v2 {:field :ledger-url}
[:input.input.is-small {:placeholder "ledger-data.csv"}]]]
[:p.control
[form-builder/submit-button {:class "is-small"} "Ledger Import"]
]]])
;; VIEWS
(def jobs-content
(with-meta
@@ -120,10 +146,12 @@
[:div
[:div.is-pulled-right
[:div.buttons
[job-button {:which :yodlee2} "Start Yodlee Import"]
[job-button {:which :yodlee2-accounts} "Start Yodlee Account Import"]
[job-button {:which :intuit} "Start Intuit"]
[job-button {:which :plaid} "Start Plaid"]]]
[job-button {:which :plaid} "Start Plaid"]
[bulk-journal-import-button]]]
[table/table {:id :jobs
:data-page ::page}]])]))
{:component-did-mount (dispatch-event [::mounted ])