Files
old-crm-integration/client/src/scenes/PracticeSummaryReport/components/MemberSummary.js
2019-07-07 07:02:42 +02:00

77 lines
2.8 KiB
JavaScript

import React from 'react';
import { Loader, Grid } from 'semantic-ui-react';
import {
UNSCHEDULED_INCIDENT_BEFORE_RESERVATION,
UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION,
UNSCHEDULED_INCIDENT_AFTER_RESERVATION, UNSCHEDULED_INCIDENT_STANDALONE, UNLOCKED_INCIDENT_STANDALONE
} from '../../../constants/enums';
const MemberSummary = props => {
const { loading } = props;
const incidents = props.incidents ? props.incidents : [];
let totalUnscheduledFees = 0;
let totalUnlockedFees = 0;
incidents.forEach((incident) => {
switch (incident.incidentType) {
case UNSCHEDULED_INCIDENT_BEFORE_RESERVATION:
case UNSCHEDULED_INCIDENT_AFTER_RESERVATION:
case UNSCHEDULED_INCIDENT_STANDALONE:
totalUnscheduledFees += parseFloat(incident.totalChargeFee);
break;
case UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION:
case UNLOCKED_INCIDENT_STANDALONE:
totalUnlockedFees += parseFloat(incident.incidentPrice);
break;
default:
break;
}
});
const grandTotal = totalUnlockedFees + totalUnscheduledFees;
const formattedUnscheduledFees = `$ ${totalUnscheduledFees.toFixed(2)}`;
const formattedUnlockedFees = `$ ${totalUnlockedFees.toFixed(2)}`;
const formattedGrandTotalFee = `$ ${grandTotal.toFixed(2)}`;
return (
<div>
<h4>Member Summary for selected period</h4>
<Loader active={loading} />
{
!loading &&
<Grid stackable>
<Grid.Row>
<Grid.Column width={3}>
<p>Unscheduled incidents total :</p>
</Grid.Column>
<Grid.Column width={9}>
<p>{formattedUnscheduledFees}</p>
</Grid.Column>
</Grid.Row>
<Grid.Row>
<Grid.Column width={3}>
<p>Unlocked incidents total :</p>
</Grid.Column>
<Grid.Column width={9}>
<p>{formattedUnlockedFees}</p>
</Grid.Column>
</Grid.Row>
<Grid.Row>
<Grid.Column width={3}>
<p><b>Grand Total :</b></p>
</Grid.Column>
<Grid.Column width={9}>
<p><b>{formattedGrandTotalFee}</b></p>
</Grid.Column>
</Grid.Row>
</Grid>
}
</div>
);
};
export default MemberSummary;