Reset coaching submission state on submit

This commit is contained in:
Matt Tuchfarber
2020-05-01 14:51:51 -04:00
parent caa06a08b0
commit ef5c303fbc
2 changed files with 4 additions and 14 deletions

View File

@@ -125,6 +125,7 @@ class CoachingConsent extends React.Component {
this.setState({
formErrors: {},
formSubmitted: true,
declineSubmitted: false,
});
// Must store target values or they disappear before the async function can use them.
const fullName = e.target.fullName.value;
@@ -147,6 +148,7 @@ class CoachingConsent extends React.Component {
this.setState({
formErrors: {},
declineSubmitted: true,
formSubmitted: false,
});
// Must store target values or they disappear before the async function can use them.
const coachingValues = this.props.formValues.coaching;

View File

@@ -8,20 +8,8 @@ import get from 'lodash.get';
* @param {Number} userId users are identified in the api by LMS id
*/
export async function getCoachingPreferences(userId) {
let data = null;
try {
({ data } = await getAuthenticatedHttpClient()
.get(`${getConfig().LMS_BASE_URL}/api/coaching/v1/users/${userId}/`));
} catch (error) {
// Default values so the client doesn't fail if the user doesn't have an entry in the
// UserCoaching model yet.
data = {
coaching_consent: false,
user: userId,
eligible_for_coaching: false,
consent_form_seen: false,
};
}
const { data } = await getAuthenticatedHttpClient()
.get(`${getConfig().LMS_BASE_URL}/api/coaching/v1/users/${userId}/`);
return data;
}