switched to graphql to create a payment.
This commit is contained in:
@@ -49,20 +49,36 @@
|
||||
(re-frame/reg-event-fx
|
||||
::print-checks
|
||||
(fn [{:keys [db]} [_ data]]
|
||||
{:db (assoc-in db [::invoice-page :checked] nil)
|
||||
:http {:method :post
|
||||
:token (:user db)
|
||||
:body (pr-str {:invoice-ids (get-in db [::invoice-page :checked])})
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:uri (str "/api/checks/")
|
||||
:on-success [::checks-created]
|
||||
:on-error [::save-error]}}))
|
||||
{:graphql
|
||||
{:token (-> db :user)
|
||||
:query-obj {:venia/operation {:operation/type :mutation
|
||||
:operation/name "PrintChecks"}
|
||||
|
||||
:venia/queries [[:print-checks
|
||||
{:invoice_ids (vec (get-in db [::invoice-page :checked]))}
|
||||
[[:invoices [:id [:checks [:amount [:check [:amount :s3_url :check_number ]]]]]
|
||||
]
|
||||
:pdf_url]]]}
|
||||
|
||||
:on-success [::checks-created]}}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::checks-created
|
||||
(fn [{:keys [db]} [_ data]]
|
||||
{:new-window (:url data)
|
||||
}))
|
||||
(let [{{:keys [pdf-url invoices]} :print-checks} data
|
||||
invoices-by-id (reduce
|
||||
(fn [x a]
|
||||
(assoc x (:id a) a))
|
||||
{}
|
||||
invoices)]
|
||||
{:new-window pdf-url
|
||||
:db (-> db
|
||||
(update-in [::invoice-page :invoices]
|
||||
(fn [invoices]
|
||||
(map (fn [i]
|
||||
(merge i (invoices-by-id (:id i))))
|
||||
invoices)))
|
||||
(assoc-in [::invoice-page :checked] nil))})))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::invalidated
|
||||
|
||||
Reference in New Issue
Block a user