"use client";
import { useEffect, useState } from "react";
import DoctorAvatar from "@/app/component/DoctorAvatar";
import QrImg from "./QrImg";
import { getStateInfoClient } from "@/lib/getStateInfoClient";
import StarDI from "@/components/icons/StarDI";
import ClipBoard from "@/components/icons/ClipBoard";
import AddressPoster from "@/components/icons/AddressPoster";
import TelefonPoster from "@/components/icons/TelefonPoster";
import Instagram from "@/components/icons/Instagram";
import Telegram from "@/components/icons/Telegram";
import Whatsapp from "@/components/icons/Whatsapp";
const POSTER_BG =
"linear-gradient(160deg, #0B2A4A 0%, #16528C 52%, #2E77C4 100%)";
function SiteLogo({ city, className }) {
if (city?.logo_url) {
return (
);
}
return (
);
}
function SectionTitle({ icon, children }) {
return (
{icon}
{children}
);
}
function Poster({ data, onQrReady }) {
const [city, setCity] = useState(null);
useEffect(() => {
const { matchedCity } = getStateInfoClient();
setCity(matchedCity || null);
}, []);
const specialties = (data?.specialties ?? []).filter((s) => s?.name).slice(0, 4);
const services = (data?.expertise ?? []).filter((s) => s?.name);
const shownServices = services.slice(0, 8);
const moreServices = services.length - shownServices.length;
const address = data?.address?.[0]?.address;
const phones = (data?.address ?? [])
.map((a) => a?.phone)
.filter(Boolean)
.slice(0, 2);
const social = city?.social_media ?? {};
const socialItems = [
social.instagram && ,
social.telegram && ,
social.whatsapp && ,
].filter(Boolean);
const badges = [
Number(data?.experience) > 0 && {
icon: ◆,
label: `${data.experience} سال تجربه`,
},
(data?.point ?? 0) > 0 && {
icon: ,
label: `امتیاز ${data.point}`,
},
(data?.satisfaction ?? 0) > 0 && {
icon: ♥,
label: `${data.satisfaction}% رضایت`,
},
].filter(Boolean);
return (
{/* header — float layout so RTL survives html2canvas */}
{city?.site_name || "نوبت ۷۲۴"}
{city?.domain || "nobat724.com"}
نوبتدهی آنلاین
{city?.slogan && (
{city.slogan}
)}
{/* hero */}
{data?.name}
{specialties.map((s, i) => (
{s.name}
))}
{badges.map((b, i) => (
{b.icon}
{b.label}
))}
{data?.medical_system_code && (
کد نظام پزشکی:{" "}
{data.medical_system_code}
)}
{/* body */}
{shownServices.length > 0 && (
}>خدمات
{shownServices.map((s, i) => (
{s.name}
))}
{moreServices > 0 && (
+ {moreServices} خدمت دیگر
)}
)}
{(address || phones.length > 0) && (
{address && (
)}
{phones.length > 0 && (
}>تلفن
{phones.map((p, i) => (
{p}
))}
)}
)}
{/* footer */}
);
}
export default Poster;