add action for sending update data to backend

This commit is contained in:
Bilal Catic
2020-01-09 01:29:06 +01:00
parent c78a0e4138
commit ff8a836fed
2 changed files with 37 additions and 3 deletions

View File

@@ -17,7 +17,7 @@ import {
BOOKING_SHORTENED
} from '../../../constants/enums';
import { doorLockRelatedWithReservationIncidentHeaders, standaloneDoorLockIncidentHeaders, bookingChangeIncidentHeaders } from '../../../constants/constants';
import { deleteIncidents } from "../../../store/actions";
import { deleteIncidents, updateIncidentFees } from "../../../store/actions";
class SingleIncidentsTable extends Component {
state = {
@@ -88,6 +88,24 @@ class SingleIncidentsTable extends Component {
});
};
updateChangedFees = () => {
const { dateRange, updateIncidentsById, memberId } = this.props;
const { changedUnlockedIncidentIds, changedUnscheduledIncidentIds, changedBookingChangeIncidentIds } = this.state;
const incidentFeesToUpdate = {
unlockedIncidentFees: changedUnlockedIncidentIds,
unscheduledIncidentFees: changedUnscheduledIncidentIds,
bookingChangeIncidentFees: changedBookingChangeIncidentIds
};
updateIncidentsById(dateRange, incidentFeesToUpdate, memberId);
this.setState({
changedUnlockedIncidentIds: {},
changedUnscheduledIncidentIds: {},
changedBookingChangeIncidentIds: {}
});
};
render(){
const {
loading,
@@ -327,7 +345,7 @@ class SingleIncidentsTable extends Component {
<Button disabled={loading || totalSelected === 0} onClick={this.deleteSelectedFees}>{`Delete selected ${numberOfSelectedText}`}</Button>
}
{
<Button disabled={loading || totalChanged === 0}>{`Save changed ${numberOfChangedText}`}</Button>
<Button disabled={loading || totalChanged === 0} onClick={this.updateChangedFees}>{`Save changed ${numberOfChangedText}`}</Button>
}
<br/><br/>
{
@@ -346,7 +364,8 @@ class SingleIncidentsTable extends Component {
}
const mapDispatchToProps = (dispatch) => ({
deleteIncidentsById: (dateRange, incidentsToDelete, memberId) => deleteIncidents(dispatch, {dateRange, incidentsToDelete, memberId})
deleteIncidentsById: (dateRange, incidentsToDelete, memberId) => deleteIncidents(dispatch, {dateRange, incidentsToDelete, memberId}),
updateIncidentsById: (dateRange, updatedIncidentsData, memberId) => updateIncidentFees(dispatch, {dateRange, updatedIncidentsData, memberId})
});
export default connect(null, mapDispatchToProps)(SingleIncidentsTable);