-
Notifications
You must be signed in to change notification settings - Fork 479
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
School Info Confirmation Dialog - fetch school name for signed in user #27742
Changes from all commits
bf86fc8
763dba5
f4704e0
947e03d
e16482a
def9e85
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,24 +21,45 @@ class SchoolInfoConfirmationDialog extends Component { | |
|
||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
showSchoolInterstitial: false, | ||
schoolName: props.schoolName, | ||
isOpen: true | ||
}; | ||
} | ||
|
||
static defaultProps = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do these defaultProps get used? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @epeach The default props will be used unless the parent component over-rides them. |
||
onUpdate: () => {}, | ||
schoolName: '' | ||
}; | ||
|
||
componentDidMount() { | ||
const {schoolName} = this.state; | ||
if (!schoolName && schoolName.length > 0) { | ||
fetch('/dashboardapi/v1/users/me/school_name') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be supplied by the controller? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is supplied by the controller. I added a controller method to get the school name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry if I've just forgotten a past PR but how do we decide when to show this dialog again? Where is that code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question, I sent another PR that includes the code. I added a helper method that contains the logic for when to show the dialog. |
||
.then(response => response.json()) | ||
.then(data => { | ||
this.setState({ | ||
schoolName: data.school_name | ||
}); | ||
}) | ||
.catch(error => this.setState({error})); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not familiar with this setState syntax - to what is the error assigned? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the request to fetch schoolName is unsuccessful, an error is thrown to activate the catch call. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry - my question should have been clearer! Once the catch call is activated, and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I see, it's the local state of the component |
||
} | ||
} | ||
|
||
handleUpdateClick = () => { | ||
this.setState({showSchoolInterstitial: true}); | ||
}; | ||
|
||
renderInitialContent() { | ||
const {onConfirm} = this.props; | ||
const {schoolName} = this.state; | ||
return ( | ||
<Body> | ||
<div> | ||
<p>{i18n.schoolInfoDialogDescription()} Lincoln Elementary School?</p> | ||
<p> | ||
{i18n.schoolInfoDialogDescription()} {schoolName} | ||
</p> | ||
</div> | ||
<Button | ||
text={i18n.schoolInfoDialogUpdate()} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,13 @@ def load_user | |
@user = current_user | ||
end | ||
|
||
# GET /api/v1/users/<user_id>/school_name | ||
def get_school_name | ||
render json: { | ||
school_name: current_user&.school | ||
} | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This whole controller strikes me as very odd. Our route takes a |
||
|
||
# GET /api/v1/users/<user_id>/contact_details | ||
def get_contact_details | ||
render json: { | ||
|
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.
Should this be required? (Github won't let me put this comment comment in propTypes)
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.
@bethanyaconnor Are you referring to schoolName? There might be times that a teacher did not enter the name of the school; so I decided to have a default value of an empty string
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.
Makes sense. Thanks!