Skip to content

Commit

Permalink
Added method for checking pending appointment request
Browse files Browse the repository at this point in the history
  • Loading branch information
ad956 committed May 23, 2024
1 parent db75b3f commit 57af621
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/patient/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import getPatientData from "./getPatientData";
import getPatientMedicalHistory from "./getPatientMedicalHistory";
import getPayments from "./getPayments";
import getUpcomingAppointments from "./getUpcomingAppointments";
import pendingAppointmentsRequest from "./pendingAppointmentsReq";

export {
bookAppointment,
getPatientData,
getPatientMedicalHistory,
getPayments,
getUpcomingAppointments,
pendingAppointmentsRequest,
};
32 changes: 32 additions & 0 deletions lib/patient/pendingAppointmentsReq.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use server";

import { getSessionToken } from "../sessions/sessionUtils";
import getBaseUrl from "@utils/getBaseUrl";

export default async function pendingAppointmentsRequest(hospital_id: string) {
const session = await getSessionToken();
const serverUrl = getBaseUrl();

const headers = {
Authorization: `Bearer ${session}`,
};
try {
const res = await fetch(`${serverUrl}/api/patient/appointment/pending`, {
method: "POST",
body: JSON.stringify(hospital_id),
headers,
});

if (!res.ok) {
throw new Error(
`fetching pending appointment request : ${res.statusText}`
);
}

const data = await res.json();

return data;
} catch (error) {
console.error("An error occurred while :", error);
}
}

0 comments on commit 57af621

Please sign in to comment.