From 0353135cc4c09f7526156a0cd557b7b58e3026e4 Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Fri, 26 Feb 2021 10:31:03 -0500 Subject: [PATCH] Split phone number step to reduce bundle for other registration pages --- .../registration/phone-number-step.jsx | 107 ++++++++++++++++++ src/components/registration/steps.jsx | 89 --------------- .../teacherregistration.jsx | 3 +- 3 files changed, 109 insertions(+), 90 deletions(-) create mode 100644 src/components/registration/phone-number-step.jsx diff --git a/src/components/registration/phone-number-step.jsx b/src/components/registration/phone-number-step.jsx new file mode 100644 index 000000000..7a086a68e --- /dev/null +++ b/src/components/registration/phone-number-step.jsx @@ -0,0 +1,107 @@ +/* eslint-disable react/no-multi-comp */ +const bindAll = require('lodash.bindall'); +const injectIntl = require('react-intl').injectIntl; +const intlShape = require('react-intl').intlShape; +const PropTypes = require('prop-types'); +const React = require('react'); + +const intl = require('../../lib/intl.jsx'); + +const Card = require('../../components/card/card.jsx'); +const Checkbox = require('../../components/forms/checkbox.jsx'); +const Form = require('../../components/forms/form.jsx'); +const PhoneInput = require('../../components/forms/phone-input.jsx'); +const Slide = require('../../components/slide/slide.jsx'); +const StepNavigation = require('../../components/stepnavigation/stepnavigation.jsx'); +const Tooltip = require('../../components/tooltip/tooltip.jsx'); + +require('./steps.scss'); + +/* + * This step is separate from the other steps because it includes a large library + * for phone number validation. + */ +class PhoneNumberStep extends React.Component { + constructor (props) { + super(props); + bindAll(this, [ + 'handleValidSubmit' + ]); + } + handleValidSubmit(formData, reset, invalidate) { + if (!formData.phone || formData.phone.national_number === '+') { + return invalidate({ + phone: this.props.intl.formatMessage({id: 'form.validationRequired'}) + }); + } + return this.props.onNextStep(formData); + } + render() { + return ( + +

+ +

+

+ + +

+ +
+ + + } + waiting={this.props.waiting} + /> + +
+ +
+ ); + } +} + +PhoneNumberStep.propTypes = { + activeStep: PropTypes.number, + defaultCountry: PropTypes.string, + intl: intlShape, + onNextStep: PropTypes.func, + totalSteps: PropTypes.number, + waiting: PropTypes.bool +}; + +PhoneNumberStep.defaultProps = { + defaultCountry: DEFAULT_COUNTRY, + waiting: false +}; + +const IntlPhoneNumberStep = injectIntl(PhoneNumberStep); + +module.exports = IntlPhoneNumberStep; \ No newline at end of file diff --git a/src/components/registration/steps.jsx b/src/components/registration/steps.jsx index 35f6b6800..29d6bae9e 100644 --- a/src/components/registration/steps.jsx +++ b/src/components/registration/steps.jsx @@ -20,7 +20,6 @@ const CheckboxGroup = require('../../components/forms/checkbox-group.jsx'); const Form = require('../../components/forms/form.jsx'); const GeneralError = require('../../components/forms/general-error.jsx'); const Input = require('../../components/forms/input.jsx'); -const PhoneInput = require('../../components/forms/phone-input.jsx'); const RadioGroup = require('../../components/forms/radio-group.jsx'); const Select = require('../../components/forms/select.jsx'); const Slide = require('../../components/slide/slide.jsx'); @@ -703,93 +702,6 @@ NameStep.defaultProps = { const IntlNameStep = injectIntl(NameStep); -/* - * PHONE NUMBER STEP - */ -class PhoneNumberStep extends React.Component { - constructor (props) { - super(props); - bindAll(this, [ - 'handleValidSubmit' - ]); - } - handleValidSubmit (formData, reset, invalidate) { - if (!formData.phone || formData.phone.national_number === '+') { - return invalidate({ - phone: this.props.intl.formatMessage({id: 'form.validationRequired'}) - }); - } - return this.props.onNextStep(formData); - } - render () { - return ( - -

- -

-

- - -

- -
- - - } - waiting={this.props.waiting} - /> - -
- -
- ); - } -} - -PhoneNumberStep.propTypes = { - activeStep: PropTypes.number, - defaultCountry: PropTypes.string, - intl: intlShape, - onNextStep: PropTypes.func, - totalSteps: PropTypes.number, - waiting: PropTypes.bool -}; - -PhoneNumberStep.defaultProps = { - defaultCountry: DEFAULT_COUNTRY, - waiting: false -}; - -const IntlPhoneNumberStep = injectIntl(PhoneNumberStep); - - /* * ORGANIZATION STEP */ @@ -1670,7 +1582,6 @@ module.exports.UsernameStep = IntlUsernameStep; module.exports.ChoosePasswordStep = IntlChoosePasswordStep; module.exports.DemographicsStep = IntlDemographicsStep; module.exports.NameStep = IntlNameStep; -module.exports.PhoneNumberStep = IntlPhoneNumberStep; module.exports.OrganizationStep = IntlOrganizationStep; module.exports.AddressStep = IntlAddressStep; module.exports.UseScratchStep = IntlUseScratchStep; diff --git a/src/views/teacherregistration/teacherregistration.jsx b/src/views/teacherregistration/teacherregistration.jsx index 2936ad82f..5ed13a600 100644 --- a/src/views/teacherregistration/teacherregistration.jsx +++ b/src/views/teacherregistration/teacherregistration.jsx @@ -12,6 +12,7 @@ const sessionActions = require('../../redux/session.js'); const Deck = require('../../components/deck/deck.jsx'); const Progression = require('../../components/progression/progression.jsx'); const Steps = require('../../components/registration/steps.jsx'); +const PhoneNumberStep = require('../../components/registration/phone-number-step.jsx'); const render = require('../../lib/render.jsx'); @@ -119,7 +120,7 @@ class TeacherRegistration extends React.Component { waiting={this.state.waiting} onNextStep={this.handleAdvanceStep} /> -