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

Fix page crash due to patient user context #9836

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions src/components/ui/sidebar/app-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { OrganizationSwitcher } from "@/components/ui/sidebar/organization-switc

import { UserFacilityModel, UserModel } from "@/components/Users/models";

import { usePatientContext } from "@/hooks/usePatientUser";
import { useNullablePatientContext } from "@/hooks/usePatientUser";

import { PatientUserContextType } from "@/Providers/PatientUserProvider";
import { AppointmentPatient } from "@/pages/Patient/Utils";
Expand Down Expand Up @@ -143,7 +143,7 @@ export function AppSidebar({
const [selectedFacility, setSelectedFacility] =
React.useState<UserFacilityModel | null>(null);

const patientUserContext = usePatientContext();
const patientUserContext = useNullablePatientContext();

const { t } = useTranslation();

Expand Down
8 changes: 8 additions & 0 deletions src/hooks/usePatientUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@ export function usePatientContext() {
}
return ctx;
}

export function useNullablePatientContext() {
const ctx = useContext(PatientUserContext);
if (!ctx) {
return null;
}
return ctx;
}
Loading