feat(doctor): wire rich rating/review UI to multi-dimensional API
Connect the existing doctor-page review UI to the rebuilt backend contract
(see clinicpro feat/rating-multidimensional).
- page.js fetches the rating aggregate alongside comments and passes
rateAggregate down to the chart (point / satisfaction / 5 dimensions).
- Submit form sends the five dimensions with doctor_uuid; comment/reply
send {doctor_uuid, comment, parent}; 401/403 ERR_RATING_NOT_ELIGIBLE
surface friendly guidance.
- Like/dislike call POST /like/{uuid} with value and update from the
response; replies render nested.
- ModalAnswer gates the submit button on GET /rate/{uuid}/eligibility.
- services/response.js: getRateEligibility, postCommentsLike(uuid, value),
drop unused patchDoctorRate. Fix hardcoded modal title; empty-state for
no comments. Remove orphaned AnswerField.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -45,16 +45,19 @@ async function Doctor({ params }) {
|
||||
const { slug } = await params;
|
||||
let doctor = null;
|
||||
let comments = null;
|
||||
let rateAggregate = { point: 0, satisfaction: 0, averages: [] };
|
||||
const API_URL = process.env.NEXT_PUBLIC_API_URL;
|
||||
|
||||
try {
|
||||
const resDoctor = await axiosInstance.get(`${API_URL}/api/v1/doctor/${slug}`);
|
||||
doctor = resDoctor.data?.data?.data;
|
||||
if (doctor) {
|
||||
const resComments = await axiosInstance.get(
|
||||
`${API_URL}/api/v1/comments/${doctor.uuid}`
|
||||
);
|
||||
const [resComments, resRate] = await Promise.all([
|
||||
axiosInstance.get(`${API_URL}/api/v1/comments/${doctor.uuid}`),
|
||||
axiosInstance.get(`${API_URL}/api/v1/rate/${doctor.uuid}`),
|
||||
]);
|
||||
comments = resComments?.data?.data?.data;
|
||||
rateAggregate = resRate?.data?.data?.data ?? rateAggregate;
|
||||
}
|
||||
} catch (error) {}
|
||||
|
||||
@@ -84,7 +87,12 @@ async function Doctor({ params }) {
|
||||
/>
|
||||
)}
|
||||
<Layout>
|
||||
<DoctorPage doctor={doctor} comments={comments} slug={slug} />
|
||||
<DoctorPage
|
||||
doctor={doctor}
|
||||
comments={comments}
|
||||
rateAggregate={rateAggregate}
|
||||
slug={slug}
|
||||
/>
|
||||
</Layout>
|
||||
</>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user