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:
@@ -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}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user