"use client"; import { useEffect, useState } from "react"; import DoctorAvatar from "@/app/component/DoctorAvatar"; import QrImg from "./QrImg"; import SiteLogo from "./SiteLogo"; import { getStateInfoClient } from "@/lib/getStateInfoClient"; import { posterSpecialtyLine, splitSpecialties } from "@/lib/specialtyDisplay"; import { doctorTitle } from "@/helper"; import StarDI from "@/components/icons/StarDI"; import { FEATURES } from "@/config/features"; const ACCENT = "#16528C"; const ACCENT_LIGHT = "#2E77C4"; const ORANGE = "#F17732"; function PosterLight({ data, onQrReady }) { const [city, setCity] = useState(null); useEffect(() => { const { matchedCity } = getStateInfoClient(); setCity(matchedCity || null); }, []); // قرینهٔ پوستر تیره — همان دلیل: برش عددیِ ثابت با نام‌های بلند از کادر بیرون می‌زد. const { primary, rest } = splitSpecialties(data?.specialties); const subSpecialties = posterSpecialtyLine(rest, 78); const services = (data?.expertise ?? []).filter((s) => s?.name); const shownServices = services.slice(0, 8); const moreServices = services.length - shownServices.length; const rawAddress = data?.address?.[0]?.address; const address = rawAddress && rawAddress.length > 120 ? `${rawAddress.slice(0, 120).trimEnd()}…` : rawAddress; const phones = (data?.address ?? []) .map((a) => a?.phone) .filter(Boolean) .slice(0, 2); const badges = [ Number(data?.experience) > 0 && { label: `${data.experience} سال تجربه` }, FEATURES.posterRatings && (data?.point ?? 0) > 0 && { icon: , label: `امتیاز ${data.point}` }, FEATURES.posterRatings && (data?.satisfaction ?? 0) > 0 && { label: `${data.satisfaction}% رضایت بیماران` }, ].filter(Boolean); return (
{/* top brand band */}
{city?.site_name || "نوبت ۷۲۴"} {city?.domain || "nobat724.com"}
{/* avatar overlapping band */}

{doctorTitle(data?.name)}

{primary && (
{primary.name}
)} {/* زیرتخصص‌ها یک خط متنی — در چاپ نه کلیک هست نه Popover. */} {subSpecialties.text && (

{subSpecialties.text} {subSpecialties.hidden > 0 && ` و ${subSpecialties.hidden} تخصص دیگر`}

)} {badges.length > 0 && (
{badges.map((b, i) => ( {i > 0 && ·} {b.icon} {b.label} ))}
)} {data?.medical_system_code && (

کد نظام پزشکی:{" "} {data.medical_system_code}

)} {/* services */} {shownServices.length > 0 && (

خدمات

{shownServices.map((s, i) => ( {s.name} ))} {moreServices > 0 && ( + {moreServices} خدمت دیگر )}
)} {/* address / phone */} {(address || phones.length > 0) && (
{address && (

آدرس: {address}

)} {phones.length > 0 && (

تلفن: {phones.map((p, i) => ( {p} {i < phones.length - 1 ? " | " : ""} ))}

)}
)}
{/* footer */}
رزرو نوبت آنلاین — اسکن کنید {city?.domain || "nobat724.com"}
نوبت‌دهی ۲۴ ساعته
); } export default PosterLight;