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:
@@ -2,13 +2,13 @@ import CircularLoading from "@/app/component/loading/Circular";
|
||||
import { numberToArStyle } from "@/helper";
|
||||
import { CircularProgress } from "@mui/material";
|
||||
|
||||
function ProgressAll({ doctor }) {
|
||||
function ProgressAll({ satisfaction }) {
|
||||
return (
|
||||
<div className="hidden lg:flex w-full h-fit relative min-w-[145px] max-w-[150px]">
|
||||
<CircularLoading width={120} height={120}>
|
||||
<CircularProgress
|
||||
variant="determinate"
|
||||
value={doctor?.satisfaction}
|
||||
value={satisfaction || 0}
|
||||
sx={{
|
||||
"& .MuiCircularProgress-circle": {
|
||||
stroke: "#05BA58",
|
||||
@@ -28,7 +28,7 @@ function ProgressAll({ doctor }) {
|
||||
رضایت کاربران
|
||||
</p>
|
||||
<p className="text-[#3B3B3B]">
|
||||
{numberToArStyle(doctor?.satisfaction)}%
|
||||
{numberToArStyle(satisfaction || 0)}%
|
||||
</p>
|
||||
</div>
|
||||
</CircularLoading>
|
||||
|
||||
@@ -6,22 +6,24 @@ import ProgressDetail from "@/app/component/ProfressDetail";
|
||||
import TextLoading from "@/app/component/loading/Text";
|
||||
import CustomLoading from "@/app/component/loading/Custom";
|
||||
|
||||
function Chart({ comments, doctor }) {
|
||||
const averages = doctor?.average_rate?.averages;
|
||||
function Chart({ comments, rateAggregate }) {
|
||||
const point = rateAggregate?.point ?? 0;
|
||||
const satisfaction = rateAggregate?.satisfaction ?? 0;
|
||||
const averages = rateAggregate?.averages ?? [];
|
||||
return (
|
||||
<div
|
||||
className="
|
||||
rounded-lg my-[12px] sm:my-[16px] md:my-[20px] lg:my-[24px] border border-[#EFEFEF] bg-[#FFF]
|
||||
rounded-lg my-[12px] sm:my-[16px] md:my-[20px] lg:my-[24px] border border-[#EFEFEF] bg-[#FFF]
|
||||
pt-[12px] md:pt-[14px] lg:pt-[16px] pb-[12px] sm:pb-[16px] md:pb-[20px] lg:pb-[24px] px-[12px] sm:px-[16px] md:px-[20px] lg:px-[24px]
|
||||
"
|
||||
>
|
||||
<TextLoading width={130} height={20}>
|
||||
<div className="flex items-center justify-start gap-2.5">
|
||||
<p className="text-[#616161] text-[14px] font-medium">
|
||||
امتیاز کلی کاربران: {doctor?.point} از 5
|
||||
امتیاز کلی کاربران: {point} از 5
|
||||
</p>
|
||||
<p className="text-[#7E7E7E] text-[14px] font-normal">
|
||||
(از مجموع {comments?.length} نظر)
|
||||
(از مجموع {comments?.length || 0} نظر)
|
||||
</p>
|
||||
</div>
|
||||
</TextLoading>
|
||||
@@ -29,7 +31,8 @@ function Chart({ comments, doctor }) {
|
||||
<TextLoading width={160} height={20}>
|
||||
<Rating
|
||||
readOnly
|
||||
value={3.5}
|
||||
value={point}
|
||||
precision={0.5}
|
||||
size="small"
|
||||
name="read-only"
|
||||
className="!mt-4 !mb-6 !hidden lg:!flex"
|
||||
@@ -41,26 +44,24 @@ function Chart({ comments, doctor }) {
|
||||
<div className="flex p-1 gap-0.5 items-start justify-center">
|
||||
<StarDI />
|
||||
<p className="text-[#616161] text-[12px] md:text-[14px] font-normal">
|
||||
امتیاز: {doctor?.point}
|
||||
امتیاز: {point}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex p-1 items-start gap-0.5">
|
||||
<LikeDI />
|
||||
<p className="text-[#616161] text-[12px] md:text-[14px] font-normal">
|
||||
{doctor?.satisfaction}% رضایت کاربران
|
||||
{satisfaction}% رضایت کاربران
|
||||
</p>
|
||||
</div>
|
||||
</CustomLoading>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center justify-center gap-[50px]">
|
||||
<ul className="flex w-full flex-col items-start justify-start gap-1.5 lg:w-fit">
|
||||
{Object.values(averages ? averages : Array(5).fill(false)).map(
|
||||
(item, idx) => (
|
||||
<ProgressDetail data={item} idx={idx} key={idx} />
|
||||
)
|
||||
)}
|
||||
{(averages.length ? averages : Array(5).fill(null)).map((item, idx) => (
|
||||
<ProgressDetail data={item} idx={idx} key={idx} />
|
||||
))}
|
||||
</ul>
|
||||
<ProgressAll doctor={doctor} />
|
||||
<ProgressAll satisfaction={satisfaction} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user