mirror of
https://github.com/penpot/penpot.git
synced 2025-05-16 05:56:10 +02:00
♻️ Fix many issues on profile settings page.
This commit is contained in:
parent
8d6d839878
commit
b39d747e8f
7 changed files with 68 additions and 33 deletions
|
@ -12,6 +12,8 @@
|
|||
[rumext.alpha :as mf]
|
||||
[uxbox.builtins.icons :as i]
|
||||
[uxbox.main.refs :as refs]
|
||||
[uxbox.main.store :as st]
|
||||
[uxbox.util.router :as rt]
|
||||
[uxbox.main.ui.dashboard.profile :refer [profile-section]]
|
||||
[uxbox.main.ui.messages :refer [messages-widget]]
|
||||
[uxbox.main.ui.settings.header :refer [header]]
|
||||
|
@ -24,11 +26,10 @@
|
|||
profile (mf/deref refs/profile)]
|
||||
[:main.settings-main
|
||||
[:& messages-widget]
|
||||
|
||||
[:section.settings-layout
|
||||
[:div.main-logo i/logo-icon]
|
||||
[:div.left-bar]
|
||||
[:div.settings-content
|
||||
[:div.main-logo {:on-click #(st/emit! (rt/nav :dashboard-team {:team-id "self"}))}
|
||||
i/logo-icon]
|
||||
[:& header {:section section}]
|
||||
(case section
|
||||
:settings-profile (mf/element profile-page)
|
||||
|
|
|
@ -20,12 +20,13 @@
|
|||
password? (= section :settings-password)
|
||||
locale (i18n/use-locale)]
|
||||
[:header.main-bar
|
||||
[:nav.library-header-navigation
|
||||
[:a.library-header-navigation-item
|
||||
[:nav
|
||||
[:a.nav-item
|
||||
{:class (when profile? "current")
|
||||
:on-click #(st/emit! (rt/nav :settings-profile))}
|
||||
(t locale "settings.profile")]
|
||||
[:a.library-header-navigation-item
|
||||
[:a.nav-item
|
||||
{:class (when password? "current")
|
||||
:on-click #(st/emit! (rt/nav :settings-password))}
|
||||
(t locale "settings.password")]]]))
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
:validators [password-equality]
|
||||
:initial {})]
|
||||
[:form.password-form {:on-submit #(on-submit % form)}
|
||||
[:span.user-settings-label (tr "settings.password.change-password")]
|
||||
[:span.settings-label (tr "settings.password.change-password")]
|
||||
[:input.input-text
|
||||
{:type "password"
|
||||
:name "password-old"
|
||||
|
@ -105,5 +105,5 @@
|
|||
|
||||
(mf/defc password-page
|
||||
[props]
|
||||
[:section.user-settings-page
|
||||
[:section.settings-password
|
||||
[:& password-form]])
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
(l/derive st/state)))
|
||||
|
||||
(s/def ::fullname ::fm/not-empty-string)
|
||||
(s/def ::lang ::fm/not-empty-string)
|
||||
(s/def ::lang (s/nilable ::fm/not-empty-string))
|
||||
(s/def ::email ::fm/email)
|
||||
|
||||
(s/def ::profile-form
|
||||
|
@ -59,9 +59,12 @@
|
|||
(mf/defc profile-form
|
||||
[props]
|
||||
(let [locale (i18n/use-locale)
|
||||
{:keys [data] :as form} (fm/use-form ::profile-form #(deref profile-iref))]
|
||||
form (fm/use-form ::profile-form #(deref profile-iref))
|
||||
data (:data form)]
|
||||
(prn "data" form)
|
||||
[:form.profile-form {:on-submit #(on-submit % form)}
|
||||
[:span.user-settings-label (t locale "settings.profile.section-basic-data")]
|
||||
[:span.settings-label (t locale "settings.profile.section-basic-data")]
|
||||
|
||||
[:input.input-text
|
||||
{:type "text"
|
||||
:name "fullname"
|
||||
|
@ -70,7 +73,6 @@
|
|||
:on-change (fm/on-input-change form :fullname)
|
||||
:value (:fullname data "")
|
||||
:placeholder (t locale "settings.profile.your-name")}]
|
||||
|
||||
[:& fm/field-error {:form form
|
||||
:type #{::api}
|
||||
:field :fullname}]
|
||||
|
@ -83,13 +85,12 @@
|
|||
:on-change (fm/on-input-change form :email)
|
||||
:value (:email data "")
|
||||
:placeholder (t locale "settings.profile.your-email")}]
|
||||
|
||||
[:& fm/field-error {:form form
|
||||
:type #{::api}
|
||||
:field :email}]
|
||||
|
||||
[:span.user-settings-label (t locale "settings.profile.lang")]
|
||||
[:select.input-select {:value (:lang data)
|
||||
[:span.settings-label (t locale "settings.profile.lang")]
|
||||
[:select.input-select {:value (or (:lang data) "en")
|
||||
:name "lang"
|
||||
:class (fm/error-class form :lang)
|
||||
:on-blur (fm/on-input-blur form :lang)
|
||||
|
@ -107,7 +108,8 @@
|
|||
|
||||
(mf/defc profile-photo-form
|
||||
[props]
|
||||
(let [photo (:photo-uri (mf/deref profile-iref))
|
||||
(let [profile (mf/deref profile-iref)
|
||||
photo (:photo-uri profile)
|
||||
photo (if (or (str/empty? photo) (nil? photo))
|
||||
"images/avatar.jpg"
|
||||
photo)
|
||||
|
@ -129,8 +131,10 @@
|
|||
;; --- Profile Page
|
||||
|
||||
(mf/defc profile-page
|
||||
[]
|
||||
[:section.user-settings-page
|
||||
[:span.user-settings-label (tr "settings.profile.your-avatar")]
|
||||
[:& profile-photo-form]
|
||||
[:& profile-form]])
|
||||
{::mf/wrap-props false}
|
||||
[props]
|
||||
(let [locale (i18n/use-locale)]
|
||||
[:section.settings-profile
|
||||
[:span.settings-label (t locale "settings.profile.your-avatar")]
|
||||
[:& profile-photo-form]
|
||||
[:& profile-form]]))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue