Skip to content

Commit bb6a403

Browse files
committed
WEB-4460 add modal controllers to dashboard
1 parent 2015f0f commit bb6a403

6 files changed

Lines changed: 103 additions & 3 deletions

File tree

app/components/navpatientheader/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const NavPatientHeader = ({ api, trackMetric, patient, clinicPatient, user, perm
100100

101101
<EditPatientDialog
102102
api={api}
103-
trackMetric={trackMetric}
103+
clinicPatient={clinicPatient}
104104
isOpen={isEditPatientModalOpen}
105105
onClose={() => setIsEditPatientModalOpen(false)}
106106
/>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
import { useSelector, useDispatch } from 'react-redux';
3+
import DataConnectionsModal from '../../../components/datasources/DataConnectionsModal';
4+
import { closeModals } from './tideDashboardSlice';
5+
6+
const DataConnectionsModalController = ({ patients }) => {
7+
const dispatch = useDispatch();
8+
9+
const dataConnectionsModal = useSelector(state => state.blip.tideDashboard.dataConnectionsModal);
10+
const { patientId, isOpen } = dataConnectionsModal;
11+
12+
const patient = patients.find(patient => patient.id === patientId);
13+
14+
const handleClose = () => dispatch(closeModals());
15+
16+
return (
17+
<DataConnectionsModal
18+
open={isOpen}
19+
patient={patient}
20+
onClose={handleClose}
21+
/>
22+
);
23+
};
24+
25+
export default DataConnectionsModalController;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from 'react';
2+
import { useSelector, useDispatch } from 'react-redux';
3+
import { closeModals } from './tideDashboardSlice';
4+
import { RTKQueryApi } from '../../../redux/api/baseApi';
5+
import EditPatientDialog from '../../../components/navpatientheader/EditPatientDialog';
6+
import { tagTypes } from './tideDashboardApi';
7+
8+
const { TIDE_DASHBOARD_PATIENTS } = tagTypes;
9+
10+
const EditPatientDialogController = ({ api, patients }) => {
11+
const dispatch = useDispatch();
12+
const editPatientDialog = useSelector(state => state.blip.tideDashboard.editPatientDialog);
13+
14+
const clinicPatient = patients.find(patient => patient.id === editPatientDialog.patientId);
15+
16+
const handleCloseModal = () => {
17+
dispatch(closeModals());
18+
};
19+
20+
const handleEditSuccess = () => {
21+
dispatch(RTKQueryApi.util.invalidateTags([TIDE_DASHBOARD_PATIENTS]));
22+
};
23+
24+
return (
25+
<>
26+
<EditPatientDialog
27+
api={api}
28+
clinicPatient={clinicPatient}
29+
isOpen={editPatientDialog.isOpen}
30+
onClose={handleCloseModal}
31+
onEditSuccess={handleEditSuccess}
32+
/>
33+
</>
34+
);
35+
};
36+
37+
export default EditPatientDialogController;

app/pages/clinicworkspace/TideDashboardV2/TideDashboardV2.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import EmptyContentNode from './EmptyContentNode';
2222
import PatientCount from '../components/PatientCount';
2323
import AppliedFiltersList from './AppliedFiltersList';
2424

25+
import EditPatientDialogController from './EditPatientDialogController';
26+
import DataConnectionsModalController from './DataConnectionsModalController';
27+
2528
const Gap = () => <Box sx={{ marginLeft: 'auto' }}></Box>;
2629

2730
const TideDashboardV2 = ({ api, trackMetric }) => {
@@ -90,6 +93,9 @@ const TideDashboardV2 = ({ api, trackMetric }) => {
9093
/>
9194
</Flex>
9295
</Grid>
96+
97+
<EditPatientDialogController api={api} patients={patients} />
98+
<DataConnectionsModalController patients={patients}/>
9399
</>
94100
);
95101
};

app/pages/clinicworkspace/TideDashboardV2/tideDashboardSlice.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ export const CATEGORY = {
1414
const getInitialState = () => ({
1515
category: CATEGORY.DEFAULT,
1616
offset: 0,
17+
editPatientDialog: {
18+
patientId: null,
19+
isOpen: false,
20+
},
21+
dataConnectionsModal: {
22+
patientId: null,
23+
isOpen: false,
24+
},
1725
});
1826

1927
const tideDashboardSlice = createSlice({
@@ -26,13 +34,36 @@ const tideDashboardSlice = createSlice({
2634
setOffset: (state, action) => {
2735
state.offset = action.payload;
2836
},
37+
setEditPatientDialogPatientId: (state, action) => {
38+
state.editPatientDialog.patientId = action.payload;
39+
},
40+
setEditPatientDialogIsOpen: (state, action) => {
41+
state.editPatientDialog.isOpen = action.payload;
42+
},
43+
setDataConnectionsModalPatientId: (state, action) => {
44+
state.dataConnectionsModal.patientId = action.payload;
45+
},
46+
setDataConnectionsModalIsOpen: (state, action) => {
47+
state.dataConnectionsModal.isOpen = action.payload;
48+
},
49+
closeModals: (state) => {
50+
const { editPatientDialog, dataConnectionsModal } = getInitialState();
51+
52+
state.editPatientDialog = editPatientDialog;
53+
state.dataConnectionsModal = dataConnectionsModal;
54+
},
2955
resetTideDashboardState: () => getInitialState(),
3056
},
3157
});
3258

3359
export const {
3460
setCategory,
3561
setOffset,
62+
setEditPatientDialogPatientId,
63+
setEditPatientDialogIsOpen,
64+
setDataConnectionsModalPatientId,
65+
setDataConnectionsModalIsOpen,
66+
closeModals,
3667
resetTideDashboardState,
3768
} = tideDashboardSlice.actions;
3869

app/pages/clinicworkspace/TideDashboardV2/useTableColumns.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
TimeInTargetPercentCell,
2424
FlagCell,
2525
PatientLastReviewedCell,
26+
MoreMenuCell,
2627
} from './Cells';
2728

2829
import TagListCell from '../components/TagListCell';
@@ -118,8 +119,8 @@ const getColumnTypes = (t, category, thresholds) => ({
118119
title: '',
119120
field: 'moreMenu',
120121
align: 'center',
121-
render: patient => null,
122-
},
122+
render: patient => <MoreMenuCell patient={patient} />,
123+
}, // More
123124
});
124125

125126
const getFormattedThresholds = (clinicBgUnits) => {

0 commit comments

Comments
 (0)