74 lines
2.5 KiB
TypeScript
74 lines
2.5 KiB
TypeScript
import { IconCircleCheck, IconExternalLink } from "@tabler/icons-react";
|
|
|
|
import type { Cinema, ContactChannel } from "@/lib/cinemas";
|
|
import { useI18n } from "@/lib/i18n";
|
|
import { translate } from "@/lib/i18n/messages";
|
|
import { COLORS } from "@/lib/design-tokens";
|
|
|
|
function isExternal(href: string | null): boolean {
|
|
return href !== null && href.startsWith("http");
|
|
}
|
|
|
|
function ContactRow({ channel }: { channel: ContactChannel }) {
|
|
return (
|
|
<div className="flex flex-col gap-2">
|
|
<span className="text-sm text-[#999]">{channel.label}</span>
|
|
<a
|
|
href={channel.href ?? undefined}
|
|
target={isExternal(channel.href) ? "_blank" : undefined}
|
|
rel="noreferrer"
|
|
className="flex items-center justify-between"
|
|
>
|
|
<span>{channel.value}</span>
|
|
<IconExternalLink size={16} />
|
|
</a>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
/** กล่องติดต่อ/จองตั๋ว — แต่ละส่วนซ่อนได้ถ้ายังไม่มีข้อมูล */
|
|
export function ContactPanel({ cinema }: { cinema: Cinema }) {
|
|
const { messages } = useI18n();
|
|
|
|
return (
|
|
<aside
|
|
className="flex flex-col justify-between gap-6 rounded-xl p-6"
|
|
style={{ border: `1px solid ${COLORS.border}` }}
|
|
>
|
|
<div className="flex flex-col gap-4">
|
|
<h2 className="text-2xl font-semibold leading-[1.3]">
|
|
{(cinema.contact_heading?.trim() || messages.detail.contactTitle)}
|
|
</h2>
|
|
|
|
{cinema.contacts.length === 0 ? (
|
|
<p className="text-sm text-[#999]">{messages.detail.contactsFallback}</p>
|
|
) : (
|
|
cinema.contacts.map((channel) => (
|
|
<ContactRow key={channel.label} channel={channel} />
|
|
))
|
|
)}
|
|
|
|
<div className="flex flex-col gap-3">
|
|
<span className="text-sm text-[#999]">
|
|
{messages.detail.paymentMethods}
|
|
</span>
|
|
{cinema.payments.length === 0 ? (
|
|
<span className="text-sm text-[#999]">
|
|
{messages.detail.paymentsFallback}
|
|
</span>
|
|
) : (
|
|
<div className="flex flex-wrap items-center gap-6">
|
|
{cinema.payments.map((payment) => (
|
|
<span key={payment} className="flex items-center gap-1 text-sm">
|
|
<IconCircleCheck size={16} />
|
|
{translate(messages.payments, payment)}
|
|
</span>
|
|
))}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</aside>
|
|
);
|
|
}
|