feat: add feature toggles for doctor share and ratings functionality

This commit is contained in:
hamed
2026-07-30 09:05:45 +03:30
parent eb83762016
commit e87a0bae9b
6 changed files with 37 additions and 9 deletions
+4 -1
View File
@@ -10,6 +10,7 @@ import { isNoindexDoctor } from "@/lib/entityQuality";
import specialtiesData from "@/data/specialties.json"; import specialtiesData from "@/data/specialties.json";
import { safeJsonLd } from "@/lib/sanitize"; import { safeJsonLd } from "@/lib/sanitize";
import { imageUrl, doctorTitle } from "@/helper"; import { imageUrl, doctorTitle } from "@/helper";
import { FEATURES } from "@/config/features";
const API_URL = process.env.NEXT_PUBLIC_API_URL; const API_URL = process.env.NEXT_PUBLIC_API_URL;
const FALLBACK_IMG = "/assets/images/og-image.png"; const FALLBACK_IMG = "/assets/images/og-image.png";
@@ -189,7 +190,9 @@ async function Doctor({ params }) {
url: imageUrl(doctor.img[0].url), url: imageUrl(doctor.img[0].url),
}, },
}), }),
...(!isUnclaimed && Number(doctor.point) > 0 && { // امتیاز وقتی در صفحه پنهان است نباید در schema بیاید؛ گوگل داده ساخت‌یافتهٔ
// نامرئی را نقض راهنما می‌داند.
...(FEATURES.doctorRatings && !isUnclaimed && Number(doctor.point) > 0 && {
aggregateRating: { aggregateRating: {
"@type": "AggregateRating", "@type": "AggregateRating",
ratingValue: doctor.point, ratingValue: doctor.point,
+2 -1
View File
@@ -11,6 +11,7 @@ import Telegram from "@/components/icons/Telegram";
import Aparat from "@/components/icons/Aparat"; import Aparat from "@/components/icons/Aparat";
import Youtube from "@/components/icons/Youtube"; import Youtube from "@/components/icons/Youtube";
import Linkedin from "@/components/icons/Linkedin"; import Linkedin from "@/components/icons/Linkedin";
import { FEATURES } from "@/config/features";
const SOCIAL_ICONS = { const SOCIAL_ICONS = {
instagram: Instagram, instagram: Instagram,
@@ -22,7 +23,7 @@ const SOCIAL_ICONS = {
function Title({ doctor }) { function Title({ doctor }) {
const isUnclaimed = doctor?.owner_status !== "claimed"; const isUnclaimed = doctor?.owner_status !== "claimed";
const hasRating = Number(doctor?.point) > 0; const hasRating = FEATURES.doctorRatings && Number(doctor?.point) > 0;
return ( return (
<div className="flex flex-col lg:flex-row items-center justify-start gap-[8px] lg:gap-[32px]"> <div className="flex flex-col lg:flex-row items-center justify-start gap-[8px] lg:gap-[32px]">
<CircularLoading width={100} height={100}> <CircularLoading width={100} height={100}>
@@ -3,6 +3,7 @@
import Chart from "./chart"; import Chart from "./chart";
import Comment from "@/app/component/comment"; import Comment from "@/app/component/comment";
import ModalAnswer from "./modal/ModalAnswer"; import ModalAnswer from "./modal/ModalAnswer";
import { FEATURES } from "@/config/features";
function Comments({ doctor, comments, rateAggregate }) { function Comments({ doctor, comments, rateAggregate }) {
const isUnclaimed = doctor?.owner_status !== "claimed"; const isUnclaimed = doctor?.owner_status !== "claimed";
@@ -30,7 +31,10 @@ function Comments({ doctor, comments, rateAggregate }) {
</p> </p>
) : ( ) : (
<> <>
<Chart comments={comments} rateAggregate={rateAggregate} /> {/* نمودار امتیاز/رضایت فعلاً پنهان است؛ خودِ نظرات نمایش داده می‌شود. */}
{FEATURES.doctorRatings && (
<Chart comments={comments} rateAggregate={rateAggregate} />
)}
<Comment comments={comments} doctor={doctor} /> <Comment comments={comments} doctor={doctor} />
</> </>
)} )}
+6 -3
View File
@@ -4,13 +4,16 @@ import Title from "./Title";
import AboutDcotor from "./cards/AboutDcotor"; import AboutDcotor from "./cards/AboutDcotor";
import Comments from "./cards/comments"; import Comments from "./cards/comments";
import Locations from "./cards/locations"; import Locations from "./cards/locations";
import { FEATURES } from "@/config/features";
function DetailDoctor({ doctor, comments, rateAggregate, addresses, bookableAddressUuids = [] }) { function DetailDoctor({ doctor, comments, rateAggregate, addresses, bookableAddressUuids = [] }) {
return ( return (
<div className="w-full lg:w-[59%]"> <div className="w-full lg:w-[59%]">
<div className="hidden lg:flex"> {FEATURES.doctorShare && (
<Share data={doctor} /> <div className="hidden lg:flex">
</div> <Share data={doctor} />
</div>
)}
<Title doctor={doctor} /> <Title doctor={doctor} />
<Link /> <Link />
<AboutDcotor doctor={doctor} /> <AboutDcotor doctor={doctor} />
+6 -3
View File
@@ -7,6 +7,7 @@ import CustomLoading from "@/app/component/loading/Custom";
import Faq from "@/components/specialties/detail/Faq"; import Faq from "@/components/specialties/detail/Faq";
import specialtiesData from "@/data/specialties.json"; import specialtiesData from "@/data/specialties.json";
import { doctorTitle } from "@/helper"; import { doctorTitle } from "@/helper";
import { FEATURES } from "@/config/features";
// مقصد تمیز صفحهٔ فرود تخصص؛ اگر تخصص slug نداشت، لیست پزشکان با کوئری قدیمی. // مقصد تمیز صفحهٔ فرود تخصص؛ اگر تخصص slug نداشت، لیست پزشکان با کوئری قدیمی.
const specialtyHref = (name) => { const specialtyHref = (name) => {
@@ -35,9 +36,11 @@ function DoctorPage({ doctor, comments, rateAggregate, addresses, bookableAddres
<p className="text-[#525252] text-nowrap mr-1">{doctorTitle(doctor?.name)}</p> <p className="text-[#525252] text-nowrap mr-1">{doctorTitle(doctor?.name)}</p>
</div> </div>
</CustomLoading> </CustomLoading>
<div className="flex lg:hidden"> {FEATURES.doctorShare && (
<Share data={doctor} /> <div className="flex lg:hidden">
</div> <Share data={doctor} />
</div>
)}
</div> </div>
<div className="flex items-start justify-center gap-6 mt-[30px]"> <div className="flex items-start justify-center gap-6 mt-[30px]">
<DetailDoctor <DetailDoctor
+14
View File
@@ -0,0 +1,14 @@
/**
* سوییچ‌های موقتِ نمایش. `false` یعنی آن بخش فعلاً از UI پنهان است؛ کد و داده‌اش
* سرِ جایش می‌ماند تا با برگرداندن مقدار به `true` دوباره ظاهر شود.
*/
export const FEATURES = {
/**
* دکمهٔ «اشتراک گذاری» صفحهٔ پزشک. ساخت **پوستر** هم داخل همین مودال است، پس
* خاموش‌کردن این سوییچ هر دو را با هم پنهان می‌کند.
*/
doctorShare: false,
/** امتیاز و درصد رضایت کاربران — هم زیر نام پزشک و هم نمودارِ بخش نظرات. */
doctorRatings: false,
};