diff --git a/app/javascript/onboarding/components/FollowTags.jsx b/app/javascript/onboarding/components/FollowTags.jsx
index 47d7e39de..3a2b00677 100644
--- a/app/javascript/onboarding/components/FollowTags.jsx
+++ b/app/javascript/onboarding/components/FollowTags.jsx
@@ -97,11 +97,14 @@ class FollowTags extends Component {
render() {
const { prev, currentSlideIndex, slidesCount } = this.props;
const { selectedTags, allTags } = this.state;
+ const canSkip = selectedTags.length === 0;
+
return (
diff --git a/app/javascript/onboarding/components/FollowUsers.jsx b/app/javascript/onboarding/components/FollowUsers.jsx
index 04f4b2cc7..604106d09 100644
--- a/app/javascript/onboarding/components/FollowUsers.jsx
+++ b/app/javascript/onboarding/components/FollowUsers.jsx
@@ -130,12 +130,14 @@ class FollowUsers extends Component {
render() {
const { users, selectedUsers } = this.state;
const { prev, slidesCount, currentSlideIndex } = this.props;
+ const canSkip = selectedUsers.length === 0;
return (
diff --git a/app/javascript/onboarding/components/Navigation.jsx b/app/javascript/onboarding/components/Navigation.jsx
index f74576038..c175d7ed4 100644
--- a/app/javascript/onboarding/components/Navigation.jsx
+++ b/app/javascript/onboarding/components/Navigation.jsx
@@ -27,8 +27,36 @@ class Navigation extends Component {
return
{stepsList}
;
}
+ /**
+ * A function to render the text for the "next-button" within the `Navigation` component.
+ * By default, it renders "Continue" for every slide.
+ * If the slide can be skipped, it renders "Skip for now".
+ * On the final slide, it renders "Finish".
+ *
+ * @returns {String} The HTML markup for the stepper.
+ */
+ buttonText() {
+ const { canSkip, currentSlideIndex, slidesCount } = this.props;
+ if (slidesCount - 1 === currentSlideIndex) {
+ return 'Finish';
+ }
+ if (canSkip) {
+ return 'Skip for now';
+ }
+
+ return 'Continue';
+ }
+
render() {
- const { next, prev, hideNext, hidePrev, disabled, className } = this.props;
+ const {
+ next,
+ prev,
+ hideNext,
+ hidePrev,
+ disabled,
+ canSkip,
+ className,
+ } = this.props;
return (
{!hidePrev && (
-
-
-
-
-
+
)}
{this.createStepper()}
@@ -60,10 +90,10 @@ class Navigation extends Component {
- Continue
+ {this.buttonText()}
)}
@@ -74,6 +104,7 @@ class Navigation extends Component {
Navigation.propTypes = {
disabled: PropTypes.bool,
+ canSkip: PropTypes.bool,
className: PropTypes.string,
prev: PropTypes.func.isRequired,
next: PropTypes.string.isRequired,
@@ -85,6 +116,7 @@ Navigation.propTypes = {
Navigation.defaultProps = {
disabled: false,
+ canSkip: false,
hideNext: false,
hidePrev: false,
className: '',
diff --git a/app/javascript/onboarding/components/ProfileForm.jsx b/app/javascript/onboarding/components/ProfileForm.jsx
index 78015117b..7b023b923 100644
--- a/app/javascript/onboarding/components/ProfileForm.jsx
+++ b/app/javascript/onboarding/components/ProfileForm.jsx
@@ -14,27 +14,31 @@ class ProfileForm extends Component {
this.user = userData();
this.state = {
- summary: '',
- location: '',
- employment_title: '',
- employer_name: '',
+ formValues: {
+ summary: '',
+ location: '',
+ employment_title: '',
+ employer_name: '',
+ },
last_onboarding_page: 'v2: personal info form',
+ canSkip: true,
};
}
componentDidMount() {
- updateOnboarding('bio form');
+ updateOnboarding('v2: personal info form');
}
onSubmit() {
const csrfToken = getContentOfToken('csrf-token');
+ const { formValues, last_onboarding_page } = this.state;
fetch('/onboarding_update', {
method: 'PATCH',
headers: {
'X-CSRF-Token': csrfToken,
'Content-Type': 'application/json',
},
- body: JSON.stringify({ user: { ...this.state } }),
+ body: JSON.stringify({ user: { ...formValues, last_onboarding_page } }),
credentials: 'same-origin',
}).then((response) => {
if (response.ok) {
@@ -45,21 +49,31 @@ class ProfileForm extends Component {
}
handleChange(e) {
+ const { formValues } = { ...this.state };
+ const currentFormState = formValues;
const { name, value } = e.target;
- this.setState({
- [name]: value,
- });
+ currentFormState[name] = value;
+
+ // Once we've derived the new form values, check if the form is empty
+ // and use that value to set the `canSkip` property on the state.
+ const formIsEmpty =
+ Object.values(currentFormState).filter((v) => v.length > 0).length === 0;
+
+ this.setState({ formValues: currentFormState, canSkip: formIsEmpty });
}
render() {
const { prev, slidesCount, currentSlideIndex } = this.props;
const { profile_image_90, username, name } = this.user;
+ const { canSkip } = this.state;
+
return (