adding new invoices has validation.
This commit is contained in:
@@ -5,5 +5,5 @@
|
||||
(defn edit-user [context args value]
|
||||
(users/update! (:edit_user args))
|
||||
(->graphql
|
||||
(users/get-by-id (:edit_user args))))
|
||||
(users/get-by-id (:id (:edit_user args)))))
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
(s/def ::date ::shared/date)
|
||||
(s/def ::total ::shared/money)
|
||||
|
||||
(s/def ::invoice (s/keys :opt-un [::vendor-id
|
||||
(s/def ::invoice (s/keys :req-un [::vendor-id
|
||||
::company-id
|
||||
::invoice-number
|
||||
::date
|
||||
|
||||
@@ -21,13 +21,21 @@
|
||||
[:footer.modal-card-foot
|
||||
foot])]])
|
||||
|
||||
(defn action-modal [{:keys [title action-text id save-event]} & rest]
|
||||
(defn action-modal [{:keys [title action-text id save-event can-submit?] :or {can-submit? true}} & rest]
|
||||
(let [{:keys [visible? saving?]} @(re-frame/subscribe [::subs/modal-state id])]
|
||||
(when visible?
|
||||
(-> [modal {:title title
|
||||
:foot [:a.button.is-primary {:on-click (fn []
|
||||
:foot [:button.button.is-primary {:on-click (fn []
|
||||
(re-frame/dispatch [::events/modal-status id {:saving? true}])
|
||||
(re-frame/dispatch save-event))
|
||||
:disabled (cond saving?
|
||||
"disabled"
|
||||
|
||||
(not can-submit?)
|
||||
"disabled"
|
||||
|
||||
:else
|
||||
"")
|
||||
:class (when saving?
|
||||
"is-loading")}
|
||||
[:span action-text]]
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[reagent.core :as r]
|
||||
[clojure.string :as str]
|
||||
[clojure.spec.alpha :as s]
|
||||
[auto-ap.entities.companies :as company]
|
||||
[auto-ap.entities.invoice :as invoice]
|
||||
[auto-ap.entities.vendors :as vendor]
|
||||
@@ -269,11 +270,11 @@
|
||||
(defn new-invoice-modal []
|
||||
(let [data @(re-frame/subscribe [::new-invoice])
|
||||
change-event [::events/change-form [::new-invoice]]]
|
||||
(println data)
|
||||
[action-modal {:id ::new-invoice
|
||||
:title "New Invoice"
|
||||
:action-text "Create"
|
||||
:save-event [::create-invoice]}
|
||||
:save-event [::create-invoice]
|
||||
:can-submit? (s/valid? ::invoice/invoice data)}
|
||||
[horizontal-field
|
||||
[:label.label "Vendor"]
|
||||
[bind-field
|
||||
|
||||
Reference in New Issue
Block a user