diff --git a/src/clj/auto_ap/ssr/invoice/new_invoice_wizard.clj b/src/clj/auto_ap/ssr/invoice/new_invoice_wizard.clj index 55101784..246b839b 100644 --- a/src/clj/auto_ap/ssr/invoice/new_invoice_wizard.clj +++ b/src/clj/auto_ap/ssr/invoice/new_invoice_wizard.clj @@ -252,32 +252,42 @@ (mut/select-keys (mm/form-schema linear-wizard) #{:invoice/expense-accounts})) (render-step [this {{:keys [snapshot]} :multi-form-state :as request}] - (alog/peek ::mfs (:step-params (:multi-form-state request))) - (mm/default-render-step - linear-wizard this - :head [:div.p-2 "Invoice accounts "] - :body (mm/default-step-body - {} - [:div {} - (pull-attr (dc/db conn) :client/name (:invoice/client snapshot)) - (fc/with-field :invoice/expense-accounts - (com/validated-field - {:errors (fc/field-errors)} - (com/data-grid {:headers [(com/data-grid-header {} "Account") - (com/data-grid-header {:class "w-32"} "Location") - (com/data-grid-header {:class "w-16"} "%") - (com/data-grid-header {:class "w-16"})]} - (fc/cursor-map #(invoice-expense-account-row* {:value % - :client-id (:invoice/client snapshot)})) - (com/data-grid-new-row {:colspan 4 - :hx-get (bidi/path-for ssr-routes/only-routes - ::route/new-wizard-new-account) - :index (count (fc/field-value)) - :tr-params {:hx-vals (hx/json {:client-id (:invoice/client snapshot)})}} - "New account"))))]) - :footer - (mm/default-step-footer linear-wizard this :validation-route ::route/new-wizard-navigate) - :validation-route ::route/new-wizard-navigate))) + (alog/peek ::mfs (:step-params (:multi-form-state request))) + (mm/default-render-step + linear-wizard this + :head [:div.p-2 "Invoice accounts "] + :body (mm/default-step-body + {} + [:div {} + (pull-attr (dc/db conn) :client/name (:invoice/client snapshot)) + (fc/with-field :invoice/expense-accounts + (com/validated-field + {:errors (fc/field-errors)} + (com/data-grid {:headers [(com/data-grid-header {} "Account") + (com/data-grid-header {:class "w-32"} "Location") + (com/data-grid-header {:class "w-16"} "%") + (com/data-grid-header {:class "w-16"})]} + (fc/cursor-map #(invoice-expense-account-row* {:value % + :client-id (:invoice/client snapshot)})) + (com/data-grid-new-row {:colspan 4 + :hx-get (bidi/path-for ssr-routes/only-routes + ::route/new-wizard-new-account) + :index (count (fc/field-value)) + :tr-params {:hx-vals (hx/json {:client-id (:invoice/client snapshot)})}} + "New account"))))]) + :footer + (mm/default-step-footer linear-wizard this :validation-route ::route/new-wizard-navigate) + :validation-route ::route/new-wizard-navigate)) + mm/Initializable + (init-step-params + [_ request] + (alog/peek ::INIT {:invoice/expense-accounts [{:db/id "123" + :invoice-expense-account/amount 100}]}) + {:invoice/expense-accounts [{:db/id "123" + :invoice-expense-account/location "Shared" + :invoice-expense-account/account (ffirst (dc/q '[:find ?a :where [?a :account/name]] + (dc/db conn))) + :invoice-expense-account/amount 100}]}))