40 lines
986 B
JavaScript
40 lines
986 B
JavaScript
import DoctorPage from "@/components/doctor";
|
|
import Layout from "@/components/layout/StLayout";
|
|
import axios from "axios";
|
|
|
|
async function Doctor({ params: { slug } }) {
|
|
let doctors = null;
|
|
let doctor = null;
|
|
let comments = null;
|
|
const API_URL = process.env.NEXT_PUBLIC_API_URL;
|
|
|
|
try {
|
|
const resDoctors = await axios.get(
|
|
`${API_URL}/api/v1/doctors?active=1`
|
|
);
|
|
const resDoctor = await axios.get(
|
|
`${API_URL}/api/v1/doctor/${slug}`
|
|
);
|
|
|
|
doctor = resDoctor.data;
|
|
doctors = resDoctors.data.data;
|
|
if (doctor) {
|
|
const resComments = await axios.get(
|
|
`${API_URL}/api/v1/clinicpro/comments/${doctor.id}`
|
|
);
|
|
comments = resComments?.data?.data;
|
|
}
|
|
} catch (error) {
|
|
// console.error("problem with req:", error.message);
|
|
// return redirect("/unauthorized");
|
|
}
|
|
|
|
return (
|
|
<Layout>
|
|
<DoctorPage doctor={doctor} doctors={doctors} comments={comments} />
|
|
</Layout>
|
|
);
|
|
}
|
|
|
|
export default Doctor;
|