add and implement action to send "delete fees" request
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Loader } from 'semantic-ui-react';
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { Loader, Button } from 'semantic-ui-react';
|
||||
import ReactTable from 'react-table';
|
||||
import 'react-table/react-table.css';
|
||||
import { NavLink } from 'react-router-dom';
|
||||
@@ -13,17 +14,34 @@ import {
|
||||
UNSCHEDULED_INCIDENT_BEFORE_RESERVATION, UNSCHEDULED_INCIDENT_STANDALONE
|
||||
} from '../../../constants/enums';
|
||||
import { doorLockRelatedWithReservationIncidentHeaders, standaloneDoorLockIncidentHeaders, bookingChangeIncidentHeaders } from '../../../constants/constants';
|
||||
import { deleteIncidents } from "../../../store/actions";
|
||||
|
||||
class SingleIncidentsTable extends Component {
|
||||
deleteSelectedFees = () => {
|
||||
const { dateRange, deleteIncidentsById } = this.props;
|
||||
|
||||
const SingleIncidentsTable = props => {
|
||||
const unlockedIncidentIds = [];
|
||||
const unscheduledIncidentIds = [];
|
||||
const bookingChangeIncidentIds = [];
|
||||
|
||||
const incidentsToDelete = {
|
||||
unlockedIncidentIds,
|
||||
unscheduledIncidentIds,
|
||||
bookingChangeIncidentIds
|
||||
};
|
||||
|
||||
deleteIncidentsById(dateRange, incidentsToDelete);
|
||||
};
|
||||
|
||||
render(){
|
||||
const {
|
||||
loading,
|
||||
title,
|
||||
openMemberSummaryOnMemberClick,
|
||||
hideMemberName,
|
||||
tableType
|
||||
} = props;
|
||||
const incidents = props.incidents ? props.incidents : [];
|
||||
} = this.props;
|
||||
const incidents = this.props.incidents ? this.props.incidents : [];
|
||||
const columns = [];
|
||||
|
||||
if (incidents && incidents.length > 0){
|
||||
@@ -152,6 +170,9 @@ const SingleIncidentsTable = props => {
|
||||
<div>
|
||||
<h4>{title}</h4>
|
||||
<Loader active={loading} />
|
||||
{
|
||||
<Button disabled={loading} onClick={this.deleteSelectedFees}>Delete</Button>
|
||||
}
|
||||
{
|
||||
!loading && incidents &&
|
||||
<ReactTable
|
||||
@@ -162,6 +183,11 @@ const SingleIncidentsTable = props => {
|
||||
}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default SingleIncidentsTable;
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
deleteIncidentsById: (dateRange, incidentsToDelete) => deleteIncidents(dispatch, {dateRange, incidentsToDelete})
|
||||
});
|
||||
|
||||
export default connect(null, mapDispatchToProps)(SingleIncidentsTable);
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
} from '../../constants/enums';
|
||||
|
||||
export default function MemberIncidentsTables (props) {
|
||||
const { pendingIncidents, incidents, hideMemberName } = props;
|
||||
const { pendingIncidents, incidents, hideMemberName, dateRange } = props;
|
||||
|
||||
const incidentsRelatedToReservations = [];
|
||||
const standaloneIncidents = [];
|
||||
@@ -46,6 +46,7 @@ export default function MemberIncidentsTables (props) {
|
||||
openMemberSummaryOnMemberClick
|
||||
hideMemberName={hideMemberName}
|
||||
tableType={incidentTableTypes.INCIDENTS_RELATED_TO_RESERVATIONS}
|
||||
dateRange={dateRange}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -56,6 +57,7 @@ export default function MemberIncidentsTables (props) {
|
||||
openMemberSummaryOnMemberClick
|
||||
hideMemberName={hideMemberName}
|
||||
tableType={incidentTableTypes.STANDALONE_INCIDENTS}
|
||||
dateRange={dateRange}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -66,6 +68,7 @@ export default function MemberIncidentsTables (props) {
|
||||
openMemberSummaryOnMemberClick
|
||||
hideMemberName={hideMemberName}
|
||||
tableType={incidentTableTypes.BOOKING_CHANGE_INCIDENTS}
|
||||
dateRange={dateRange}
|
||||
/>
|
||||
);
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class IncidentsReport extends Component {
|
||||
<br/><br/>
|
||||
<hr/>
|
||||
<br/>
|
||||
<MemberIncidentsTables pendingIncidents={loading} incidents={incidents} />
|
||||
<MemberIncidentsTables pendingIncidents={loading} incidents={incidents} dateRange={dateRange} />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -88,6 +88,17 @@ export const fetchIncidents = (dispatch, dateRange) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteIncidents = (dispatch, deleteData) => {
|
||||
dispatch({type: FETCH_INCIDENTS_PENDING});
|
||||
API.delete(`/integration/fees`, { data: deleteData })
|
||||
.then(response => {
|
||||
dispatch({type: FETCH_INCIDENTS_SUCCESS, payload: response.data});
|
||||
})
|
||||
.catch(error => {
|
||||
dispatch({type: FETCH_INCIDENTS_FAILED, payload: error.response});
|
||||
});
|
||||
};
|
||||
|
||||
export const fetchMembersList = (dispatch) => {
|
||||
dispatch({type: FETCH_MEMBERS_PENDING});
|
||||
API.get('officeRnD/membersList')
|
||||
|
||||
Reference in New Issue
Block a user