Transactions are converted!

This commit is contained in:
Bryce Covert
2020-08-21 08:21:47 -07:00
parent 57895d9ee2
commit e8301b071d
5 changed files with 145 additions and 90 deletions

View File

@@ -89,6 +89,12 @@
(assoc db single {:state :loading
:error nil})))
(re-frame/reg-event-db
::dispose-single
[(re-frame/path [::status]) ]
(fn [db [_ single]]
(dissoc db single )))
(re-frame/reg-event-db
::completed
[(re-frame/path [::status]) ]
@@ -101,17 +107,33 @@
[(re-frame/path [::status]) ]
(fn [db [_ single error]]
(assoc db single {:state :error
:info nil
:error error})))
(re-frame/reg-event-db
::info
[(re-frame/path [::status]) ]
(fn [db [_ single info]]
(assoc db single {:info info})))
(defn status-notification [{:keys [statuses]}]
(let [states
(->> statuses
(mapv #(deref (re-frame/subscribe %)))
(filter #(= :error (:state %))))]
(when (seq states)
[:div.notification.is-warning
(for [state states
state (:error state)]
(do
^{:key (:message state)}
[:p (:message state)]))])))
(let [states (mapv #(deref (re-frame/subscribe %)) statuses)
error-states
(->> states
(filter #(= :error (:state %))))
info-states
(->> states (filter #(:info %)))]
[:<>
(if (seq error-states)
[:div.notification.is-warning
(for [state states
state (:error state)]
(do
^{:key (:message state)}
[:p (:message state)]))])
(if (seq info-states)
[:div.notification
(for [state states]
(do
^{:key (:info state)}
[:p (:info state)]))])]))