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