Skip to content
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

Application form save data bug fix #285

Open
wants to merge 3 commits into
base: 2024-root
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/store/form/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ export const getUserProfile = () => (dispatch, getState) => {
dispatch(loadingStart());
return API.get("treehacks", `/users/${userId}`, {}).then(e => {
dispatch(setUserProfile(e));
dispatch(loadingEnd());
}).catch(e => {
console.error(e);
dispatch(loadingEnd());
alert("Error getting user data " + e);
}).finally(() => {
dispatch(loadingEnd());
});
};

Expand All @@ -49,12 +49,12 @@ export const saveData = () => (dispatch, getState) => {
dispatch(loadingStart());
return API.put("treehacks", `/users/${userId}/forms/${formName}`, { "body": formData }).then(e => {
dispatch(setData(e, false));
dispatch(loadingEnd());
dispatch(setUserEdited(false));
}).catch(e => { // catches 401 and other errors
console.error(e);
dispatch(loadingEnd());
alert("Error saving data " + e);
}).finally(() => {
dispatch(loadingEnd());
});
}

Expand All @@ -63,11 +63,11 @@ export const submitForm = () => (dispatch, getState) => {
const formName = (getState().form as IFormState).formName;
dispatch(loadingStart());
return API.post("treehacks", `/users/${userId}/forms/${formName}/submit`, {}).then(e => {
dispatch(loadingEnd());
}).catch(e => {
console.error(e);
dispatch(loadingEnd());
alert("Error submitting form " + e);
}).finally(() => {
dispatch(loadingEnd());
});
}

Expand All @@ -76,12 +76,12 @@ export const loadData = (userId = null) => (dispatch, getState) => {
const formName = (getState().form as IFormState).formName;
dispatch(loadingStart());
return API.get("treehacks", `/users/${userId}/forms/${formName}`, {}).then(e => {
dispatch(loadingEnd());
dispatch(setData(e));
}).catch(e => {
console.error(e);
dispatch(loadingEnd());
alert("Error getting data " + e);
}).finally(() => {
dispatch(loadingEnd());
});
}

Expand All @@ -92,8 +92,9 @@ export const confirmAdmission = () => (dispatch, getState) => {
dispatch(getUserProfile());
}).catch(e => {
console.error(e);
dispatch(loadingEnd());
alert("Error " + e);
}).finally(() => {
dispatch(loadingEnd());
});
}

Expand All @@ -104,7 +105,8 @@ export const declineAdmission = () => (dispatch, getState) => {
dispatch(getUserProfile());
}).catch(e => {
console.error(e);
dispatch(loadingEnd());
alert("Error " + e);
}).finally(() => {
dispatch(loadingEnd());
});
}