Skip to content

Commit

Permalink
Redirect "Upcoming appointments" click to Appointments tab (#58)
Browse files Browse the repository at this point in the history
# Redirect "Upcoming appointments" click to Appointments tab

### Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md).
  • Loading branch information
arkadiuszbachorski authored Oct 1, 2024
1 parent 9a80edf commit 0bf8c52
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 5 additions & 1 deletion modules/notifications/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// SPDX-License-Identifier: MIT
//
import { type UserMessage } from '@/modules/firebase/models'
import { routes } from '@/modules/routes'
import { type PatientPageTab } from '@/routes/~_dashboard/~patients/~$id/~index'

export const isMessageRead = (message: UserMessage) => !!message.completionDate

Expand All @@ -19,7 +21,9 @@ export const parseMessageToLink = (message: UserMessage) => {
if (actionParts.at(0) === 'users') {
const userId = actionParts.at(1)
const tab = actionParts.at(2)
return `/patients/${userId}${tab ? `?tab=${tab}` : ''}`
if (userId) {
return routes.patients.patient(userId, { tab: tab as PatientPageTab })
}
}
return null
}
Expand Down
5 changes: 4 additions & 1 deletion modules/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// SPDX-License-Identifier: MIT
//

import type { PatientPageTab } from '@/routes/~_dashboard/~patients/~$id/~index'

export const routes = {
home: '/',
notifications: '/notifications',
Expand All @@ -16,7 +18,8 @@ export const routes = {
},
patients: {
index: '/patients',
patient: (patientId: string) => `/patients/${patientId}`,
patient: (patientId: string, params?: { tab?: PatientPageTab }) =>
`/patients/${patientId}${params?.tab ? `?tab=${params.tab}` : ''}`,
invite: '/patients/invite',
},
signIn: '/sign-in',
Expand Down
7 changes: 5 additions & 2 deletions routes/~_dashboard/UpcomingAppointmentsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useQueries, useQuery } from '@tanstack/react-query'
import { useNavigate } from '@tanstack/react-router'
import { createColumnHelper } from '@tanstack/table-core'
import { addWeeks, isBefore, isFuture } from 'date-fns'
import { Loader2, Info } from 'lucide-react'
import { Info, Loader2 } from 'lucide-react'
import { useMemo } from 'react'
import { appointmentsQueries } from '@/modules/firebase/appointment'
import { routes } from '@/modules/routes'
Expand All @@ -25,6 +25,7 @@ import {
} from '@/packages/design-system/src/components/DataTable'
import { Tooltip } from '@/packages/design-system/src/components/Tooltip'
import { getUserName } from '@/packages/design-system/src/modules/auth/user'
import { PatientPageTab } from '@/routes/~_dashboard/~patients/~$id/~index'

export const UpcomingAppointmentsCard = () => {
const navigate = useNavigate()
Expand Down Expand Up @@ -108,7 +109,9 @@ export const UpcomingAppointmentsCard = () => {
tableView={{
onRowClick: (appointment) =>
void navigate({
to: routes.patients.patient(appointment.patient.id),
to: routes.patients.patient(appointment.patient.id, {
tab: PatientPageTab.appointments,
}),
}),
}}
/>
Expand Down

0 comments on commit 0bf8c52

Please sign in to comment.