diff --git a/app/assets/stylesheets/preact/onboarding-modal.scss b/app/assets/stylesheets/preact/onboarding-modal.scss index 3974d24c8..d218c28f3 100644 --- a/app/assets/stylesheets/preact/onboarding-modal.scss +++ b/app/assets/stylesheets/preact/onboarding-modal.scss @@ -446,11 +446,13 @@ $onboarding-user-selected-hover: rgba(71, 85, 235, 0.2); margin-bottom: 1rem; .current-user-avatar-container { + width: 80px; height: 80px; } .current-user-avatar { border-radius: 100%; + width: inherit; height: inherit; object-fit: cover; border: 2px solid var(--base-90); @@ -681,6 +683,40 @@ $onboarding-user-selected-hover: rgba(71, 85, 235, 0.2); } } +.onboarding-profile-details-container { + display: flex; + align-items: center; + padding: 0px; + gap: 24px; +} + +.onboarding-profile-image { + width: 80px; + height: 80px; + aspect-ratio: 1/1; + border-radius: 40px; + border: 1.5px solid #d4d4d4; +} + +.onboarding-profile-details-sub-container { + display: flex; + flex-direction: column; + align-items: flex-start; + padding: 0px; + gap: 10px; +} + +.onboarding-profile-user-name { + font-weight: var(--fw-bol); + font-size: var(--fs-xl); + line-height: var(--lh-base); +} + +.onboarding-profile-upload-error { + color: darken($red, 8%); + font-size: 0.8em; +} + // Adjusting modals... This is naughty... Santa won't come. .onboarding-main { --onboarding-modal-height: 800px; diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 10fcf3afa..790a1dbc3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -43,16 +43,26 @@ class UsersController < ApplicationController end flash[:settings_notice] = notice @user.touch(:profile_updated_at) - redirect_to "/settings/#{@tab}" + respond_to do |format| + format.json { render json: { success: true, user: @user } } + format.html { redirect_to "/settings/#{@tab}" } + end else Honeycomb.add_field("error", @user.errors.messages.compact_blank) Honeycomb.add_field("errored", true) - if @tab - render :edit, status: :bad_request - else - flash[:error] = @user.errors.full_messages.join(", ") - redirect_to "/settings" + error_message = @user.errors.full_messages.join(", ") + + respond_to do |format| + format.json { render json: { success: false, error: error_message }, status: :bad_request } + format.html do + if @tab + render :edit, status: :bad_request + else + flash[:error] = error_message + redirect_to "/settings" + end + end end end end diff --git a/app/javascript/onboarding/components/ProfileForm.jsx b/app/javascript/onboarding/components/ProfileForm.jsx index cbb2865cf..04daf4545 100644 --- a/app/javascript/onboarding/components/ProfileForm.jsx +++ b/app/javascript/onboarding/components/ProfileForm.jsx @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import { userData, updateOnboarding } from '../utilities'; +import { ProfileImage } from './ProfileForm/ProfileImage'; import { Navigation } from './Navigation'; import { TextArea } from './ProfileForm/TextArea'; import { TextInput } from './ProfileForm/TextInput'; @@ -21,9 +22,13 @@ export class ProfileForm extends Component { this.user = userData(); this.state = { groups: [], - formValues: { username: this.user.username }, + formValues: { + username: this.user.username, + profile_image_90: this.user.profile_image_90, + }, canSkip: false, last_onboarding_page: 'v2: personal info form', + profile_image_90: this.user.profile_image_90, }; } @@ -48,12 +53,12 @@ export class ProfileForm extends Component { async onSubmit() { const { formValues, last_onboarding_page } = this.state; - const { username, ...newFormValues } = formValues; + const { username, profile_image_90, ...newFormValues } = formValues; try { const response = await request('/onboarding', { method: 'PATCH', body: { - user: { last_onboarding_page, username }, + user: { last_onboarding_page, profile_image_90, username }, profile: { ...newFormValues }, }, }); @@ -142,10 +147,18 @@ export class ProfileForm extends Component { } } + onProfileImageUrlChange = (url) => { + this.setState({ profile_image_90: url }, () => { + this.handleFieldChange({ + target: { name: 'profile_image_90', value: url }, + }); + }); + }; + render() { const { prev, slidesCount, currentSlideIndex, communityConfig } = this.props; - const { profile_image_90, username, name } = this.user; + const { username, name } = this.user; const { canSkip, groups = [], error, errorMessage } = this.state; const SUMMARY_MAXLENGTH = 200; const summaryCharacters = this.state?.formValues?.summary?.length || 0; @@ -204,15 +217,13 @@ export class ProfileForm extends Component { able to edit this later in your Settings. -
+ {uploadErrorMessage} +
+ )} +