43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
import AppointmentPage from "@/components/appointment";
|
|
import { getStateInfo } from "@/lib/getStateInfo";
|
|
import axios from "axios";
|
|
|
|
async function Appointment({ params: { doctorId } }) {
|
|
const { matchedCity } = getStateInfo();
|
|
const API_URL = process.env.NEXT_PUBLIC_API_URL;
|
|
|
|
let doctor = null;
|
|
let disabledDates = [];
|
|
|
|
try {
|
|
// دریافت اطلاعات دکتر با UUID
|
|
const doctorRes = await axios.get(`${API_URL}/api/v1/doctor/${doctorId}`);
|
|
doctor = doctorRes.data;
|
|
|
|
// دریافت روزهای غیرفعال با استفاده از doctor.id
|
|
if (doctor && doctor.id) {
|
|
const disabledDatesRes = await axios.get(
|
|
`${API_URL}/api/v1/appointment/not-available/${doctor.id}`,
|
|
{
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
}
|
|
}
|
|
);
|
|
disabledDates = disabledDatesRes.data?.data || [];
|
|
}
|
|
} catch (error) {
|
|
console.error("Error fetching appointment data:", error.message);
|
|
}
|
|
|
|
return (
|
|
<AppointmentPage
|
|
doctor={doctor}
|
|
disabledDates={disabledDates}
|
|
matchedCity={matchedCity}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export default Appointment;
|