-
-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WEB-3352] - TIDE Drawer Navigation Bugs #1500
base: WEB-3397-mobile-views
Are you sure you want to change the base?
Changes from 9 commits
bb8b94f
171a0ef
1275ef0
ddd2bfb
b1d11ae
4a41b41
6b72e12
dccfc78
e46fd8c
6c4473e
7dc1c7a
997cecd
e8c52f4
226dc98
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import PatientDrawer from './PatientDrawer'; | ||
import PatientDrawer, { isValidAgpPeriod } from './PatientDrawer'; | ||
|
||
export { isValidAgpPeriod }; | ||
|
||
export default PatientDrawer; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,7 @@ import PopoverMenu from '../../components/elements/PopoverMenu'; | |
import RadioGroup from '../../components/elements/RadioGroup'; | ||
import DeltaBar from '../../components/elements/DeltaBar'; | ||
import Pill from '../../components/elements/Pill'; | ||
import PatientDrawer from './PatientDrawer'; | ||
import PatientDrawer, { isValidAgpPeriod } from './PatientDrawer'; | ||
import utils from '../../core/utils'; | ||
|
||
import { | ||
|
@@ -909,15 +909,23 @@ export const TideDashboard = (props) => { | |
|
||
const drawerPatientId = new URLSearchParams(location.search).get('drawerPatientId') || null; | ||
|
||
// Failsafe to ensure blip.pdf is always cleared out after drawer is closed | ||
// Patient Drawer effects | ||
useEffect(() => { | ||
const isOpen = !!drawerPatientId; | ||
// If invalid period for AGP (ie. 1 day), clear drawerPatientId from searchParams | ||
if (!!drawerPatientId && !!config?.period && !isValidAgpPeriod(config.period)) { | ||
const { search, pathname } = location; | ||
|
||
if (!isOpen && !isEmpty(pdf)) { | ||
const params = new URLSearchParams(search); | ||
params.delete('drawerPatientId'); | ||
history.replace({ pathname, search: params.toString() }); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I really am not a fan of doing this kind of thing in side effects like this. I worked on a few of different solutions and this ended up being the best of the evils. The main challenge is the question of how to make the drawer initialize in an open or closed state but without requiring the originating page to have contextual knowledge about the TIDE dashboard. |
||
|
||
// Failsafe to ensure blip.pdf is always cleared out after drawer is closed | ||
if (!drawerPatientId && !isEmpty(pdf)) { | ||
dispatch(actions.worker.removeGeneratedPDFS()); | ||
dispatch(actions.worker.dataWorkerRemoveDataRequest(null, drawerPatientId)); | ||
} | ||
}, [drawerPatientId, pdf]); | ||
}, [drawerPatientId, pdf, config, location, history]); | ||
|
||
const handleEditPatientConfirm = useCallback(() => { | ||
trackMetric('Clinic - Edit patient confirmed', { clinicId: selectedClinicId }); | ||
|
@@ -1248,7 +1256,7 @@ export const TideDashboard = (props) => { | |
{showEditPatientDialog && renderEditPatientDialog()} | ||
|
||
<PatientDrawer | ||
patientId={showTideDashboardPatientDrawer ? drawerPatientId : null} | ||
patientId={drawerPatientId} | ||
onClose={handleClosePatientDrawer} | ||
api={api} | ||
trackMetric={trackMetric} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By storing in state here, I am just caching the value url
searchParams
at the first render, so that if the route changes, the back button has a reference to what the search params were on component mountScreen.Recording.2025-01-21.at.11.08.10.mov