-
Notifications
You must be signed in to change notification settings - Fork 480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New school info interstitial #20390
New school info interstitial #20390
Conversation
3085ba9
to
49d35bd
Compare
d4a24f3
to
c287911
Compare
> | ||
<div style={styles.container}> | ||
<div style={styles.heading}> | ||
We want to bring Computer Science to every student - help us track our progress! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be localized? (Sim. other text)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks for the reminder. Added to the TODO list in the PR description.
const initialNcesSchoolId = existingSchoolInfo.school_id ? | ||
existingSchoolInfo.school_id : | ||
( | ||
existingSchoolInfo.country === 'United States' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure that you also need to check existingSchoolInfo.country === 'US'
We seem to be inconsistent about how we specify the country in school_info
. Sometimes it is set to a two-character country code and sometimes to the country name. The validation logic doesn't check this and the column is longer than two characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, it looks like you actually map 'US'
to 'United States'
in _school_info_interstitial.html.haml
.
Perhaps add a comment here to call that out. Also, if we are doing that mapping in the haml then why not also do the mapping of school_id
to "-1"
there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point.
I added this code because I discovered a funny edge case for partial entry: We never send/save a school id of "-1"
to the database, so there's nothing to differentiate a form submitted where there's been no interaction with the school autocomplete dropdown (school_id
is null
) and one where the user has checked "I can't find my school" but hasn't entered any details yet (school_id
is "-1"
) - in essence, we don't serialize the state of that checkbox.
As much as possible, I'd like all the business logic around this component to live in one layer, and the checkbox state in particular seems like a UI concern so I think it should live with the React component. So I'm leaning toward moving the US/United States
logic into the React component as well. Does that sound okay to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably easier to test that stuff in the React layer than in a HAML file, too.
// TODO (bbuchanan): Gather metrics on this. | ||
this.props.onClose(); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this unknown error because we don't expect any validation to run on the submission?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a a fallback in case of an unexpected error response on submission - likely caused by the service being temporarily unavailable, so we ask the teacher to try again at least once. Based on this handler in the Census Teacher Banner:
code-dot-org/apps/src/templates/census2017/CensusTeacherBanner.jsx
Lines 194 to 199 in e98992f
updateSchoolInfoError= () => { | |
// It isn't clear what could cause an error here since none of the fields are required. | |
this.setState({ | |
showSchoolInfoUnknownError: true, | |
}); | |
}; |
}; | ||
|
||
static defaultProps = { | ||
onClose: function () {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it actually make sense to use this component without providing a meaningful onClose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only in a storybook/test context. I'll clear this out.
schoolZip={this.state.schoolZip} | ||
schoolLocation={this.state.schoolLocation} | ||
useGoogleLocationSearch={false} | ||
showErrors={false} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the schoolLocation
value even get used if useGoogleLocationSearch
is false?
"user[school_info_attributes][school_state]": this.state.schoolState, | ||
"user[school_info_attributes][school_zip]": this.state.schoolZip, | ||
"user[school_info_attributes][full_address]": this.state.schoolLocation, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like this.state.schoolLocation
ever gets updated from the original value. Since you aren't using the google location search this should probably get set to null here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually don't know whether we want the google location search or not - I'll check with Poorva. What's the potential harm in keeping this wired up, to minimize the work to enable it later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case that the user entered new info, you will be keeping the old full_address
resulting in a mashup of the old and new data. If they are submitting the form then the old data ought to be cleared out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh - the guidance I got was that this dialog should be like the school info on the signup page as much as possible, and that one uses Google Location search. So instead of removing this I'm going to enable that feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep in mind the note here about including the google maps script.
Replace the existing, HAML-and-jQuery School Info Interstitial with a React one that reuses the new
SchoolInfoInputs
component that has school autocomplete and other flow we want to replicate.Guidance on this feature:
TODO:
Test code that manages when we re-display the interstitialDoing in a separate PR.New unit tests: