profile: Redirect user to the console when he tries to edit phone number on profile page (#701)

Since phone change requires sms verification, we don't want user let to edit it directly on profile page.
Instead, we redirect him to the Console automatically issuing :phone command.
This commit is contained in:
Juraj Martinka 2017-01-27 16:42:45 +01:00 committed by Roman Volosovskyi
parent dc01b9e3b7
commit 71ba979671
1 changed files with 15 additions and 3 deletions

View File

@ -33,7 +33,8 @@
[status-im.utils.utils :refer [clean-text]] [status-im.utils.utils :refer [clean-text]]
[status-im.components.image-button.view :refer [show-qr-button]] [status-im.components.image-button.view :refer [show-qr-button]]
[status-im.i18n :refer [label [status-im.i18n :refer [label
get-contact-translated]])) get-contact-translated]]
[status-im.constants :refer [console-chat-id wallet-chat-id]]))
(defn toolbar [{:keys [account edit?]}] (defn toolbar [{:keys [account edit?]}]
(let [profile-edit-data-valid? (s/valid? ::v/profile account)] (let [profile-edit-data-valid? (s/valid? ::v/profile account)]
@ -113,6 +114,13 @@
[status-view {:style (st/status-text (:height (r/state component))) [status-view {:style (st/status-text (:height (r/state component)))
:status status}])])}))) :status status}])])})))
(defn- navigate-to-phone-change
"Switch user to the console issuing the !phone command automatically to let him change his phone number."
[]
(dispatch [:navigate-to :chat console-chat-id])
(dispatch [:set-chat-command :phone])
)
(defview profile [] (defview profile []
[{whisper-identity :whisper-identity [{whisper-identity :whisper-identity
address :address address :address
@ -155,10 +163,13 @@
[view st/profile-property-with-top-spacing [view st/profile-property-with-top-spacing
[selectable-field {:label (label :t/phone-number) [selectable-field {:label (label :t/phone-number)
:editable? false :editable? false
:value (if (and phone (not (str/blank? phone))) :value (if (and phone (not (str/blank? phone)))
(format-phone-number phone) (format-phone-number phone)
(label :t/not-specified))}] (label :t/not-specified))
;; TODO: should this be changed?
:on-press navigate-to-phone-change}]
[view st/underline-container]] [view st/underline-container]]
(when address (when address
@ -211,7 +222,8 @@
:editable? edit? :editable? edit?
:value (if (and phone (not (str/blank? phone))) :value (if (and phone (not (str/blank? phone)))
(format-phone-number phone) (format-phone-number phone)
(label :t/not-specified))}] (label :t/not-specified))
:on-press navigate-to-phone-change}]
[view st/underline-container]] [view st/underline-container]]
[view st/profile-property [view st/profile-property