You can now turn schedules on and off
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
{:db (assoc-in db [:admin-companies :editing :saving?] true)
|
||||
:http {:method :put
|
||||
:token (:user db)
|
||||
:body (pr-str (select-keys edited-company [:name :email :data]))
|
||||
:body (pr-str (select-keys edited-company [:name :email :data :invoice-reminder-schedule]))
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:uri (str "/api/companies/" (:id edited-company))
|
||||
:on-success [::save-complete]}})))
|
||||
@@ -36,5 +36,3 @@
|
||||
(fn [db [_ path value]]
|
||||
(assoc-in db (concat [:admin-companies :editing] path)
|
||||
value)))
|
||||
|
||||
|
||||
|
||||
@@ -16,13 +16,15 @@
|
||||
[:thead
|
||||
[:tr
|
||||
[:th "Name"]
|
||||
[:th "Email"]]]
|
||||
[:tbody (for [{:keys [id name email data] :as c} @companies]
|
||||
[:th "Email"]
|
||||
[:th "Invoice Reminders"]]]
|
||||
[:tbody (for [{:keys [id name email data invoice-reminder-schedule] :as c} @companies]
|
||||
^{:key (str name "-" id )}
|
||||
[:tr {:on-click (fn [] (re-frame/dispatch [::events/edit id]))
|
||||
:style {"cursor" "pointer"}}
|
||||
[:td name]
|
||||
[:td email]])]]))
|
||||
[:td email]
|
||||
[:td invoice-reminder-schedule]])]]))
|
||||
|
||||
(defn admin-companies-page []
|
||||
[:div {:class "inbox-messages"}
|
||||
@@ -32,11 +34,12 @@
|
||||
(let [companies (re-frame/subscribe [::subs/companies])
|
||||
admin-companies (re-frame/subscribe [::subs/admin-companies])
|
||||
editing-company (:editing @admin-companies)]
|
||||
(println editing-company)
|
||||
|
||||
[:div
|
||||
[:h1.title "Companies"]
|
||||
[companies-table]
|
||||
[:a.button.is-primary "New Company"]
|
||||
|
||||
|
||||
|
||||
(when editing-company
|
||||
@@ -61,18 +64,31 @@
|
||||
[:input.input {:type "email"
|
||||
:value (:email editing-company)
|
||||
:on-change (dispatch-value-change [::events/change [:email]])}]]]
|
||||
|
||||
[:div.field
|
||||
[:labal.label "Invoice Reminders"]
|
||||
[:div.control
|
||||
[:label.radio
|
||||
[:input {:type "radio" :name "schedule"}]
|
||||
"Send Invoice Reminders Weekly"]
|
||||
[:input {:type "radio"
|
||||
:name "schedule"
|
||||
:value "Weekly"
|
||||
:checked (if (= "Weekly" (:invoice-reminder-schedule editing-company))
|
||||
"checked"
|
||||
"")
|
||||
:on-change (dispatch-value-change [::events/change [:invoice-reminder-schedule]])}]
|
||||
" Send weekly"]]
|
||||
[:div.control
|
||||
[:label.radio
|
||||
[:input {:type "radio" :name "schedule"}]
|
||||
"Do not send invoice reminders"]]]
|
||||
|
||||
[:input {:type "radio"
|
||||
:name "schedule"
|
||||
:value "Never"
|
||||
:checked (if (= "Never" (:invoice-reminder-schedule editing-company))
|
||||
"checked"
|
||||
"")
|
||||
:on-change (dispatch-value-change [::events/change [:invoice-reminder-schedule]])}]
|
||||
" Never"]]]
|
||||
|
||||
|
||||
(when (:saving? editing-company) [:div.is-overlay {:style {"background-color" "rgba(150,150,150, 0.5)"}}])]
|
||||
(when (:saving? editing-company) [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])]
|
||||
|
||||
[:footer.modal-card-foot
|
||||
[:a.button.is-primary {:on-click (fn [] (re-frame/dispatch [::events/save]))}
|
||||
@@ -80,4 +96,3 @@
|
||||
(when (:saving? editing-company)
|
||||
[:span.icon
|
||||
[:i.fa.fa-spin.fa-spinner]])]]]])])]]]])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user