diff --git a/src/Routers/SessionRouter.tsx b/src/Routers/SessionRouter.tsx index 86b4770288f..56c36536b8d 100644 --- a/src/Routers/SessionRouter.tsx +++ b/src/Routers/SessionRouter.tsx @@ -20,52 +20,36 @@ export const routes = { "/": () => , "/facilities": () => , "/facility/:id": ({ id }: { id: string }) => , - "/facility/:facilityId/appointments/:staffUsername/otp/:page": ({ + "/facility/:facilityId/appointments/:staffId/otp/:page": ({ facilityId, - staffUsername, + staffId, page, }: { facilityId: string; - staffUsername: string; + staffId: string; page: string; - }) => ( - - ), - "/facility/:facilityId/appointments/:staffExternalId/book-appointment": ({ + }) => , + "/facility/:facilityId/appointments/:staffId/book-appointment": ({ facilityId, - staffExternalId, + staffId, }: { facilityId: string; - staffExternalId: string; - }) => ( - - ), - "/facility/:facilityId/appointments/:staffUsername/patient-select": ({ + staffId: string; + }) => , + "/facility/:facilityId/appointments/:staffId/patient-select": ({ facilityId, - staffUsername, + staffId, }: { facilityId: string; - staffUsername: string; - }) => , - "/facility/:facilityId/appointments/:staffUsername/patient-registration": ({ + staffId: string; + }) => , + "/facility/:facilityId/appointments/:staffId/patient-registration": ({ facilityId, - staffUsername, + staffId, }: { facilityId: string; - staffUsername: string; - }) => ( - - ), + staffId: string; + }) => , "/login": () => , "/forgot-password": () => , "/password_reset/:token": ({ token }: { token: string }) => ( diff --git a/src/Utils/request/api.tsx b/src/Utils/request/api.tsx index c1ee0c6c5a7..23e4897fd0e 100644 --- a/src/Utils/request/api.tsx +++ b/src/Utils/request/api.tsx @@ -366,7 +366,7 @@ const routes = { getScheduleAbleFacilityUser: { path: "/api/v1/facility/{facility_id}/schedulable_users/{user_id}/", - TRes: Type(), + TRes: Type(), }, getScheduleAbleFacilityUsers: { diff --git a/src/pages/Appoinments/PatientRegistration.tsx b/src/pages/Appoinments/PatientRegistration.tsx index c026bb124ef..512ae8ca42d 100644 --- a/src/pages/Appoinments/PatientRegistration.tsx +++ b/src/pages/Appoinments/PatientRegistration.tsx @@ -62,11 +62,11 @@ const initialForm: AppointmentPatientRegister & { type PatientRegistrationProps = { facilityId: string; - staffUsername: string; + staffId: string; }; export function PatientRegistration(props: PatientRegistrationProps) { - const { staffUsername } = props; + const { staffId } = props; const selectedSlot = JSON.parse( localStorage.getItem("selectedSlot") ?? "", ) as SlotAvailability; @@ -230,7 +230,7 @@ export function PatientRegistration(props: PatientRegistrationProps) { type="button" onClick={() => navigate( - `/facility/${props.facilityId}/appointments/${staffUsername}/patient-select`, + `/facility/${props.facilityId}/appointments/${staffId}/patient-select`, ) } > @@ -436,7 +436,7 @@ export function PatientRegistration(props: PatientRegistrationProps) { type="button" onClick={() => navigate( - `/facility/${props.facilityId}/appointments/${staffUsername}/patient-select`, + `/facility/${props.facilityId}/appointments/${staffId}/patient-select`, ) } > diff --git a/src/pages/Appoinments/PatientSelect.tsx b/src/pages/Appoinments/PatientSelect.tsx index 8506130ea67..de239cdda2a 100644 --- a/src/pages/Appoinments/PatientSelect.tsx +++ b/src/pages/Appoinments/PatientSelect.tsx @@ -27,10 +27,10 @@ import { TokenData } from "@/types/auth/otpToken"; export default function PatientSelect({ facilityId, - staffUsername, + staffId, }: { facilityId: string; - staffUsername: string; + staffId: string; }) { const { t } = useTranslation(); const selectedSlot = JSON.parse( @@ -44,16 +44,16 @@ export default function PatientSelect({ const queryClient = useQueryClient(); - if (!staffUsername) { - Notification.Error({ msg: "Staff Username Not Found" }); + if (!staffId) { + Notification.Error({ msg: "Staff Not Found" }); navigate(`/facility/${facilityId}/`); } else if (!tokenData) { Notification.Error({ msg: "Phone Number Not Found" }); - navigate(`/facility/${facilityId}/appointments/${staffUsername}/otp/send`); + navigate(`/facility/${facilityId}/appointments/${staffId}/otp/send`); } else if (!selectedSlot) { Notification.Error({ msg: "Selected Slot Not Found" }); navigate( - `/facility/${facilityId}/appointments/${staffUsername}/book-appointment`, + `/facility/${facilityId}/appointments/${staffId}/book-appointment`, ); } @@ -205,7 +205,7 @@ export default function PatientSelect({ className="border border-secondary-400" onClick={() => navigate( - `/facility/${facilityId}/appointments/${staffUsername}/book-appointment`, + `/facility/${facilityId}/appointments/${staffId}/book-appointment`, ) } > @@ -229,7 +229,7 @@ export default function PatientSelect({ className="w-1/2 self-center" onClick={() => navigate( - `/facility/${facilityId}/appointments/${staffUsername}/patient-registration`, + `/facility/${facilityId}/appointments/${staffId}/patient-registration`, ) } > diff --git a/src/pages/Appoinments/Schedule.tsx b/src/pages/Appoinments/Schedule.tsx index 2473a51fc8b..62d67b3db07 100644 --- a/src/pages/Appoinments/Schedule.tsx +++ b/src/pages/Appoinments/Schedule.tsx @@ -32,12 +32,12 @@ import { TokenData } from "@/types/auth/otpToken"; interface AppointmentsProps { facilityId: string; - staffExternalId: string; + staffId: string; } export function ScheduleAppointment(props: AppointmentsProps) { const { t } = useTranslation(); - const { facilityId, staffExternalId } = props; + const { facilityId, staffId } = props; const [selectedMonth, setSelectedMonth] = useState(new Date()); const [selectedDate, setSelectedDate] = useState(new Date()); const [selectedSlot, setSelectedSlot] = useState(); @@ -47,14 +47,12 @@ export function ScheduleAppointment(props: AppointmentsProps) { localStorage.getItem(CarePatientTokenKey) || "{}", ); - if (!staffExternalId) { + if (!staffId) { Notification.Error({ msg: "Staff username not found" }); navigate(`/facility/${facilityId}/`); } else if (!tokenData) { Notification.Error({ msg: "Phone number not found" }); - navigate( - `/facility/${facilityId}/appointments/${staffExternalId}/otp/send`, - ); + navigate(`/facility/${facilityId}/appointments/${staffId}/otp/send`); } const { data: facilityResponse, error: facilityError } = useQuery< @@ -73,12 +71,11 @@ export function ScheduleAppointment(props: AppointmentsProps) { } const { data: userData, error: userError } = useQuery({ - queryKey: ["user", staffExternalId], - queryFn: () => - request(routes.getScheduleAbleFacilityUser, { - pathParams: { facilityId: facilityId, user_id: staffExternalId }, - }), - enabled: !!staffExternalId, + queryKey: ["user", facilityId, staffId], + queryFn: query(routes.getScheduleAbleFacilityUser, { + pathParams: { facility_id: facilityId, user_id: staffId }, + }), + enabled: !!facilityId && !!staffId, }); if (userError) { @@ -86,11 +83,11 @@ export function ScheduleAppointment(props: AppointmentsProps) { } const slotsQuery = useQuery<{ results: SlotAvailability[] }>({ - queryKey: ["slots", facilityId, staffExternalId, selectedDate], + queryKey: ["slots", facilityId, staffId, selectedDate], queryFn: query(routes.otp.getSlotsForDay, { body: { facility: facilityId, - resource: staffExternalId, + resource: staffId, day: dateQueryString(selectedDate), }, headers: { @@ -135,12 +132,10 @@ export function ScheduleAppointment(props: AppointmentsProps) { ); }; - if (!userData?.data) { + if (!userData) { return ; } - const user = userData.data; - return (
@@ -162,24 +157,24 @@ export function ScheduleAppointment(props: AppointmentsProps) {

- {user.user_type === "Doctor" - ? `Dr. ${user.first_name} ${user.last_name}` - : `${user.first_name} ${user.last_name}`} + {userData.user_type === "doctor" + ? `Dr. ${userData.first_name} ${userData.last_name}` + : `${userData.first_name} ${userData.last_name}`}

- {user.user_type} + {userData.user_type}

{/*

Education:

- {user.qualification} + {userData.qualification}

*/}
@@ -198,9 +193,9 @@ export function ScheduleAppointment(props: AppointmentsProps) {
{t("book_an_appointment_with")}{" "} - {user.user_type === "Doctor" - ? `Dr. ${user.first_name} ${user.last_name}` - : `${user.first_name} ${user.last_name}`} + {userData.user_type === "doctor" + ? `Dr. ${userData.first_name} ${userData.last_name}` + : `${userData.first_name} ${userData.last_name}`}
@@ -299,7 +294,7 @@ export function ScheduleAppointment(props: AppointmentsProps) { ); localStorage.setItem("reason", reason); navigate( - `/facility/${facilityId}/appointments/${staffExternalId}/patient-select`, + `/facility/${facilityId}/appointments/${staffId}/patient-select`, ); }} > diff --git a/src/pages/Appoinments/auth/PatientLogin.tsx b/src/pages/Appoinments/auth/PatientLogin.tsx index b4963847471..5b1ae45f76e 100644 --- a/src/pages/Appoinments/auth/PatientLogin.tsx +++ b/src/pages/Appoinments/auth/PatientLogin.tsx @@ -47,11 +47,11 @@ const FormSchema = z.object({ export default function PatientLogin({ facilityId, - staffUsername, + staffId, page, }: { facilityId: string; - staffUsername: string; + staffId: string; page: string; }) { const { goBack } = useAppHistory(); @@ -74,7 +74,7 @@ export default function PatientLogin({ dayjs(tokenData.createdAt).isAfter(dayjs().subtract(14, "minutes")) ) { navigate( - `/facility/${facilityId}/appointments/${staffUsername}/book-appointment`, + `/facility/${facilityId}/appointments/${staffId}/book-appointment`, ); } const validate = (phoneNumber: string) => { @@ -110,11 +110,11 @@ export default function PatientLogin({ ) { Notification.Success({ msg: t("valid_otp_found") }); navigate( - `/facility/${facilityId}/appointments/${staffUsername}/book-appointment`, + `/facility/${facilityId}/appointments/${staffId}/book-appointment`, ); } else { navigate( - `/facility/${facilityId}/appointments/${staffUsername}/otp/verify`, + `/facility/${facilityId}/appointments/${staffId}/otp/verify`, ); } } @@ -162,7 +162,7 @@ export default function PatientLogin({ }; localStorage.setItem(CarePatientTokenKey, JSON.stringify(tokenData)); navigate( - `/facility/${facilityId}/appointments/${staffUsername}/book-appointment`, + `/facility/${facilityId}/appointments/${staffId}/book-appointment`, ); } }, @@ -289,7 +289,7 @@ export default function PatientLogin({ page === "send" ? goBack() : navigate( - `/facility/${facilityId}/appointments/${staffUsername}/otp/send`, + `/facility/${facilityId}/appointments/${staffId}/otp/send`, ) } > diff --git a/src/pages/Facility/components/UserCard.tsx b/src/pages/Facility/components/UserCard.tsx index 2cfe886d1c2..7ae0221e4ff 100644 --- a/src/pages/Facility/components/UserCard.tsx +++ b/src/pages/Facility/components/UserCard.tsx @@ -36,10 +36,10 @@ export function UserCard({ user, className, facilityId }: Props) { Object.keys(tokenData).length > 0 && dayjs(tokenData.createdAt).isAfter(dayjs().subtract(14, "minutes")) ) { - return `/facility/${facilityId}/appointments/${user.external_id}/book-appointment`; + return `/facility/${facilityId}/appointments/${user.id}/book-appointment`; } - return `/facility/${facilityId}/appointments/${user.external_id}/otp/send`; - }, [tokenData, facilityId, user.external_id]); + return `/facility/${facilityId}/appointments/${user.id}/otp/send`; + }, [tokenData, facilityId, user.id]); return (