Warns when an account is unusable

This commit is contained in:
Bryce
2024-03-28 19:39:47 -07:00
parent 0d75df522d
commit 6496eea485
5 changed files with 29 additions and 13 deletions

File diff suppressed because one or more lines are too long

View File

@@ -4,6 +4,7 @@
[auto-ap.graphql.utils
:refer [assert-can-see-client can-see-client? cleanse-query is-admin?]]
[auto-ap.solr :as solr]
[auto-ap.logging :as alog]
[auto-ap.ssr.utils
:refer [entity-id ref->enum-schema wrap-schema-enforce]]
[com.brunobonacci.mulog :as mu]
@@ -34,8 +35,7 @@
:name (first name)})))
(defn account-search [{{:keys [q client-id allowance vendor-id] :as qp} :query-params id :identity}]
(defn account-search [{{:keys [q client-id purpose vendor-id] :as qp} :query-params id :identity}]
(when client-id
(assert-can-see-client id client-id))
(let [num (some-> (re-find #"([0-9]+)" q)
@@ -46,9 +46,9 @@
valid-allowances (cond-> #{:allowance/allowed
:allowance/warn}
(is-admin? id) (conj :allowance/admin-only))
allowance (cond (= allowance :vendor)
allowance (cond (= purpose "vendor")
:account/vendor-allowance
(= allowance :invoice)
(= purpose "invoice")
:account/invoice-allowance
:else
:account/default-allowance)
@@ -99,6 +99,6 @@
[:maybe entity-id]]
[:vendor-id {:optional true}
[:maybe entity-id]]
[:allowance {:optional true}
[:maybe (ref->enum-schema "allowance")]]])))
[:purpose {:optional true}
[:maybe :string]]])))

View File

@@ -4,6 +4,7 @@
[auto-ap.ssr.hiccup-helper :as hh]
[clojure.string :as str]
[auto-ap.ssr.svg :as svg]
[auto-ap.ssr.components.tags :as tags]
[auto-ap.ssr.hx :as hx]))
@@ -37,7 +38,7 @@
(defn typeahead- [params]
[:div {:x-data (hx/json {:open false
[:div.relative {:x-data (hx/json {:open false
:baseUrl (if (str/includes? (:url params) "?")
(str (:url params) "&q=")
(str (:url params) "?q="))
@@ -47,10 +48,12 @@
:elements (if ((:value-fn params identity) (:value params))
[{:value ((:value-fn params identity) (:value params)) :label ((:content-fn params identity) (:value params))}]
[])
:popper nil})
:popper nil
:warning_badge nil})
:x-modelable "value.value"
:x-model (:x-model params)
:x-init "popper = Popper.createPopper($refs.input, $refs.dropdown, {placement: 'bottom-start', strategy: 'fixed', modifiers: {name: 'offset', options: {offset: [0, 10]}}})"
:x-init "popper = Popper.createPopper($refs.input, $refs.dropdown, {placement: 'bottom-start', strategy: 'fixed', modifiers: {name: 'offset', options: {offset: [0, 10]}}})
warning_badge = Popper.createPopper($refs.warning_badge, $refs.warning_pop, {placement: 'top', strategy: 'fixed', modifiers: {name: 'offset', options: {offset: [10,0 ]}}})"
}
[:a {:class (-> (hh/add-class (or (:class params) "") default-input-classes)
(hh/add-class "cursor-pointer"))
@@ -76,7 +79,18 @@
[:div.flex.w-full.justify-items-stretch
[:span.flex-grow.text-left {"x-text" "value.label"}]
[:div {:class "w-3 h-3 m-1 inline ml-1 justify-self-end text-gray-500 self-center"}
svg/drop-down]]]
svg/drop-down]
[:div {:x-show "value.warning"
:x-ref "warning_badge"
:x-effect "if (value.warning) { $nextTick(()=> warning_badge.update()) }"}
(tags/badge- {:class "peer"} "!")
[:div {:x-show "value.warning"
:x-ref "warning_pop"
:class "hidden peer-hover:block bg-red-50 dark:bg-gray-600 rounded-lg shadow-2xl w-max z-50 p-4"
:x-text "value.warning"}
]]]]
[:ul.dropdown-contents {:class "bg-gray-100 dark:bg-gray-600 rounded-lg shadow-2xl w-max z-50 ring-1"
"x-ref" "dropdown"

View File

@@ -158,7 +158,7 @@
(defn default-render-step [linear-wizard step & {:keys [head body footer validation-route discard-route]}]
(let [is-last? (= (step-key step) (last (steps linear-wizard)))]
(com/modal-card-advanced
{"@keydown.enter.prevent.stop" "$refs.next.click()"
{"@keydown.enter.prevent.stop" "if ($refs.next ) {$refs.next.click()}"
:class (str
"w-full h-full md:w-[750px] md:h-[600px]
group-[.forward]/transition:htmx-swapping:opacity-0

View File

@@ -303,7 +303,9 @@
[:div.flex.flex-col
(com/typeahead {:name name
:placeholder "Search..."
:url (str (bidi/path-for ssr-routes/only-routes :account-search) "?client-id=" client-id)
:url (hu/url (bidi/path-for ssr-routes/only-routes :account-search)
{:client-id client-id
:purpose "invoice"})
:id name
:x-model x-model
:value value