get data with filter location for first time, get comment of doctor and show in doctor page, handle new comment

This commit is contained in:
Ehsan
2025-09-03 22:05:26 +03:30
parent 6920e4078b
commit ebfe47468c
14 changed files with 187 additions and 50 deletions
+8 -1
View File
@@ -5,6 +5,7 @@ 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"
@@ -15,6 +16,12 @@ async function Doctor({ params: { 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");
@@ -22,7 +29,7 @@ async function Doctor({ params: { slug } }) {
return (
<Layout>
<DoctorPage doctor={doctor} doctors={doctors} />
<DoctorPage doctor={doctor} doctors={doctors} comments={comments} />
</Layout>
);
}