mirror of
https://github.com/penpot/penpot.git
synced 2025-07-16 23:25:16 +02:00
🐛 Fix allow team name to be all blank
This commit is contained in:
parent
4d4e9703cc
commit
02466d603c
4 changed files with 27 additions and 2 deletions
|
@ -17,12 +17,20 @@
|
|||
[app.util.router :as rt]
|
||||
[beicon.core :as rx]
|
||||
[cljs.spec.alpha :as s]
|
||||
[cuerdas.core :as str]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(s/def ::name ::us/not-empty-string)
|
||||
(s/def ::team-form
|
||||
(s/keys :req-un [::name]))
|
||||
|
||||
(defn- validate-name
|
||||
[errors data]
|
||||
(let [name (-> data :name str/trim)]
|
||||
(cond-> errors
|
||||
(str/empty? name)
|
||||
(assoc :name {:message (tr "dashboard.team-name.not-empty-name")}))))
|
||||
|
||||
(defn- on-create-success
|
||||
[_form response]
|
||||
(let [msg "Team created successfully"]
|
||||
|
@ -66,10 +74,11 @@
|
|||
(on-create-submit form))))
|
||||
|
||||
(mf/defc team-form-modal {::mf/register modal/components
|
||||
::mf/register-as :team-form}
|
||||
::mf/register-as :team-form}
|
||||
[{:keys [team] :as props}]
|
||||
(let [initial (mf/use-memo (fn [] (or team {})))
|
||||
form (fm/use-form :spec ::team-form
|
||||
:validators [validate-name]
|
||||
:initial initial)]
|
||||
[:div.modal-overlay
|
||||
[:div.modal-container.team-form-modal
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue