diff --git a/client/src/components/DateRangePicker/index.js b/client/src/components/DateRangePicker/index.js index cb2d2c4..304ed83 100644 --- a/client/src/components/DateRangePicker/index.js +++ b/client/src/components/DateRangePicker/index.js @@ -81,7 +81,7 @@ class DateRangePicker extends Component { const endDateValue = endDate.format(defaultDateFormat); const buttonRender = ( - + { inlineButton && } {buttonLabel} diff --git a/client/src/components/MemberIncidentsTables/components/SingleIncidentsTable.js b/client/src/components/MemberIncidentsTables/components/SingleIncidentsTable.js index 98e778a..fbdfb3e 100644 --- a/client/src/components/MemberIncidentsTables/components/SingleIncidentsTable.js +++ b/client/src/components/MemberIncidentsTables/components/SingleIncidentsTable.js @@ -70,6 +70,19 @@ const SingleIncidentsTable = props => { urlValue = `/practice-summary-report/${memberId}`; cellValue = props.value; break; + case 'resourceName': + if (props.row['_original'].resourceName){ + cellValue = props.row['_original'].resourceName || '---'; + }else{ + const oldResourceName = props.row['_original'].oldResourceName || '---'; + const newResourceName = props.row['_original'].newResourceName || '---'; + if (oldResourceName !== newResourceName){ + cellValue = `${oldResourceName}\n${newResourceName}`; + }else{ + cellValue = oldResourceName; + } + } + break; case 'reservation': const bookingStart = props.row['_original'].bookingStart; const bookingEnd = props.row['_original'].bookingEnd; @@ -116,8 +129,8 @@ const SingleIncidentsTable = props => { cellValue = `${oldBookingStart}\n${oldBookingEnd}`; break; case 'newReservation': - const newBookingStart = props.row['_original'].newBookingStart; - const newBookingEnd = props.row['_original'].newBookingEnd; + const newBookingStart = props.row['_original'].newBookingStart || '---'; + const newBookingEnd = props.row['_original'].newBookingEnd || '---'; cellValue = `${newBookingStart}\n${newBookingEnd}`; break; default: diff --git a/client/src/components/MemberIncidentsTables/index.js b/client/src/components/MemberIncidentsTables/index.js index ad6706a..45ec9d1 100644 --- a/client/src/components/MemberIncidentsTables/index.js +++ b/client/src/components/MemberIncidentsTables/index.js @@ -3,7 +3,7 @@ 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, - UNSCHEDULED_INCIDENT_BEFORE_RESERVATION, UNSCHEDULED_INCIDENT_STANDALONE, BOOKING_MOVED_TO_ANOTHER_DAY, BOOKING_SHORTENED, + UNSCHEDULED_INCIDENT_BEFORE_RESERVATION, UNSCHEDULED_INCIDENT_STANDALONE, BOOKING_MOVED_TO_ANOTHER_DAY, BOOKING_SHORTENED, BOOKING_CANCELED_LATE, incidentTableTypes } from '../../constants/enums'; @@ -29,6 +29,7 @@ export default function MemberIncidentsTables (props) { break; case BOOKING_MOVED_TO_ANOTHER_DAY: case BOOKING_SHORTENED: + case BOOKING_CANCELED_LATE: bookingChangeIncidents.push(incident); break; default: diff --git a/client/src/constants/enums.js b/client/src/constants/enums.js index 6a5c48b..cfcd675 100644 --- a/client/src/constants/enums.js +++ b/client/src/constants/enums.js @@ -6,6 +6,7 @@ export const UNLOCKED_INCIDENT_STANDALONE = 5; export const UNSCHEDULED_INCIDENT_STANDALONE = 6; export const BOOKING_MOVED_TO_ANOTHER_DAY = 7; export const BOOKING_SHORTENED = 8; +export const BOOKING_CANCELED_LATE = 9; export const incidentDescriptions = {}; incidentDescriptions[UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION] = 'User left door unlocked'; @@ -15,6 +16,7 @@ incidentDescriptions[UNLOCKED_INCIDENT_STANDALONE] = 'User left door unlocked'; incidentDescriptions[UNSCHEDULED_INCIDENT_STANDALONE] = 'Unscheduled use'; incidentDescriptions[BOOKING_MOVED_TO_ANOTHER_DAY] = 'Reservation moved to another day'; incidentDescriptions[BOOKING_SHORTENED] = 'Reservation shortened'; +incidentDescriptions[BOOKING_CANCELED_LATE] = 'Reservation canceled late'; export const incidentLevelDescriptions = { UNLOCKED_0: 'First month', diff --git a/client/src/scenes/PracticeSummaryReport/components/MemberSummary.js b/client/src/scenes/PracticeSummaryReport/components/MemberSummary.js index c6e6af0..d19e4c3 100644 --- a/client/src/scenes/PracticeSummaryReport/components/MemberSummary.js +++ b/client/src/scenes/PracticeSummaryReport/components/MemberSummary.js @@ -5,7 +5,7 @@ import { UNSCHEDULED_INCIDENT_BEFORE_RESERVATION, UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION, UNSCHEDULED_INCIDENT_AFTER_RESERVATION, UNSCHEDULED_INCIDENT_STANDALONE, UNLOCKED_INCIDENT_STANDALONE, - BOOKING_MOVED_TO_ANOTHER_DAY, BOOKING_SHORTENED, + BOOKING_MOVED_TO_ANOTHER_DAY, BOOKING_SHORTENED, BOOKING_CANCELED_LATE, } from '../../../constants/enums'; const MemberSummary = props => { @@ -29,6 +29,7 @@ const MemberSummary = props => { break; case BOOKING_MOVED_TO_ANOTHER_DAY: case BOOKING_SHORTENED: + case BOOKING_CANCELED_LATE: totalBookingChangeFees += parseFloat(incident.totalChargeFee); break; default: diff --git a/services/integration/reports.js b/services/integration/reports.js index 07c6f02..4bd54ca 100644 --- a/services/integration/reports.js +++ b/services/integration/reports.js @@ -116,7 +116,8 @@ const getBookingChangeIncidents = (startDate, endDate, memberId) => { 'id', 'reservationId', 'memberId', - 'resourceId', + 'oldResourceId', + 'newResourceId', 'oldBookingStart', 'oldBookingEnd', 'newBookingStart', @@ -251,7 +252,8 @@ const getAllIncidents = (dateRange, memberId) => { const { id, memberId, - resourceId, + oldResourceId, + newResourceId, oldBookingStart, oldBookingEnd, newBookingStart, @@ -261,14 +263,17 @@ const getAllIncidents = (dateRange, memberId) => { createdAt, } = bookingChangeIncident; const memberName = membersMap[memberId].name; - const resource = resourcesMap[resourceId]; - const resourceName = resource.resourceName; - const officeName = officesMap[resource.officeId].officeName; + const oldResource = resourcesMap[oldResourceId]; + const newResource = newResourceId ? resourcesMap[newResourceId] : null; + const oldResourceName = oldResource.resourceName; + const newResourceName = newResource ? newResource.resourceName : null; + const officeName = officesMap[oldResource.officeId].officeName; allIncidents.push({ incidentId: id, memberId, memberName, - resourceName, + oldResourceName, + newResourceName, officeName, oldBookingStart: formatTime(oldBookingStart), oldBookingEnd: formatTime(oldBookingEnd),