import { IconPlus, IconTrash } from "@tabler/icons-react"; import type { ContactChannel } from "@/lib/cinemas"; import { resolveContact } from "@/lib/contact-link"; /** * แก้ช่องทางติดต่อของการ์ด "สอบถามข้อมูลและจองตั๋ว" ต่อโรง * แต่ละแถว = label / ค่าที่แสดง / ลิงก์ (ถ้าไม่มีลิงก์ หน้าเว็บแสดงเป็นข้อความธรรมดา) */ const SUGGESTED_LABELS = [ "Website", "Facebook", "Instagram", "Line", "Call", "อีเมล", "จองตั๋ว", ]; const smallButtonClass = "flex min-h-9 items-center gap-1 rounded-lg border border-[#303030] px-2 text-xs text-[#999] transition hover:border-[#A92626] hover:text-[#D47272]"; type Props = { contacts: ContactChannel[]; onChange: (next: ContactChannel[]) => void; inputClass: string; labelClass: string; }; export function ContactsEditor({ contacts, onChange, inputClass, labelClass, }: Props) { function updateAt(index: number, patch: Partial) { onChange( contacts.map((item, i) => (i === index ? { ...item, ...patch } : item)), ); } return (
ช่องทางติดต่อ / จองตั๋ว {contacts.length === 0 ? ( ยังไม่มีช่องทางติดต่อ — หน้าเว็บจะขึ้น “ยังไม่ระบุช่องทางติดต่อ” ) : null} {contacts.map((contact, index) => (
{(() => { const resolved = resolveContact(contact); if (!resolved.href) { return contact.value.trim() === "" ? "ใส่ข้อความหรือเบอร์ก่อน — ระบบจะสร้างลิงก์ให้" : "⚠ ค่านี้ยังใช้เป็นลิงก์ไม่ได้ (ต้องเป็นเบอร์ / อีเมล / โดเมน / URL)"; } const label = resolved.kind === "tel" ? "กดโทรได้" : resolved.kind === "mailto" ? "เปิดอีเมล" : "เปิดเว็บ (แท็บใหม่)"; return `✓ ${label} → ${resolved.href}`; })()}
))} {SUGGESTED_LABELS.map((label) => (
); }