38 lines
994 B
JavaScript
38 lines
994 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;
|
|
try {
|
|
const resDoctors = await axios.get(
|
|
"https://back-dev.clinic-pro.ir/api/v1/doctors?active=1"
|
|
);
|
|
const resDoctor = await axios.get(
|
|
`https://back-dev.clinic-pro.ir/api/v1/doctor/${slug}`
|
|
);
|
|
|
|
doctor = resDoctor.data;
|
|
doctors = resDoctors.data.data;
|
|
if (doctor) {
|
|
const resComments = await axios.get(
|
|
`https://back-dev.clinic-pro.ir/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;
|