Skip to content

Commit

Permalink
redirect to patient page post update status to in_consultation (ohcne…
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad authored Jan 2, 2025
1 parent 328fedc commit 34d7cbb
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/components/Schedule/Appointments/AppointmentDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,34 @@ export default function AppointmentDetailsPage(props: Props) {
}),
});

const { mutate: updateAppointment, isPending } = useMutation({
const redirectToPatientPage = () => {
navigate(`/facility/${props.facilityId}/patients/verify`, {
query: {
phone_number: patient.phone_number,
year_of_birth: patient.year_of_birth,
partial_id: patient.id.slice(0, 5),
},
});
};

const { mutate: updateAppointment, isPending } = useMutation<
Appointment,
unknown,
{ status: Appointment["status"] }
>({
mutationFn: mutate(ScheduleAPIs.appointments.update, {
pathParams: {
facility_id: props.facilityId,
id: props.appointmentId,
},
}),
onSuccess: () => {
onSuccess: (_, request) => {
queryClient.invalidateQueries({
queryKey: ["appointment", props.appointmentId],
});
if (request.status === "in_consultation") {
redirectToPatientPage();
}
},
});

Expand Down Expand Up @@ -160,15 +177,7 @@ export default function AppointmentDetailsPage(props: Props) {
<AppointmentActions
appointment={appointment}
onChange={(status) => updateAppointment({ status })}
onViewPatient={() => {
navigate(`/facility/${props.facilityId}/patients/verify`, {
query: {
phone_number: patient.phone_number,
year_of_birth: patient.year_of_birth,
partial_id: patient.id.slice(0, 5),
},
});
}}
onViewPatient={redirectToPatientPage}
/>
</div>
</div>
Expand Down

0 comments on commit 34d7cbb

Please sign in to comment.