Files
old-crm-integration/client/src/components/MemberIncidentsTables/index.js

105 lines
3.8 KiB
JavaScript
Raw Normal View History

2019-07-07 07:02:42 +02:00
import React from 'react';
import {Accordion, Label} from 'semantic-ui-react';
import SingleIncidentsTable from './components/SingleIncidentsTable';
import {
UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION, UNLOCKED_INCIDENT_STANDALONE, UNSCHEDULED_INCIDENT_AFTER_RESERVATION,
2019-07-19 09:46:15 +02:00
UNSCHEDULED_INCIDENT_BEFORE_RESERVATION, UNSCHEDULED_INCIDENT_STANDALONE, BOOKING_MOVED_TO_ANOTHER_DAY, BOOKING_SHORTENED, BOOKING_CANCELED_LATE,
2019-07-08 20:37:14 +02:00
incidentTableTypes
2019-07-07 07:02:42 +02:00
} from '../../constants/enums';
export default function MemberIncidentsTables (props) {
const { pendingIncidents, incidents, hideMemberName, dateRange, memberId } = props;
2019-07-07 07:02:42 +02:00
const incidentsRelatedToReservations = [];
const standaloneIncidents = [];
2019-07-08 20:37:14 +02:00
const bookingChangeIncidents = [];
2019-07-07 07:02:42 +02:00
if (Array.isArray(incidents)){
incidents.forEach((incident) => {
if (incident && incident.incidentType){
switch (incident.incidentType) {
case UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION:
case UNSCHEDULED_INCIDENT_BEFORE_RESERVATION:
case UNSCHEDULED_INCIDENT_AFTER_RESERVATION:
incidentsRelatedToReservations.push(incident);
break;
case UNLOCKED_INCIDENT_STANDALONE:
case UNSCHEDULED_INCIDENT_STANDALONE:
standaloneIncidents.push(incident);
break;
2019-07-08 20:37:14 +02:00
case BOOKING_MOVED_TO_ANOTHER_DAY:
case BOOKING_SHORTENED:
2019-07-19 09:46:15 +02:00
case BOOKING_CANCELED_LATE:
2019-07-08 20:37:14 +02:00
bookingChangeIncidents.push(incident);
break;
default:
break;
2019-07-07 07:02:42 +02:00
}
}
});
}
const incidentsRelatedToReservationsTable = (
<SingleIncidentsTable
loading={pendingIncidents}
incidents={incidentsRelatedToReservations}
openMemberSummaryOnMemberClick
hideMemberName={hideMemberName}
2019-07-08 20:37:14 +02:00
tableType={incidentTableTypes.INCIDENTS_RELATED_TO_RESERVATIONS}
dateRange={dateRange}
memberId={memberId}
2019-07-07 07:02:42 +02:00
/>
);
const standaloneIncidentsTable = (
<SingleIncidentsTable
loading={pendingIncidents}
incidents={standaloneIncidents}
openMemberSummaryOnMemberClick
hideMemberName={hideMemberName}
2019-07-08 20:37:14 +02:00
tableType={incidentTableTypes.STANDALONE_INCIDENTS}
dateRange={dateRange}
memberId={memberId}
2019-07-08 20:37:14 +02:00
/>
);
const bookingChangeIncidentsTable = (
<SingleIncidentsTable
loading={pendingIncidents}
incidents={bookingChangeIncidents}
openMemberSummaryOnMemberClick
hideMemberName={hideMemberName}
tableType={incidentTableTypes.BOOKING_CHANGE_INCIDENTS}
dateRange={dateRange}
memberId={memberId}
2019-07-07 07:02:42 +02:00
/>
);
const accordionPanels = [
{
key: 'related-door-lock-incidents',
title : { content: <Label color='blue' content={'Door Lock Charges - Related to reservations'} /> },
content: { content : incidentsRelatedToReservationsTable },
},
{
key: 'standalone-door-lock-incidents',
title : { content: <Label color='blue' content={'Door Lock Charges - Standalone'} /> },
content: { content: standaloneIncidentsTable },
},
{
key: 'reservation-modification-incidents',
2019-07-08 20:37:14 +02:00
title: {content: <Label color='blue' content={'Booking change charges'}/>},
content: { content: bookingChangeIncidentsTable },
2019-07-07 07:02:42 +02:00
}
];
return (
<Accordion
panels={accordionPanels}
exclusive={false}
defaultActiveIndex={[0]}
fluid
/>
);
}