|
11 | 11 | (:require-macros [status-im.utils.views :refer [defview letsubs]]))
|
12 | 12 |
|
13 | 13 | (defn input-field
|
14 |
| - ([id errors on-submit] (input-field id errors on-submit false)) |
15 |
| - ([id errors on-submit focus?] |
| 14 | + [{:keys [id errors on-submit disabled? focus?] |
| 15 | + :or {disabled? false focus? false}}] |
| 16 | + [react/view {:style {:opacity (if disabled? 0.33 1)}} |
16 | 17 | [quo/text-input
|
17 | 18 | {:placeholder (i18n/label id)
|
18 | 19 | :default-value ""
|
19 | 20 | :auto-focus focus?
|
| 21 | + :editable (not disabled?) |
20 | 22 | :accessibility-label id
|
21 | 23 | :show-cancel false
|
22 | 24 | :style {:margin-bottom 32}
|
|
28 | 30 | :error (when-let [error (get errors id)]
|
29 | 31 | (if (keyword? error)
|
30 | 32 | (i18n/label error)
|
31 |
| - error))}])) |
| 33 | + error))}]]) |
32 | 34 |
|
33 | 35 | (defview reset-password []
|
34 | 36 | (letsubs [{:keys [form-vals errors next-enabled?]}
|
35 | 37 | [:multiaccount/reset-password-form-vals-and-errors]]
|
36 |
| - (let [on-submit #(re-frame/dispatch [::reset-password/reset form-vals])] |
| 38 | + (let [{:keys [current-password |
| 39 | + new-password]} form-vals |
| 40 | + on-submit #(re-frame/dispatch [::reset-password/reset form-vals])] |
37 | 41 | [react/keyboard-avoiding-view {:flex 1}
|
38 | 42 | [react/view {:style {:flex 1
|
39 | 43 | :justify-content :space-between}}
|
40 |
| - [react/view {:style {:padding-horizontal 16 |
| 44 | + [react/view {:style {:margin-top 32 |
| 45 | + :padding-horizontal 16 |
41 | 46 | :padding-vertical 16}}
|
42 |
| - [input-field :current-password errors on-submit true] |
43 |
| - [input-field :new-password errors on-submit] |
44 |
| - [input-field :confirm-new-password errors on-submit]] |
| 47 | + [input-field {:id :current-password |
| 48 | + :errors errors |
| 49 | + :on-sumbit on-submit |
| 50 | + :disabled? false |
| 51 | + :focus? true}] |
| 52 | + [input-field {:id :new-password |
| 53 | + :errors errors |
| 54 | + :on-sumbit on-submit |
| 55 | + :disabled? (zero? (count current-password))}] |
| 56 | + [input-field {:id :confirm-new-password |
| 57 | + :errors errors |
| 58 | + :on-sumbit on-submit |
| 59 | + :disabled? (zero? (count new-password))}]] |
45 | 60 | [quo/text {:color :secondary :align :center :size :small
|
46 | 61 | :style {:padding-horizontal 16}}
|
47 | 62 | (i18n/label :t/password-description)]
|
|
85 | 100 | [react/view {:align-items :center}
|
86 | 101 | [quo/button {:on-press #(re-frame/dispatch [:hide-popover])
|
87 | 102 | :disabled resetting?}
|
88 |
| - (i18n/label :t/ok-got-it)]]])) |
| 103 | + (i18n/label :t/okay)]]])) |
0 commit comments