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
1bab2bb5
Unverified
Commit
1bab2bb5
authored
May 13, 2020
by
Chris Willis-Ford
Committed by
GitHub
May 13, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3856 from cwillisf/day1-student-country-default
default student's country to educator's during reg
parents
7a666123
4bd81362
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
+11
-2
src/components/registration/steps.jsx
src/components/registration/steps.jsx
+9
-2
src/views/studentregistration/studentregistration.jsx
src/views/studentregistration/studentregistration.jsx
+2
-0
No files found.
src/components/registration/steps.jsx
View file @
1bab2bb5
...
...
@@ -453,7 +453,7 @@ class DemographicsStep extends React.Component {
handleChooseGender
(
name
,
gender
)
{
this
.
setState
({
otherDisabled
:
gender
!==
'
other
'
});
}
// look up country name using user's country code selection
// look up country name using user's country code selection
('us' -> 'United States')
getCountryName
(
values
)
{
if
(
values
.
countryCode
)
{
const
countryInfo
=
countryData
.
lookupCountryInfo
(
values
.
countryCode
);
...
...
@@ -463,6 +463,12 @@ class DemographicsStep extends React.Component {
}
return
null
;
}
// look up country code from country label ('United States' -> 'us')
// if `countryName` is not found, including if it's null or undefined, then this function will return undefined.
getCountryCode
(
countryName
)
{
const
country
=
countryData
.
countryInfo
.
find
(
countryItem
=>
countryItem
.
name
===
countryName
);
return
country
&&
country
.
code
;
}
handleValidSubmit
(
formData
)
{
const
countryName
=
this
.
getCountryName
(
formData
);
if
(
countryName
&&
formData
.
user
)
{
...
...
@@ -573,7 +579,7 @@ class DemographicsStep extends React.Component {
validations=
{
{
countryVal
:
values
=>
this
.
countryValidator
(
values
)
}
}
value=
{
countryOptions
[
0
].
value
}
value=
{
this
.
getCountryCode
(
this
.
props
.
countryName
)
||
countryOptions
[
0
].
value
}
/>
<
Checkbox
className=
"demographics-checkbox-is-robot"
...
...
@@ -598,6 +604,7 @@ class DemographicsStep extends React.Component {
DemographicsStep
.
propTypes
=
{
activeStep
:
PropTypes
.
number
,
birthOffset
:
PropTypes
.
number
,
countryName
:
PropTypes
.
string
,
// like 'United States', not 'US' or 'United States of America'
description
:
PropTypes
.
string
,
intl
:
intlShape
,
onNextStep
:
PropTypes
.
func
,
...
...
src/views/studentregistration/studentregistration.jsx
View file @
1bab2bb5
...
...
@@ -132,6 +132,8 @@ class StudentRegistration extends React.Component {
onNextStep=
{
this
.
handleAdvanceStep
}
/>
<
Steps
.
DemographicsStep
countryName=
{
this
.
state
.
classroom
&&
this
.
state
.
classroom
.
educator
&&
this
.
state
.
classroom
.
educator
.
profile
&&
this
.
state
.
classroom
.
educator
.
profile
.
country
}
description=
{
this
.
props
.
intl
.
formatMessage
({
id
:
'
registration.studentPersonalStepDescription
'
})
}
...
...
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