Commit cf0fd2d2 authored by Florent Chehab's avatar Florent Chehab
Browse files

Detecting when a save was moderated

parent 9e940bf1
...@@ -39,6 +39,7 @@ class Editor extends MyComponent { ...@@ -39,6 +39,7 @@ class Editor extends MyComponent {
open: false, open: false,
}, },
lastSave: this.props.lastSave, lastSave: this.props.lastSave,
lastUpdateTime: this.props.lastUpdateTime,
} }
formIsValid() { formIsValid() {
...@@ -144,11 +145,22 @@ class Editor extends MyComponent { ...@@ -144,11 +145,22 @@ class Editor extends MyComponent {
if (this.state.lastSave < this.props.lastSave) { if (this.state.lastSave < this.props.lastSave) {
//saving data was successfull //saving data was successfull
this.setState({ lastSave: this.props.lastSave });
// We check if data was moderated
let message = "Les données ont été enregistrées avec succès !";
let lastUpdateTime = this.state.lastUpdateTime;
const newUpdateTime = this.props.lastUpdateTime;
if (lastUpdateTime == newUpdateTime) {
message = "Les données ont été enregistrées et sont en attentes de modération.";
} else {
lastUpdateTime = newUpdateTime;
}
this.setState({ lastSave: this.props.lastSave, lastUpdateTime });
this.setState({ this.setState({
notification: { notification: {
open: true, open: true,
message: "Les données ont été enregistrées avec succès !", message,
success: true, success: true,
duration: 5000, duration: 5000,
preventClickAway: false preventClickAway: false
...@@ -268,6 +280,7 @@ Editor.propTypes = { ...@@ -268,6 +280,7 @@ Editor.propTypes = {
clearSaveError: PropTypes.func.isRequired, clearSaveError: PropTypes.func.isRequired,
savingHasError: PropTypes.object.isRequired, savingHasError: PropTypes.object.isRequired,
saveData: PropTypes.func.isRequired, saveData: PropTypes.func.isRequired,
lastUpdateTime: PropTypes.string,
}; };
Editor.defaultProps = { Editor.defaultProps = {
......
...@@ -75,9 +75,16 @@ UniversitySemestersDatesEditor.propTypes = { ...@@ -75,9 +75,16 @@ UniversitySemestersDatesEditor.propTypes = {
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
let lastUpdateTime = null;
const tmp = state.universitiesSemestersDatesEl.fetched;
if (tmp.fetchedAt) {
lastUpdateTime = tmp.data.updated_on;
}
return { return {
savingHasError: state.universitiesSemestersDatesEl.savingHasError, savingHasError: state.universitiesSemestersDatesEl.savingHasError,
lastSave: state.universitiesSemestersDatesEl.fetched.fetchedAt, lastSave: state.universitiesSemestersDatesEl.fetched.fetchedAt,
lastUpdateTime,
}; };
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment