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

Detecting when a save was moderated

parent 9e940bf1
Pipeline #27297 passed with stages
in 2 minutes and 41 seconds
......@@ -39,6 +39,7 @@ class Editor extends MyComponent {
open: false,
},
lastSave: this.props.lastSave,
lastUpdateTime: this.props.lastUpdateTime,
}
formIsValid() {
......@@ -144,11 +145,22 @@ class Editor extends MyComponent {
if (this.state.lastSave < this.props.lastSave) {
//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({
notification: {
open: true,
message: "Les données ont été enregistrées avec succès !",
message,
success: true,
duration: 5000,
preventClickAway: false
......@@ -268,6 +280,7 @@ Editor.propTypes = {
clearSaveError: PropTypes.func.isRequired,
savingHasError: PropTypes.object.isRequired,
saveData: PropTypes.func.isRequired,
lastUpdateTime: PropTypes.string,
};
Editor.defaultProps = {
......
......@@ -25,7 +25,7 @@ const styles = theme => ({
class UniversitySemestersDatesEditor extends Editor {
renderEditor() {
const { modelData } = this.props;
......@@ -75,9 +75,16 @@ UniversitySemestersDatesEditor.propTypes = {
const mapStateToProps = (state) => {
let lastUpdateTime = null;
const tmp = state.universitiesSemestersDatesEl.fetched;
if (tmp.fetchedAt) {
lastUpdateTime = tmp.data.updated_on;
}
return {
savingHasError: state.universitiesSemestersDatesEl.savingHasError,
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