Skip to content

Commit

Permalink
added warning on doctor notes usage if not subscribed (#7224)
Browse files Browse the repository at this point in the history
* added warning on doctor notes usage if not subscribed

* removing unnecessary console logs
  • Loading branch information
Bhavik-ag authored Feb 21, 2024
1 parent 077635f commit 59a205f
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Components/Facility/PatientNotesSlideover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import routes from "../../Redux/api";
import { PatientNoteStateType } from "./models";
import useKeyboardShortcut from "use-keyboard-shortcut";
import AutoExpandingTextInputFormField from "../Form/FormFields/AutoExpandingTextInputFormField.js";
import * as Sentry from "@sentry/browser";
import useAuthUser from "../../Common/hooks/useAuthUser";

interface PatientNotesProps {
patientId: string;
Expand All @@ -26,6 +28,33 @@ export default function PatientNotesSlideover(props: PatientNotesProps) {
const [reload, setReload] = useState(false);
const [focused, setFocused] = useState(false);

const { username } = useAuthUser();

const intialSubscriptionState = async () => {
try {
const res = await request(routes.getUserPnconfig, {
pathParams: { username },
});
const reg = await navigator.serviceWorker.ready;
const subscription = await reg.pushManager.getSubscription();
if (!subscription && !res.data?.pf_endpoint) {
Notification.Warn({
msg: "Please subscribe to notifications to get live updates on doctor notes.",
});
} else if (subscription?.endpoint !== res.data?.pf_endpoint) {
Notification.Warn({
msg: "Please subscribe to notifications on this device to get live updates on doctor notes.",
});
}
} catch (error) {
Sentry.captureException(error);
}
};

useEffect(() => {
intialSubscriptionState();
}, []);

const initialData: PatientNoteStateType = {
notes: [],
cPage: 1,
Expand Down

0 comments on commit 59a205f

Please sign in to comment.