feat: enhance doctor and clinic components with doctorTitle helper and improve rendering logic

This commit is contained in:
hamed
2026-07-19 16:17:24 +03:30
parent 4c8377f439
commit e8a7bdf2fc
8 changed files with 54 additions and 20 deletions
@@ -7,6 +7,10 @@ import { imageUrl } from "@/helper";
function Images({ data }) {
const images_clinic = data?.images_clinic || [];
// کلینیک بدون عکس، بلوک تصویر ندارد — تصویر پیش‌فرض به‌جای «عکسی ثبت نشده»
// خوانده می‌شود و کاربر آن را عکس واقعی کلینیک فرض می‌کند.
if (images_clinic.length === 0) return null;
return (
<div
className=" flex flex-col md:flex-row items-center mb-[8px] justify-center w-full gap-[12px] md:gap-[18px] lg:gap-[24px] overflow-hidden "
+24 -6
View File
@@ -1,14 +1,32 @@
import ContentDetail from "./ContentDetail";
function Detail({ data }) {
// API برای فیلدهای پرنشده null می‌فرستد؛ درج مستقیم در template رشتهٔ «null»
// را روی صفحه می‌نشاند. هر ردیف فقط وقتی مقدار واقعی دارد رندر می‌شود.
const workingDays = data?.["24_7"]
? "۲۴ ساعته، تمام روزهای هفته"
: data?.field_working_days?.trim();
const phone = (data?.phone_number || data?.phone || "").trim();
const address = data?.location?.trim();
if (!workingDays && !phone && !address) return null;
return (
<ul className="flex flex-col items-start justify-start gap-[16px]">
<ContentDetail
head="روزهای کاری: "
detail={` ${data.field_working_days}`}
/>
<ContentDetail head="تلفن: " detail={`${data.phone_number}`} />
<ContentDetail head="آدرس: " detail={data.location} />
{workingDays && (
<ContentDetail head="روزهای کاری: " detail={workingDays} />
)}
{phone && (
<ContentDetail
head="تلفن: "
detail={
<a href={`tel:${phone}`} dir="ltr" className="hover:text-[#5559CE]">
{phone}
</a>
}
/>
)}
{address && <ContentDetail head="آدرس: " detail={address} />}
</ul>
);
}
+15 -9
View File
@@ -12,13 +12,22 @@ function Contact({ data }) {
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);
// بدون مختصات و بدون نشانی، کوئری نقشه خالی می‌ماند و iframe نقطهٔ بی‌ربط
// نشان می‌دهد؛ در آن حالت نقشه و دکمهٔ مسیریابی اصلاً معنا ندارند.
const hasCoords = Boolean(data?.map?.latitude && data?.map?.longitude);
const mapQuery = hasCoords
? `${data.map.latitude},${data.map.longitude}`
: data?.location?.trim()
? encodeURIComponent(data.location.trim())
: "";
return (
<div
className=" opacity-page border border-[#EFEFEF] rounded-[16px] py-[12px] sm:py-[18px] md:py-[25px] lg:py-[32px] px-[12px] sm:px-[30px] md:px-[47px] lg:px-[64px] "
>
<div className="flex items-end justify-between">
<Detail data={data} />
<ModalOpenLocation
{mapQuery && <ModalOpenLocation
data={data}
open={open}
setOpen={setOpen}
@@ -32,16 +41,13 @@ function Contact({ data }) {
<RoutingC />
مسیریابی
</Button>
</ModalOpenLocation>
</ModalOpenLocation>}
</div>
<div className="w-full relative h-[460px] mt-[24px]">
{mapQuery && <div className="w-full relative h-[460px] mt-[24px]">
<CustomLoading width="full" height={400}>
<iframe
src={`https://maps.google.com/maps?q=${
data?.map?.latitude && data?.map?.longitude
? `${data.map.latitude},${data.map.longitude}`
: encodeURIComponent(data?.location || data?.title || "")
}&z=14&output=embed`}
src={`https://maps.google.com/maps?q=${mapQuery}&z=14&output=embed`}
title="موقعیت کلینیک روی نقشه"
className="w-full h-full rounded-lg"
loading="lazy"
></iframe>
@@ -60,7 +66,7 @@ function Contact({ data }) {
</Button>
</ModalOpenLocation>
</CustomLoading>
</div>
</div>}
</div>
);
}