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