Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
0353135c
Commit
0353135c
authored
Feb 26, 2021
by
Paul Kaplan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split phone number step to reduce bundle for other registration pages
parent
da2ca40c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
90 deletions
+109
-90
src/components/registration/phone-number-step.jsx
src/components/registration/phone-number-step.jsx
+107
-0
src/components/registration/steps.jsx
src/components/registration/steps.jsx
+0
-89
src/views/teacherregistration/teacherregistration.jsx
src/views/teacherregistration/teacherregistration.jsx
+2
-1
No files found.
src/components/registration/phone-number-step.jsx
0 → 100644
View file @
0353135c
/* 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
(
<
Slide
className=
"registration-step phone-step"
>
<
h2
>
<
intl
.
FormattedMessage
id=
"teacherRegistration.phoneNumber"
/>
</
h2
>
<
p
className=
"description"
>
<
intl
.
FormattedMessage
id=
"teacherRegistration.phoneStepDescription"
/>
<
Tooltip
tipContent=
{
this
.
props
.
intl
.
formatMessage
({
id
:
'
registration.nameStepTooltip
'
})
}
title=
{
'
?
'
}
/>
</
p
>
<
Card
>
<
Form
onValidSubmit=
{
this
.
handleValidSubmit
}
>
<
PhoneInput
required
defaultCountry=
{
this
.
props
.
defaultCountry
}
label=
{
this
.
props
.
intl
.
formatMessage
({
id
:
'
teacherRegistration.phoneNumber
'
})
}
name=
"phone"
/>
<
Checkbox
name=
"phoneConsent"
required=
"isFalse"
validationErrors=
{
{
isFalse
:
this
.
props
.
intl
.
formatMessage
({
id
:
'
teacherRegistration.validationPhoneConsent
'
})
}
}
valueLabel=
{
this
.
props
.
intl
.
formatMessage
({
id
:
'
teacherRegistration.phoneConsent
'
})
}
/>
<
NextStepButton
text=
{
<
intl
.
FormattedMessage
id=
"registration.nextStep"
/>
}
waiting=
{
this
.
props
.
waiting
}
/>
</
Form
>
</
Card
>
<
StepNavigation
active=
{
this
.
props
.
activeStep
}
steps=
{
this
.
props
.
totalSteps
-
1
}
/>
</
Slide
>
);
}
}
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
src/components/registration/steps.jsx
View file @
0353135c
...
@@ -20,7 +20,6 @@ const CheckboxGroup = require('../../components/forms/checkbox-group.jsx');
...
@@ -20,7 +20,6 @@ const CheckboxGroup = require('../../components/forms/checkbox-group.jsx');
const
Form
=
require
(
'
../../components/forms/form.jsx
'
);
const
Form
=
require
(
'
../../components/forms/form.jsx
'
);
const
GeneralError
=
require
(
'
../../components/forms/general-error.jsx
'
);
const
GeneralError
=
require
(
'
../../components/forms/general-error.jsx
'
);
const
Input
=
require
(
'
../../components/forms/input.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
RadioGroup
=
require
(
'
../../components/forms/radio-group.jsx
'
);
const
Select
=
require
(
'
../../components/forms/select.jsx
'
);
const
Select
=
require
(
'
../../components/forms/select.jsx
'
);
const
Slide
=
require
(
'
../../components/slide/slide.jsx
'
);
const
Slide
=
require
(
'
../../components/slide/slide.jsx
'
);
...
@@ -703,93 +702,6 @@ NameStep.defaultProps = {
...
@@ -703,93 +702,6 @@ NameStep.defaultProps = {
const
IntlNameStep
=
injectIntl
(
NameStep
);
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
(
<
Slide
className=
"registration-step phone-step"
>
<
h2
>
<
intl
.
FormattedMessage
id=
"teacherRegistration.phoneNumber"
/>
</
h2
>
<
p
className=
"description"
>
<
intl
.
FormattedMessage
id=
"teacherRegistration.phoneStepDescription"
/>
<
Tooltip
tipContent=
{
this
.
props
.
intl
.
formatMessage
({
id
:
'
registration.nameStepTooltip
'
})
}
title=
{
'
?
'
}
/>
</
p
>
<
Card
>
<
Form
onValidSubmit=
{
this
.
handleValidSubmit
}
>
<
PhoneInput
required
defaultCountry=
{
this
.
props
.
defaultCountry
}
label=
{
this
.
props
.
intl
.
formatMessage
({
id
:
'
teacherRegistration.phoneNumber
'
})
}
name=
"phone"
/>
<
Checkbox
name=
"phoneConsent"
required=
"isFalse"
validationErrors=
{
{
isFalse
:
this
.
props
.
intl
.
formatMessage
({
id
:
'
teacherRegistration.validationPhoneConsent
'
})
}
}
valueLabel=
{
this
.
props
.
intl
.
formatMessage
({
id
:
'
teacherRegistration.phoneConsent
'
})
}
/>
<
NextStepButton
text=
{
<
intl
.
FormattedMessage
id=
"registration.nextStep"
/>
}
waiting=
{
this
.
props
.
waiting
}
/>
</
Form
>
</
Card
>
<
StepNavigation
active=
{
this
.
props
.
activeStep
}
steps=
{
this
.
props
.
totalSteps
-
1
}
/>
</
Slide
>
);
}
}
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
* ORGANIZATION STEP
*/
*/
...
@@ -1670,7 +1582,6 @@ module.exports.UsernameStep = IntlUsernameStep;
...
@@ -1670,7 +1582,6 @@ module.exports.UsernameStep = IntlUsernameStep;
module
.
exports
.
ChoosePasswordStep
=
IntlChoosePasswordStep
;
module
.
exports
.
ChoosePasswordStep
=
IntlChoosePasswordStep
;
module
.
exports
.
DemographicsStep
=
IntlDemographicsStep
;
module
.
exports
.
DemographicsStep
=
IntlDemographicsStep
;
module
.
exports
.
NameStep
=
IntlNameStep
;
module
.
exports
.
NameStep
=
IntlNameStep
;
module
.
exports
.
PhoneNumberStep
=
IntlPhoneNumberStep
;
module
.
exports
.
OrganizationStep
=
IntlOrganizationStep
;
module
.
exports
.
OrganizationStep
=
IntlOrganizationStep
;
module
.
exports
.
AddressStep
=
IntlAddressStep
;
module
.
exports
.
AddressStep
=
IntlAddressStep
;
module
.
exports
.
UseScratchStep
=
IntlUseScratchStep
;
module
.
exports
.
UseScratchStep
=
IntlUseScratchStep
;
...
...
src/views/teacherregistration/teacherregistration.jsx
View file @
0353135c
...
@@ -12,6 +12,7 @@ const sessionActions = require('../../redux/session.js');
...
@@ -12,6 +12,7 @@ const sessionActions = require('../../redux/session.js');
const
Deck
=
require
(
'
../../components/deck/deck.jsx
'
);
const
Deck
=
require
(
'
../../components/deck/deck.jsx
'
);
const
Progression
=
require
(
'
../../components/progression/progression.jsx
'
);
const
Progression
=
require
(
'
../../components/progression/progression.jsx
'
);
const
Steps
=
require
(
'
../../components/registration/steps.jsx
'
);
const
Steps
=
require
(
'
../../components/registration/steps.jsx
'
);
const
PhoneNumberStep
=
require
(
'
../../components/registration/phone-number-step.jsx
'
);
const
render
=
require
(
'
../../lib/render.jsx
'
);
const
render
=
require
(
'
../../lib/render.jsx
'
);
...
@@ -119,7 +120,7 @@ class TeacherRegistration extends React.Component {
...
@@ -119,7 +120,7 @@ class TeacherRegistration extends React.Component {
waiting=
{
this
.
state
.
waiting
}
waiting=
{
this
.
state
.
waiting
}
onNextStep=
{
this
.
handleAdvanceStep
}
onNextStep=
{
this
.
handleAdvanceStep
}
/>
/>
<
Steps
.
PhoneNumberStep
<
PhoneNumberStep
defaultCountry=
{
this
.
state
.
formData
.
countryCode
}
defaultCountry=
{
this
.
state
.
formData
.
countryCode
}
waiting=
{
this
.
state
.
waiting
}
waiting=
{
this
.
state
.
waiting
}
onNextStep=
{
this
.
handleAdvanceStep
}
onNextStep=
{
this
.
handleAdvanceStep
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment