diff --git a/client/src/components/MemberIncidentsTables/components/SingleIncidentsTable.js b/client/src/components/MemberIncidentsTables/components/SingleIncidentsTable.js index b4f1cb6..1324972 100644 --- a/client/src/components/MemberIncidentsTables/components/SingleIncidentsTable.js +++ b/client/src/components/MemberIncidentsTables/components/SingleIncidentsTable.js @@ -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 { } { - + }

{ @@ -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); diff --git a/client/src/store/actions/integrationActions.js b/client/src/store/actions/integrationActions.js index f285e29..f5320cb 100644 --- a/client/src/store/actions/integrationActions.js +++ b/client/src/store/actions/integrationActions.js @@ -103,6 +103,21 @@ export const deleteIncidents = (dispatch, deleteData) => { }); }; +export const updateIncidentFees = (dispatch, updateData) => { + const pendingAction = updateData.memberId ? FETCH_MEMBER_INCIDENTS_PENDING : FETCH_INCIDENTS_PENDING; + const successAction = updateData.memberId ? FETCH_MEMBER_INCIDENTS_SUCCESS : FETCH_INCIDENTS_SUCCESS; + const failedAction = updateData.memberId ? FETCH_MEMBER_INCIDENTS_FAILED : FETCH_INCIDENTS_FAILED; + + dispatch({type: pendingAction}); + API.patch(`/integration/fees`, updateData) + .then(response => { + dispatch({type: successAction, payload: response.data}); + }) + .catch(error => { + dispatch({type: failedAction, payload: error.response}); + }); +}; + export const fetchMembersList = (dispatch) => { dispatch({type: FETCH_MEMBERS_PENDING}); API.get('officeRnD/membersList')