Skip to content

Commit

Permalink
Merge pull request #17 from City-of-Turku/new-features
Browse files Browse the repository at this point in the history
New features
  • Loading branch information
arvileino authored Dec 11, 2017
2 parents 665622f + 1f7b524 commit 2fe2a82
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/components/Alerts.less
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@
.details {
font-size: 14px;
line-height: 1.2;
white-space: pre;
}
12 changes: 6 additions & 6 deletions src/routes/AssignmentPage/containers/AssignmentPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ function mergeProps(stateProps, dispatchProps, ownProps) {

export default connect(mapStateToProps, null, mergeProps)(reduxForm({
form: 'assignmentPage',
onSubmitFail: (errors, dispatch) => {
dispatch(showAlert(
'Tarkista tiedot',
'Tarkista, että kaikki vaaditut tiedot on täytetty.',
'danger',
));
onSubmitFail: (errors, dispatch, submitError) => {
if (errors !== undefined) {
dispatch(showAlert(
'Tarkista tiedot',
'Tarkista, että kaikki vaaditut tiedot on täytetty.',
'danger',
));
dispatch(scrollToFirstErrorSection(errors));
}
},
Expand Down
13 changes: 11 additions & 2 deletions src/sagas/assignmentForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,28 @@ import { cleanInvalidFriends } from '../routes/AssignmentPage/actions/friendsOfP
import { showAlert } from "../actions/alerts";

function* handleFormSubmition(action) {
let details;
switch (action.type) {
case formActionType.SUBMIT_FORM:
yield put(cleanInvalidFriends());
yield put(disableSubmitButton());
break;
case formActionType.SUBMIT_FORM_FULFILLED:
yield put(showAlert('Tiedot lähetetty', 'Olet lähettänyt tiedot onnistuneesti. Kiitos ajastasi.', 'success'));
details = 'Olet lähettänyt tiedot onnistuneesti. Kiitos ajastasi.'
if (action.payload.feedback_system_success){
details += '\n\n' + action.payload.feedback_system_success;
}
yield put(showAlert('Tiedot lähetetty', details, 'success'));
yield put(enableSubmitButton());
yield put(reset('assignmentPage'));
yield put(scrollToTop());
break;
case formActionType.SUBMIT_FORM_REJECTED:
yield put(showAlert('Lähetys epäonnistui', 'Jokin meni pahasti pieleen :( Yritä myöhemmin uudelleen.', 'danger'));
details = 'Jokin meni pahasti pieleen :( Yritä myöhemmin uudelleen.';
if (action.payload.response !== undefined) {
details += '\n\n' + action.payload.response.data.detail;
}
yield put(showAlert('Lähetys epäonnistui', details, 'danger'));
yield put(enableSubmitButton());
break;
default:
Expand Down

0 comments on commit 2fe2a82

Please sign in to comment.