"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 StarDI from "@/components/icons/StarDI";
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 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 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} سال تجربه` },
(data?.point ?? 0) > 0 && { icon:
کد نظام پزشکی:{" "} {data.medical_system_code}
)} {/* services */} {shownServices.length > 0 && (خدمات
آدرس: {address}
)} {phones.length > 0 && (تلفن: {phones.map((p, i) => ( {p} {i < phones.length - 1 ? " | " : ""} ))}
)}