fix(appointment): unwrap doctor response and drop dead not-available call

The doctor endpoint is triple-nested, so doctorRes.data left doctor.id
undefined and the booking page received a broken doctor object. Extract
with data?.data?.data and remove the disabledDates fetch to the
nonexistent /appointment/not-available route (404); pass [] so the date
picker enables all dates and lets the slots response gate availability.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-06-15 15:37:47 +03:30
co-authored by Claude Opus 4.8
parent 811882ea05
commit 0e112d2299
+2 -11
View File
@@ -8,25 +8,16 @@ async function Appointment({ params }) {
const API_URL = process.env.NEXT_PUBLIC_API_URL;
let doctor = null;
let disabledDates = [];
try {
const doctorRes = await axiosInstance.get(`${API_URL}/api/v1/doctor/${doctorId}`);
doctor = doctorRes.data;
if (doctor && doctor.id) {
const disabledDatesRes = await axiosInstance.get(
`${API_URL}/api/v1/appointment/not-available/${doctor.id}`,
{ headers: { "Content-Type": "application/json" } }
);
disabledDates = disabledDatesRes.data?.data || [];
}
doctor = doctorRes.data?.data?.data;
} catch (error) {}
return (
<AppointmentPage
doctor={doctor}
disabledDates={disabledDates}
disabledDates={[]}
matchedCity={matchedCity}
/>
);