Skip to content

Commit

Permalink
ft(booking):add logic to create notification for each key action
Browse files Browse the repository at this point in the history
  • Loading branch information
23nosurrend committed Jul 21, 2024
2 parents 86eb42a + a522889 commit 14bf6da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/(app)/ActionMenu/Booking/SelectPayment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default function SelectPayment() {
console.log("Error while inserting data in booking ", error);
}
}
const addNotification = async ( doctorName: string) => {
const addNotification = async ( doctorName: string,doctorId:string) => {
try {
const { error } = await supabase
.from('notifications')
Expand All @@ -95,7 +95,7 @@ export default function SelectPayment() {
description: `You have successfully booked an appointment with Dr. ${doctorName}`,
patient_id: patient_id,
type: "appointment_booked",
doctor_id: doctor_id,
doctor_id: doctorId,
viewed:false

});
Expand Down Expand Up @@ -219,7 +219,7 @@ console.log("Notification will be pushed")
bookAppointment();
if (typeof doctor_id === "string") {
const doctorName = await fetchDoctorName(doctor_id);
await addNotification(doctorName);
await addNotification(doctorName,doctor_id);
}
showSuccefulModal();
} else {
Expand Down
5 changes: 3 additions & 2 deletions app/(app)/Appointments/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,13 @@ const AppointmentScreen: React.FC = () => {

const handleCancel =async (id:string,doctor_id:string) => {
setAppointmentId(id);


setShowPopup(true);
if (typeof doctor_id === "string") {
const doctorName = await fetchDoctorName(doctor_id);
await addNotification(doctorName);
}

setShowPopup(true);
}

const filteredAppointments = appointments.filter((appointment) => {
Expand Down

0 comments on commit 14bf6da

Please sign in to comment.