11import React from 'react' ;
2- import { useSelector } from 'react-redux' ;
2+ import { useSelector , useDispatch } from 'react-redux' ;
33import { useTranslation , withTranslation } from 'react-i18next' ;
44import { Box , Flex , Text } from 'theme-ui' ;
55import { colors as vizColors } from '@tidepool/viz' ;
@@ -13,8 +13,18 @@ import utils from '../../../core/utils';
1313import { CATEGORY } from './tideDashboardSlice' ;
1414import isUndefined from 'lodash/isUndefined' ;
1515
16+ import PopoverMenu from '../../../components/elements/PopoverMenu' ;
17+ import EditIcon from '@material-ui/icons/EditRounded' ;
18+ import DataInIcon from '../../../core/icons/DataInIcon.svg' ;
1619
17- import { tideDashboardExclusionQueryParams } from './tideDashboardApi' ;
20+ import {
21+ setEditPatientDialogIsOpen ,
22+ setEditPatientDialogPatientId ,
23+ setDataConnectionsModalIsOpen ,
24+ setDataConnectionsModalPatientId ,
25+ } from './tideDashboardSlice' ;
26+
27+ import { tideDashboardExclusionQuery } from './tideDashboardApi' ;
1828
1929export const COMPACT = '@container (max-width: 1200px)' ;
2030
@@ -163,7 +173,7 @@ export const FlagCell = ({ patient, category = null }) => {
163173
164174 const { VERY_LOW , ANY_LOW , DROP_IN_TIR , ANY_HIGH , VERY_HIGH , LOW_CGM_WEAR } = CATEGORY ;
165175
166- const getThreshold = ( category ) => tideDashboardExclusionQueryParams . getRule ( category ) . threshold ;
176+ const getThreshold = ( category ) => tideDashboardExclusionQuery . getRule ( category ) . threshold ;
167177
168178 if ( ! period ) return null ;
169179
@@ -231,7 +241,50 @@ export const MoreMenuHeader = () => {
231241 return < Box aria-label = { t ( 'More Options' ) } > </ Box > ;
232242} ;
233243
234- export const MoreMenuCell = ( ) => < > </ > ; // TEMPORARY
244+ export const MoreMenuCell = ( { patient } ) => {
245+ const { t } = useTranslation ( ) ;
246+ const dispatch = useDispatch ( ) ;
247+
248+ const handleOpenEditPatientDialog = ( ) => {
249+ dispatch ( setEditPatientDialogIsOpen ( true ) ) ;
250+ dispatch ( setEditPatientDialogPatientId ( patient . id ) ) ;
251+ } ;
252+
253+ const handleOpenDataConnectionsModal = ( ) => {
254+ dispatch ( setDataConnectionsModalIsOpen ( true ) ) ;
255+ dispatch ( setDataConnectionsModalPatientId ( patient . id ) ) ;
256+ } ;
257+
258+ return (
259+ < PopoverMenu
260+ id = { `action-menu-${ patient ?. id } ` }
261+ items = { [ {
262+ icon : EditIcon ,
263+ iconLabel : t ( 'Edit Patient Details' ) ,
264+ iconPosition : 'left' ,
265+ id : `edit-${ patient ?. id } ` ,
266+ variant : 'actionListItem' ,
267+ onClick : ( _popupState ) => {
268+ _popupState . close ( ) ;
269+ handleOpenEditPatientDialog ( ) ;
270+ } ,
271+ text : t ( 'Edit Patient Details' ) ,
272+ } , {
273+ iconSrc : DataInIcon ,
274+ iconLabel : t ( 'Bring Data into Tidepool' ) ,
275+ iconPosition : 'left' ,
276+ id : `edit-data-connections-${ patient ?. id } ` ,
277+ variant : 'actionListItem' ,
278+ onClick : ( _popupState ) => {
279+ _popupState . close ( ) ;
280+ handleOpenDataConnectionsModal ( ) ;
281+ } ,
282+ text : t ( 'Bring Data into Tidepool' ) ,
283+ } ] }
284+ sx = { { position : 'relative' , left : '-2px' } }
285+ />
286+ ) ;
287+ } ;
235288
236289export const PatientLastReviewedCell = ( { patient } ) => {
237290 return < PatientLastReviewed patient = { patient } /> ;
0 commit comments