From fb82f6d4da2c13f34604a697df2a5f7841039571 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Sun, 7 Jul 2019 03:45:07 +0200 Subject: [PATCH] improve UI, refactor --- .../components/SingleIncidentsTable.js} | 13 ++-- .../components/MemberIncidentsTables/index.js | 78 +++++++++++++++++++ client/src/scenes/IncidentsReport/index.js | 74 +----------------- .../src/scenes/PracticeSummaryReport/index.js | 8 +- 4 files changed, 91 insertions(+), 82 deletions(-) rename client/src/components/{MemberIncidentsTable/index.js => MemberIncidentsTables/components/SingleIncidentsTable.js} (93%) create mode 100644 client/src/components/MemberIncidentsTables/index.js diff --git a/client/src/components/MemberIncidentsTable/index.js b/client/src/components/MemberIncidentsTables/components/SingleIncidentsTable.js similarity index 93% rename from client/src/components/MemberIncidentsTable/index.js rename to client/src/components/MemberIncidentsTables/components/SingleIncidentsTable.js index 01dac02..5c1d91e 100644 --- a/client/src/components/MemberIncidentsTable/index.js +++ b/client/src/components/MemberIncidentsTables/components/SingleIncidentsTable.js @@ -4,17 +4,17 @@ import ReactTable from 'react-table'; import 'react-table/react-table.css'; import { NavLink } from 'react-router-dom'; -import {incidentsReportHeaderTitles} from '../../constants/menuItems'; +import {incidentsReportHeaderTitles} from '../../../constants/menuItems'; import { incidentDescriptions, incidentLevelDescriptions, UNLOCKED_INCIDENT_RELATED_WITH_RESERVATION, UNLOCKED_INCIDENT_STANDALONE, UNSCHEDULED_INCIDENT_AFTER_RESERVATION, UNSCHEDULED_INCIDENT_BEFORE_RESERVATION, UNSCHEDULED_INCIDENT_STANDALONE -} from '../../constants/enums'; +} from '../../../constants/enums'; -const MemberIncidentsTable = props => { - const { loading, title, openMemberSummaryOnMemberClick, showBookingTimes, showDoorLockEntryTimes } = props; +const SingleIncidentsTable = props => { + const { loading, title, openMemberSummaryOnMemberClick, showBookingTimes, showDoorLockEntryTimes, hideMemberName } = props; const incidents = props.incidents ? props.incidents : []; const columns = []; @@ -31,6 +31,9 @@ const MemberIncidentsTable = props => { if ((header === 'unlockTimestamp' || header === 'lockTimestamp') && !showDoorLockEntryTimes){ showColumn = false; } + if (header === 'memberName' && hideMemberName){ + showColumn = false; + } if (columnTitle && showColumn){ const columnAlignments = { @@ -113,4 +116,4 @@ const MemberIncidentsTable = props => { ); }; -export default MemberIncidentsTable; +export default SingleIncidentsTable; diff --git a/client/src/components/MemberIncidentsTables/index.js b/client/src/components/MemberIncidentsTables/index.js new file mode 100644 index 0000000..ed05541 --- /dev/null +++ b/client/src/components/MemberIncidentsTables/index.js @@ -0,0 +1,78 @@ +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, + UNSCHEDULED_INCIDENT_BEFORE_RESERVATION, UNSCHEDULED_INCIDENT_STANDALONE +} from '../../constants/enums'; + +export default function MemberIncidentsTables (props) { + const { pendingIncidents, incidents, hideMemberName } = props; + + const incidentsRelatedToReservations = []; + const standaloneIncidents = []; + + 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; + } + } + }); + } + + const incidentsRelatedToReservationsTable = ( + + ); + + const standaloneIncidentsTable = ( + + ); + + const accordionPanels = [ + { + key: 'related-door-lock-incidents', + title : { content: