import type { Cinema } from "@/lib/cinemas"; import { DEFAULT_LOCALE, MESSAGES, type FacilityKey } from "@/lib/i18n/messages"; /** * แก้ข้อความสิ่งอำนวยความสะดวก "ของโรงนี้" (ผูกกับโรง ไม่ใช่ส่วนกลาง) * * - ชื่อหัวข้อ: ช่องเดียว (ใช้ทั้ง TH/EN) — ว่าง = ใช้ค่าเริ่มต้นจาก messages.ts * - คำอธิบาย TH/EN: แสดงเฉพาะโรงที่ต้องการ (hasDescriptions) เช่น เฮ้าส์ สามย่าน * ที่มีข้อมูลครบแล้ว โรงอื่นไม่ต้องกรอก */ export type FacilityDetail = { label?: string; sub_th?: string; sub_en?: string; }; const ADMIN_MESSAGES = MESSAGES[DEFAULT_LOCALE]; type Props = { facilities: FacilityKey[]; details: NonNullable; hasDescriptions: boolean; onChange: (next: NonNullable) => void; inputClass: string; labelClass: string; }; export function CinemaFacilitiesEditor({ facilities, details, hasDescriptions, onChange, inputClass, labelClass, }: Props) { if (facilities.length === 0) { return ( เลือกหัวข้อด้านบนก่อน แล้วค่อยใส่ชื่อที่ต้องการ ); } function update(key: FacilityKey, patch: FacilityDetail) { const current = details[key] ?? {}; const next: FacilityDetail = { ...current, ...patch }; const cleaned: FacilityDetail = {}; if (next.label?.trim()) cleaned.label = next.label; if (next.sub_th?.trim()) cleaned.sub_th = next.sub_th; if (next.sub_en?.trim()) cleaned.sub_en = next.sub_en; onChange({ ...details, [key]: cleaned }); } return (
{facilities.map((key) => { const fallback = ADMIN_MESSAGES.facilities[key]; const detail = details[key] ?? {}; return (
{hasDescriptions ? ( <> ) : null}
); })}
); }