makes it possible to add new vendors.

This commit is contained in:
Bryce
2024-04-10 10:27:08 -07:00
parent 894f7af16e
commit 1493b03ba3
5 changed files with 59 additions and 36 deletions

File diff suppressed because one or more lines are too long

View File

@@ -10,6 +10,7 @@
[auto-ap.routes.utils [auto-ap.routes.utils
:refer [wrap-client-redirect-unauthenticated]] :refer [wrap-client-redirect-unauthenticated]]
[auto-ap.rule-matching :as rm] [auto-ap.rule-matching :as rm]
[auto-ap.client-routes :as client-routes]
[auto-ap.solr :as solr] [auto-ap.solr :as solr]
[auto-ap.ssr-routes :as ssr-routes] [auto-ap.ssr-routes :as ssr-routes]
[auto-ap.ssr.common-handlers :refer [add-new-entity-handler]] [auto-ap.ssr.common-handlers :refer [add-new-entity-handler]]
@@ -229,6 +230,14 @@
:value (fc/field-value) :value (fc/field-value)
:content-fn (fn [c] (pull-attr (dc/db conn) :vendor/name c)) :content-fn (fn [c] (pull-attr (dc/db conn) :vendor/name c))
:x-model "vendorId"})])) :x-model "vendorId"})]))
[:div.mb-4
[:span.text-sm.text-gray-500 "Can't find the vendor? "
(com/link {:href (bidi.bidi/path-for
client-routes/routes
:new-vendor)
:target "new"}
"Add new vendor")
" in a new window, then return here."]]
[:div.flex.items-center.gap-2 [:div.flex.items-center.gap-2

View File

@@ -7,6 +7,7 @@
"needs-activation" :needs-activation "needs-activation" :needs-activation
"payments/" :payments "payments/" :payments
"admin/" {"vendors" :admin-vendors} "admin/" {"vendors" :admin-vendors}
"vendor/" {"new" :new-vendor}
"invoices/" {"" :invoices "invoices/" {"" :invoices
"import" :import-invoices "import" :import-invoices
"unpaid" :unpaid-invoices "unpaid" :unpaid-invoices

View File

@@ -18,7 +18,7 @@
[auto-ap.views.pages.ledger.profit-and-loss-detail :refer [profit-and-loss-detail-page]] [auto-ap.views.pages.ledger.profit-and-loss-detail :refer [profit-and-loss-detail-page]]
[auto-ap.views.pages.login :refer [login-page]] [auto-ap.views.pages.login :refer [login-page]]
[auto-ap.views.pages.payments :refer [payments-page]] [auto-ap.views.pages.payments :refer [payments-page]]
[auto-ap.views.pages.home :refer [home-page]])) [auto-ap.views.pages.home :refer [home-page home-page-with-vendor]]))
(defmulti page (fn [active-page] active-page)) (defmulti page (fn [active-page] active-page))
(defmethod page :unpaid-invoices [_] (defmethod page :unpaid-invoices [_]
@@ -94,6 +94,10 @@
(defmethod page :index [_] (defmethod page :index [_]
(home-page)) (home-page))
(defmethod page :new-vendor [_]
(home-page-with-vendor))
(defmethod page :login [_] (defmethod page :login [_]
[login-page]) [login-page])

View File

@@ -2,7 +2,9 @@
(:require [auto-ap.routes :as routes] (:require [auto-ap.routes :as routes]
[auto-ap.subs :as subs] [auto-ap.subs :as subs]
[auto-ap.views.components.grid :as grid] [auto-ap.views.components.grid :as grid]
[auto-ap.permissions :as p]
[auto-ap.views.components.layouts :refer [side-bar-layout]] [auto-ap.views.components.layouts :refer [side-bar-layout]]
[auto-ap.views.components.vendor-dialog :as vendor-dialog]
[auto-ap.history :refer [history]] [auto-ap.history :refer [history]]
[cemerick.url :as url] [cemerick.url :as url]
[auto-ap.views.utils [auto-ap.views.utils
@@ -42,8 +44,7 @@
:inner-radius 20} :inner-radius 20}
(map (fn [_ y] (map (fn [_ y]
^{:key y} ^{:key y}
[cell {:key y :fill (colors y)}]) data (range)) [cell {:key y :fill (colors y)}]) data (range))]
]
[tool-tip] [tool-tip]
[legend]]) [legend]])
@@ -58,8 +59,7 @@
(defn make-cash-flow-chart [{:keys [width height data]}] (defn make-cash-flow-chart [{:keys [width height data]}]
(let [redirect-fn (fn [x] (let [redirect-fn (fn [x]
(pushy/set-token! history (str (bidi/path-for routes/routes :unpaid-invoices) "?" (get (js->clj x) "query-params"))) (pushy/set-token! history (str (bidi/path-for routes/routes :unpaid-invoices) "?" (get (js->clj x) "query-params"))))]
)]
[bar-chart {:width width :height height :data data :fill "#FFFFFF" :stackOffset "sign"} [bar-chart {:width width :height height :data data :fill "#FFFFFF" :stackOffset "sign"}
[tool-tip] [tool-tip]
[bar {:dataKey "effective-balance" :fill (get colors 1) :stackId "a" :name "Effective Balance" [bar {:dataKey "effective-balance" :fill (get colors 1) :stackId "a" :name "Effective Balance"
@@ -74,8 +74,7 @@
:on-click redirect-fn}] :on-click redirect-fn}]
[x-axis {:dataKey "name"}] [x-axis {:dataKey "name"}]
[y-axis] [y-axis]
[legend]]) [legend]]))
)
(re-frame/reg-event-db (re-frame/reg-event-db
::received ::received
@@ -300,16 +299,14 @@
"Due ") "Due ")
type] type]
[grid/cell {} name] [grid/cell {} name]
[grid/cell {:class "has-text-right"} (->$ amount)] [grid/cell {:class "has-text-right"} (->$ amount)]])]]]))
])]]]))
(defn home-content [] (defn home-content []
(let [client-id (-> @(re-frame/subscribe [::subs/client]) :id) (let [client-id (-> @(re-frame/subscribe [::subs/client]) :id)
chart-options @(re-frame/subscribe [::chart-options]) chart-options @(re-frame/subscribe [::chart-options])
state @(re-frame/subscribe [::status/single ::page])] state @(re-frame/subscribe [::status/single ::page])]
^{:key client-id} ^{:key client-id}
[side-bar-layout {:side-bar [:div [side-bar-layout {:side-bar [:div]
]
:main [:div [:h1.title "Home"] :main [:div [:h1.title "Home"]
(if client-id (if client-id
(if (= :loading (:state state)) (if (= :loading (:state state))
@@ -360,4 +357,16 @@
(defn home-page [] (defn home-page []
(let [client-id (-> @(re-frame/subscribe [::subs/client]) :id)] (let [client-id (-> @(re-frame/subscribe [::subs/client]) :id)]
(re-frame/dispatch [::mounted]) (re-frame/dispatch [::mounted])
^{:key client-id} [home-content]))
(defn home-page-with-vendor []
(let [client-id (-> @(re-frame/subscribe [::subs/client]) :id)
user @(re-frame/subscribe [::subs/user])]
(re-frame/dispatch [::mounted])
(when (p/can? user {:subject :vendor
:activity :create})
(re-frame/dispatch [::vendor-dialog/started {}]))
^{:key client-id} [home-content])) ^{:key client-id} [home-content]))