This commit is contained in:
2024-05-26 20:22:13 -07:00
111 changed files with 10708 additions and 5015 deletions

View File

@@ -10,6 +10,7 @@
[auto-ap.routes.outgoing-invoice :as oi-routes]
[auto-ap.routes.payments :as payment-routes]
[auto-ap.ssr-routes :as ssr-routes]
[auto-ap.ssr.components.tags :as tags]
[auto-ap.ssr.hiccup-helper :as hh]
[auto-ap.ssr.hx :as hx]
[auto-ap.ssr.svg :as svg]
@@ -45,14 +46,14 @@
:class (fnil hh/add-class "") "space-y-1.5 max-h-0 transition transition-all overflow-hidden")
true (assoc ":class" (format "selected == '%s' ? 'py-0.5' : 'py-0'" (:selector params))
:x-ref "submenu"
:style (cond-> {} (:active? params) (assoc "max-height" "400px"))
":style" (format "selected == '%s' ? 'max-height: ' + $refs.submenu.scrollHeight + 'px' : ''" (:selector params))))
:style (cond-> {} (:active? params) (assoc "max-height" "900px"))
":style" (format "selected == '%s' ? 'max-height: ' + $el.scrollHeight + 'px' : ''" (:selector params))))
(for [c children]
[:li
(update-in c [1 1 :class ] (fn [c]
(hh/add-class (or c "") " flex items-center p-2 pl-11 w-full text-base font-normal rounded-lg transition duration-75 group hover:bg-gray-100 dark:text-white dark:hover:bg-gray-700")))])])
(defn left-aside- [{:keys [nav page-specific]} & children]
(defn left-aside- [{:keys [nav page-specific]} & _]
[:aside {:id "left-nav",
:class "fixed top-0 left-0 pt-16 z-20 w-64 h-screen transition-transform",
"x-transition:enter" "transition duration-500"
@@ -66,12 +67,13 @@
:x-show "leftNavShow"
":aria-hidden" "leftNavShow ? 'false' : 'true'"}
;; TODO this causes a leftNavShow error when hitting back button. maybe amke a container
[:template {:x-teleport "body"}
[:div.fixed.inset-0.lg:hidden {:x-show "leftNavShow" :x-transition:enter "transition duration-500" :x-transition:enter-start "opacity-0" :x-transition:enter-end "opacity-100"
:x-transition:leave "transition duration-500" :x-transition:leave-start "opacity-100" :x-transition:leave-end "opacity-0"
"@click.capture.prevent" "leftNavShow=false"}
[:div.fixed.inset-0.bg-gray-800.z-10.opacity-70]]]
[:div.fixed.inset-0.bg-gray-800.z-100.opacity-70]]]
[:div {:class "overflow-y-auto py-5 px-3 h-full bg-gray-50 border-r border-gray-200 dark:bg-gray-800 dark:border-gray-700"}
nav
@@ -83,12 +85,12 @@
(defn main-aside-nav- [request]
(let [selected (cond
(#{::invoice-route/all-page ::invoice-route/unpaid-page ::invoice-route/voided-page ::invoice-route/paid-page ::oi-routes/new ::invoice-route/import-page} (:matched-route request))
(#{::invoice-route/all-page ::invoice-route/unpaid-page ::invoice-route/voided-page ::invoice-route/paid-page ::oi-routes/new ::invoice-route/import-page :invoice-glimpse :invoice-glimpse-textract-invoice} (:matched-route request))
"invoices"
(#{:pos-sales :pos-expected-deposits :pos-tenders :pos-refunds :pos-cash-drawer-shifts} (:matched-route request))
"sales"
(#{::payment-routes/all-page ::payment-routes/pending-page ::payment-routes/cleared-page ::payment-routes/voided-page } (:matched-route request))
(#{::payment-routes/all-page ::payment-routes/pending-page ::payment-routes/cleared-page ::payment-routes/voided-page} (:matched-route request))
"payments"
:else
nil)]
@@ -102,7 +104,7 @@
(when (can? (:identity request)
{:subject :invoice-page})
(list
(list
(menu-button- {"@click.prevent" "if (selected == 'invoices') {selected = null } else { selected = 'invoices'} "
:icon svg/accounting-invoice-mail}
"Invoices")
@@ -135,13 +137,26 @@
:hx-boost "true"}
"Voided")
(when (can? (:identity request)
{:subject :invoice
:activity :import})
(menu-button- {:href (bidi/path-for ssr-routes/only-routes
::invoice-route/import-page)
:active? (= ::invoice-route/import-page (:matched-route request))
:hx-boost "true"} "Import"))
:hx-boost "true"} "Import"))
(when (can? (:identity request)
{:subject :invoice
:activity :import})
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
:invoice-glimpse))
:active? (= :invoice-glimpse (:matched-route request))
:hx-boost "true"}
[:div.flex.gap-2
"Glimpse"
(tags/pill- {:color :secondary} "Beta")]))
(when (can? (:identity request)
@@ -272,42 +287,62 @@
:external-import-ledger)} "External Ledger Import")))))]))
(defn company-aside-nav- [_]
(defn company-aside-nav- [request]
[:ul {:class "space-y-2" :hx-boost "true"}
[:li
(menu-button- {:icon svg/vendors
:active? (= :company (:matched-route request))
:href (bidi/path-for ssr-routes/only-routes
:company)
:hx-boost true}
"My Company")]
[:li
(menu-button- {:icon svg/report
:active? (= :company-reports (:matched-route request))
:href (bidi/path-for ssr-routes/only-routes
:company-reports)
:hx-boost true}
"Reports")]
[:li
(menu-button- {:icon svg/report
:active? (= :company-expense-report (:matched-route request))
:href (bidi/path-for ssr-routes/only-routes
:company-expense-report)
:hx-boost true}
"Expense Report")]
(when (can? (:identity request)
{:subject :reconciliation-report})
[:li
(menu-button- {:icon svg/report
:active? (= :company-reconciliation-report (:matched-route request))
:href (bidi/path-for ssr-routes/only-routes
:company-reports)
:company-reconciliation-report)
:hx-boost true}
"Reports")]
"Bank Sync Report")])
[:li
(menu-button- {:icon svg/bank
:active? (= :company-plaid (:matched-route request))
:href (bidi/path-for ssr-routes/only-routes
:company-plaid)
:hx-boost true}
"Plaid Link")]
[:li
(menu-button- {:icon svg/bank
:active? (= :company-yodlee (:matched-route request))
:href (bidi/path-for ssr-routes/only-routes
:company-yodlee)
:hx-boost true}
"Yodlee Link")]
[:li
(menu-button- {:icon svg/government-building
:active? (= :company-1099 (:matched-route request))
:href (bidi/path-for ssr-routes/only-routes
:company-1099)
:hx-boost true}
"1099 Vendor Info"
)]])
"1099 Vendor Info")]])
(defn admin-aside-nav- [{:keys [matched-route] :as request}]
(defn admin-aside-nav- [{:keys [matched-route]}]
[:ul {:class "space-y-2" :x-data (hx/json {:selected "nil"})}
[:li
(menu-button- {:icon svg/dashboard