parent
5bff89a58f
commit
aead730d28
|
@ -55,4 +55,5 @@
|
|||
{:check (i18n/label :t/emojis)})
|
||||
(validators/has-special-characters? s) (i18n/label :t/are-not-allowed
|
||||
{:check (i18n/label :t/special-characters)})
|
||||
(name-too-short? s) (i18n/label :t/minimum-characters {:min-chars min-length})
|
||||
(name-too-long? s) (i18n/label :t/nickname-is-too-long)))
|
||||
|
|
|
@ -19,16 +19,19 @@
|
|||
profile-picture (profile.utils/photo profile)
|
||||
[unsaved-nickname set-unsaved-nickname] (rn/use-state nickname)
|
||||
[error-msg set-error-msg] (rn/use-state nil)
|
||||
[typing? set-typing?] (rn/use-state false)
|
||||
has-nickname? (rn/use-memo (fn [] (not (string/blank? nickname)))
|
||||
[nickname])
|
||||
validate-nickname (rn/use-callback
|
||||
(debounce/debounce
|
||||
(fn [name]
|
||||
(set-error-msg
|
||||
(profile-validator/validation-nickname name)))
|
||||
(profile-validator/validation-nickname name))
|
||||
(set-typing? false))
|
||||
300))
|
||||
on-cancel (rn/use-callback #(rf/dispatch [:hide-bottom-sheet]))
|
||||
on-nickname-change (rn/use-callback (fn [text]
|
||||
(set-typing? true)
|
||||
(set-unsaved-nickname text)
|
||||
(validate-nickname text)))
|
||||
on-nickname-submit (rn/use-callback
|
||||
|
@ -74,7 +77,8 @@
|
|||
[quo/bottom-actions
|
||||
{:actions :two-actions
|
||||
:button-one-label (i18n/label (if has-nickname? :t/update-nickname-title :t/add-nickname-title))
|
||||
:button-one-props {:disabled? (or (string/blank? unsaved-nickname)
|
||||
:button-one-props {:disabled? (or typing?
|
||||
(string/blank? unsaved-nickname)
|
||||
(not (string/blank? error-msg)))
|
||||
:customization-color customization-color
|
||||
:on-press on-nickname-submit}
|
||||
|
|
Loading…
Reference in New Issue