Addes expense report card

This commit is contained in:
2024-04-29 20:08:11 -07:00
parent cb5028948e
commit 8afbc124c4
4 changed files with 111 additions and 87 deletions

View File

@@ -9,6 +9,7 @@
[auto-ap.routes.utils :refer [wrap-admin
wrap-client-redirect-unauthenticated]]
[auto-ap.ssr-routes :as ssr-routes]
[auto-ap.ssr.company.reports.expense :refer [expense-breakdown-card]]
[auto-ap.ssr.components :as com]
[auto-ap.ssr.hiccup-helper :as hh]
[auto-ap.ssr.hx :as hx]
@@ -26,11 +27,10 @@
(defn bank-accounts-card [request]
(html-response
(com/card {:class "inline-block " }
[:div.p-4
(com/card {:class "h-full"}
[:div.p-4.h-full
[:h1.text-2xl.font-bold "Bank Accounts"]
[:div (hx/alpine-mount-then-appear {:class "max-h-[900px] overflow-scroll"
:data-key "show"})
[:div (hx/htmx-transition-appear {:class "h-full overflow-scroll" })
(for [c (:valid-trimmed-client-ids request)
b (:client/bank-accounts (dc/pull (dc/db conn) '[{:client/bank-accounts
@@ -218,10 +218,10 @@
(defn tasks-card [request]
(html-response
(com/card {:class "w-full h-full p-4 space-y-2"}
(com/card {:class "w-full h-full p-4"}
[:h1.text-2xl.font-bold.text-gray-700
"Tasks"]
[:div (hx/alpine-mount-then-appear {:data-key "show"})
[:div (hx/htmx-transition-appear {:class "space-y-2"})
(let [[unpaid-invoice-count unpaid-invoice-amount]
(first (dc/q '[:find (count ?e) (sum ?ab)
:in $ [?clients ?start-date ?end-date]
@@ -262,8 +262,7 @@
"?date-range="
(url/url-encode (pr-str {:start (atime/unparse-local (time/plus (time/now) (time/years -1)) atime/iso-date) :end (atime/unparse-local (time/now) atime/iso-date)}))) }
"Review now")
])))])))
"Review now")])))])))
(defn stub-card [params & children]
(com/card (-> params
@@ -276,30 +275,35 @@
[:div.htmx-indicator (svg/spinner {:class "inline w-32 h-32 text-green-500"})]]))
(defn- page-contents [request]
[:div
[:div {:class "grid grid-cols-1 lg:grid-cols-2 2xl:grid-cols-3 gap-4 auto-rows-fr max-h-[970px]"}
[:div (stub-card {:title "Expenses"
[:div.mb-8
[:div {:class "grid grid-cols-1 lg:grid-cols-2 2xl:grid-cols-3 gap-4 mb-8"}
[:div.h-96 (stub-card {:title "Expenses"
:hx-get (bidi.bidi/path-for ssr-routes/only-routes ::d-routes/expense-card)
:hx-trigger "load"} )]
[:div
[:div.h-96
(stub-card {:title "Tasks"
:hx-get (bidi.bidi/path-for ssr-routes/only-routes ::d-routes/tasks-card)
:hx-trigger "load"} )]
[:div.row-span-2
[:div {:class " row-span-2 h-[49rem]"}
(stub-card {:title "Bank Accounts"
:hx-get (bidi.bidi/path-for ssr-routes/only-routes ::d-routes/bank-accounts-card)
:hx-trigger "load"} )
]
[:div
[:div.h-96
(stub-card {:title "Gross Sales, last 14 days"
:hx-get (bidi.bidi/path-for ssr-routes/only-routes ::d-routes/sales-card)
:hx-trigger "load"})
]
[:div
[:div.h-96
(stub-card {:title "Profit and Loss, last month"
:hx-get (bidi.bidi/path-for ssr-routes/only-routes ::d-routes/pnl-card)
:hx-trigger "load"}) ] ] ])
:hx-trigger "load"}) ]
[:div.col-span-2.h-96
(stub-card {:title "Expense breakdown"
:hx-get (bidi.bidi/path-for ssr-routes/only-routes :company-expense-report-breakdown-card)
:hx-trigger "load"} )]
[:div]] ])
(defn page [request]
(base-page
@@ -331,6 +335,6 @@
::d-routes/pnl-card pnl-card
::d-routes/sales-card sales-chart-card
::d-routes/bank-accounts-card bank-accounts-card
::d-routes/tasks-card tasks-card}
::d-routes/tasks-card tasks-card }
(fn [h]
(wrap-client-redirect-unauthenticated (wrap-admin h)))))