From 344aa4d3d8b66f0226dad2ce74559e31063f2ddf Mon Sep 17 00:00:00 2001 From: Arkadiusz Bachorski <60391032+arkadiuszbachorski@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:52:18 +0200 Subject: [PATCH 1/2] Use routes inside parseMessageToLink --- modules/notifications/helpers.ts | 6 +++++- modules/routes.ts | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/notifications/helpers.ts b/modules/notifications/helpers.ts index c648b96c..05c6c922 100644 --- a/modules/notifications/helpers.ts +++ b/modules/notifications/helpers.ts @@ -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 @@ -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 } diff --git a/modules/routes.ts b/modules/routes.ts index 7fb159b2..2880be3e 100644 --- a/modules/routes.ts +++ b/modules/routes.ts @@ -6,6 +6,8 @@ // SPDX-License-Identifier: MIT // +import type { PatientPageTab } from '@/routes/~_dashboard/~patients/~$id/~index' + export const routes = { home: '/', notifications: '/notifications', @@ -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', From f3aa1544024b08a99b2b9e76a9a97b6d3e3a785e Mon Sep 17 00:00:00 2001 From: Arkadiusz Bachorski <60391032+arkadiuszbachorski@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:53:16 +0200 Subject: [PATCH 2/2] Redirect "Upcoming appointments" click to Appointments tab --- routes/~_dashboard/UpcomingAppointmentsCard.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/routes/~_dashboard/UpcomingAppointmentsCard.tsx b/routes/~_dashboard/UpcomingAppointmentsCard.tsx index 9fb99d3e..5f712351 100644 --- a/routes/~_dashboard/UpcomingAppointmentsCard.tsx +++ b/routes/~_dashboard/UpcomingAppointmentsCard.tsx @@ -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' @@ -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() @@ -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, + }), }), }} />