Skip to content
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

Redirect "Upcoming appointments" click to Appointments tab #58

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'

Check warning on line 9 in modules/notifications/helpers.ts

View check run for this annotation

Codecov / codecov/patch

modules/notifications/helpers.ts#L9

Added line #L9 was not covered by tests
import { type PatientPageTab } from '@/routes/~_dashboard/~patients/~$id/~index'

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

Expand All @@ -19,7 +21,9 @@
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 })
}

Check warning on line 26 in modules/notifications/helpers.ts

View check run for this annotation

Codecov / codecov/patch

modules/notifications/helpers.ts#L24-L26

Added lines #L24 - L26 were not covered by tests
}
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 @@
},
patients: {
index: '/patients',
patient: (patientId: string) => `/patients/${patientId}`,
patient: (patientId: string, params?: { tab?: PatientPageTab }) =>
`/patients/${patientId}${params?.tab ? `?tab=${params.tab}` : ''}`,

Check warning on line 22 in modules/routes.ts

View check run for this annotation

Codecov / codecov/patch

modules/routes.ts#L21-L22

Added lines #L21 - L22 were not covered by tests
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 { 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'

Check warning on line 12 in routes/~_dashboard/UpcomingAppointmentsCard.tsx

View check run for this annotation

Codecov / codecov/patch

routes/~_dashboard/UpcomingAppointmentsCard.tsx#L12

Added line #L12 was not covered by tests
import { useMemo } from 'react'
import { appointmentsQueries } from '@/modules/firebase/appointment'
import { routes } from '@/modules/routes'
Expand All @@ -25,6 +25,7 @@
} 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'

Check warning on line 28 in routes/~_dashboard/UpcomingAppointmentsCard.tsx

View check run for this annotation

Codecov / codecov/patch

routes/~_dashboard/UpcomingAppointmentsCard.tsx#L28

Added line #L28 was not covered by tests

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

Check warning on line 114 in routes/~_dashboard/UpcomingAppointmentsCard.tsx

View check run for this annotation

Codecov / codecov/patch

routes/~_dashboard/UpcomingAppointmentsCard.tsx#L112-L114

Added lines #L112 - L114 were not covered by tests
}),
}}
/>
Expand Down
Loading