reboot alterflixhub

This commit is contained in:
Bkk1234 committed 2026-11-01 17:24:44 +07:00
commit 1e84023a44
188 files changed
+31629

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
import { Link } from "react-router";
import { SiteShell } from "@/components/site/SiteShell";
import { useI18n } from "@/lib/i18n";
import { COLORS } from "@/lib/design-tokens";
/** หน้า fallback เมื่อ slug ไม่ตรงกับโรงหนังที่มีอยู่ */
export function CinemaNotFound() {
const { messages } = useI18n();
return (
<SiteShell variant="detail">
<main className="relative z-10 mx-auto flex max-w-[1440px] flex-col items-center gap-6 px-5 py-32 text-center md:px-[108px]">
<h1 className="text-3xl font-bold">{messages.notFound.title}</h1>
<p className="text-[#B3B3B3]">{messages.notFound.text}</p>
<Link
to="/"
className="rounded-lg px-6 py-2 font-medium"
style={{ background: COLORS.brand }}
>
{messages.notFound.cta}
</Link>
</main>
</SiteShell>
);
}
+60
View File
@@ -0,0 +1,60 @@
import { IconMap, IconMapPin } from "@tabler/icons-react";
import {
cinemaDescription,
cinemaLocationLabel,
cinemaName,
type Cinema,
} from "@/lib/cinemas";
import { useI18n } from "@/lib/i18n";
import { COLORS } from "@/lib/design-tokens";
/** หัวโรงหนัง: ป้ายประเภท + ชื่อ + ที่ตั้ง + ปุ่มแผนที่ + คำอธิบาย */
export function CinemaSummary({ cinema }: { cinema: Cinema }) {
const { locale, messages } = useI18n();
const locationLabel = cinemaLocationLabel(cinema, locale);
const description = cinemaDescription(cinema, locale);
return (
<div className="flex flex-col gap-6">
<div className="flex flex-col gap-4">
<div className="flex flex-wrap gap-2">
{cinema.tags.map((tag) => (
<span
key={tag}
className="rounded-[18px] border border-[#A92626] px-4 py-2 text-sm text-[#D47272]"
style={{ background: COLORS.pillGradient }}
>
{messages.tags[tag] ?? tag}
</span>
))}
</div>
<h1 className="text-[40px] font-bold leading-[1.3]">
{cinemaName(cinema, locale)}
</h1>
</div>
<div className="flex flex-wrap items-center justify-between gap-4">
<div className="flex items-center gap-2 text-lg">
<IconMapPin size={24} className="shrink-0" />
{locationLabel || messages.card.locationFallback}
</div>
{cinema.map_url ? (
<a
href={cinema.map_url}
target="_blank"
rel="noreferrer"
className="flex w-[200px] items-center justify-center gap-2 rounded-lg border border-white px-4 py-2 text-lg font-medium"
>
{messages.detail.openMap}
<IconMap size={24} />
</a>
) : null}
</div>
{description ? (
<p className="text-xl leading-[1.3]">{description}</p>
) : null}
</div>
);
}
+73
View File
@@ -0,0 +1,73 @@
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>
);
}
@@ -0,0 +1,77 @@
import {
IconBook,
IconBriefcase,
IconCoffee,
IconPlant2,
IconShoppingBag,
IconSofa,
IconTicket,
IconToolsKitchen2,
type Icon as TablerIcon,
} from "@tabler/icons-react";
import { LocationPanel } from "@/components/cinema/LocationPanel";
import { cinemaFacilities, type Cinema } from "@/lib/cinemas";
import { useI18n } from "@/lib/i18n";
import type { FacilityKey } from "@/lib/i18n/messages";
import { COLORS } from "@/lib/design-tokens";
const FACILITY_ICONS: Record<FacilityKey, TablerIcon> = {
seating: IconSofa,
ticket: IconTicket,
restaurant: IconToolsKitchen2,
cafe: IconCoffee,
garden: IconPlant2,
bookstore: IconBook,
colearning: IconBriefcase,
other: IconShoppingBag,
};
/** สิ่งอำนวยความสะดวก (ซ้าย) + ที่ตั้ง (ขวา) ตาม layout ใน Figma */
export function FacilitiesSection({ cinema }: { cinema: Cinema }) {
const { locale, messages } = useI18n();
const facilities = cinemaFacilities(cinema);
return (
<section className="grid gap-10 lg:grid-cols-[minmax(0,749px)_minmax(0,384px)] lg:justify-between">
<div className="flex flex-col gap-8">
<h2 className="text-2xl font-semibold leading-[1.3]">
{messages.detail.facilities}
</h2>
{facilities.length > 0 ? (
<div className="grid grid-cols-2 gap-x-4 gap-y-10 sm:grid-cols-4">
{facilities.map((key) => {
const Icon = FACILITY_ICONS[key];
const base = messages.facilities[key];
const custom = cinema.facility_details?.[key];
const title = custom?.label?.trim() || base.title;
// คำอธิบายแสดงเฉพาะที่กรอกไว้รายโรง (ค่าเริ่มต้นใช้เป็น placeholder ในหลังบ้าน)
const sub =
(locale === "en" ? custom?.sub_en : custom?.sub_th)?.trim() ?? "";
return (
<div key={key} className="flex flex-col items-center gap-3">
<div
className="flex size-[72px] items-center justify-center rounded-full"
style={{ background: COLORS.glowSoft }}
>
<Icon size={40} stroke={1.5} />
</div>
<div className="text-center">
<div className="font-medium">{title}</div>
{sub ? (
<div className="mt-1 text-sm text-[#B3B3B3]">{sub}</div>
) : null}
</div>
</div>
);
})}
</div>
) : (
<p className="text-sm text-[#777]">{messages.detail.noData}</p>
)}
</div>
<LocationPanel cinema={cinema} />
</section>
);
}
+97
View File
@@ -0,0 +1,97 @@
import { IconChevronLeft, IconChevronRight } from "@tabler/icons-react";
import type { ReactNode } from "react";
import { Logo } from "@/components/site/Logo";
import { splitGallery } from "@/lib/gallery";
import { useI18n } from "@/lib/i18n";
type GalleryProps = {
photos: string[];
cinemaName: string;
};
type GallerySlotProps = {
photo: string | null;
alt: string;
/** เนื้อหาที่แสดงเมื่อยังไม่มีรูป — ใช้โลโก้ AlterFlixHub แทนข้อความ */
placeholder: ReactNode;
className: string;
};
function GallerySlot({ photo, alt, placeholder, className }: GallerySlotProps) {
if (!photo) {
return (
<div
className={`flex items-center justify-center bg-[#242424] text-sm text-[#999] ${className}`}
>
{placeholder}
</div>
);
}
return (
<img
src={photo}
alt={alt}
className={`bg-[#242424] object-cover ${className}`}
/>
);
}
/** แกลเลอรีภาพโรงหนัง — ป้าย "+N" คำนวณจากจำนวนรูปจริงในข้อมูล */
export function Gallery({ photos, cinemaName }: GalleryProps) {
const { messages } = useI18n();
const { main, thumbs, remaining } = splitGallery(photos);
const [firstThumb = null, secondThumb = null] = thumbs;
return (
<section className="grid gap-6 lg:grid-cols-[minmax(0,807px)_minmax(0,387px)]">
<div className="relative overflow-hidden rounded-xl">
<GallerySlot
photo={main}
alt={`${messages.gallery.main} — ${cinemaName}`}
placeholder={<Logo size="md" />}
className="aspect-[269/202] w-full lg:aspect-auto lg:h-[606px]"
/>
<button
type="button"
aria-label={messages.gallery.previous}
className="absolute left-6 top-1/2 flex size-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/50"
>
<IconChevronLeft size={24} />
</button>
<button
type="button"
aria-label={messages.gallery.next}
className="absolute right-6 top-1/2 flex size-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/50"
>
<IconChevronRight size={24} />
</button>
</div>
<div className="grid grid-cols-2 gap-6 lg:grid-cols-1 lg:grid-rows-2">
<div className="overflow-hidden rounded-xl">
<GallerySlot
photo={firstThumb}
alt={`${messages.gallery.second} — ${cinemaName}`}
placeholder={<Logo size="sm" />}
className="aspect-[387/290] w-full"
/>
</div>
<div className="relative overflow-hidden rounded-xl">
<GallerySlot
photo={secondThumb}
alt={`${messages.gallery.third} — ${cinemaName}`}
placeholder={<Logo size="sm" />}
className="aspect-[387/290] w-full"
/>
{remaining > 0 ? (
<div className="absolute bottom-2.5 right-2.5 flex size-[60px] items-center justify-center rounded-lg bg-black/80 text-lg font-medium">
{messages.gallery.more(remaining)}
</div>
) : null}
</div>
</div>
</section>
);
}
+93
View File
@@ -0,0 +1,93 @@
import { IconMap } from "@tabler/icons-react";
import { COLORS } from "@/lib/design-tokens";
import { cinemaAddressLines, cinemaName, type Cinema } from "@/lib/cinemas";
import { useI18n } from "@/lib/i18n";
import { mapEmbedUrl, mapOpenUrl } from "@/lib/map-embed";
/**
* การ์ดที่ตั้ง + แผนที่
* แผนที่ดึงจากลิงก์ Google Maps ของโรง ถ้าไม่มีจึงใช้พิกัดที่กรอกในหลังบ้าน
* ถ้าไม่มีทั้งสองอย่างแสดง "ไม่มีข้อมูล"
*/
export function LocationPanel({ cinema }: { cinema: Cinema }) {
const { locale, messages } = useI18n();
const addressLines = cinemaAddressLines(cinema, locale);
const embedUrl = mapEmbedUrl(cinema, locale);
const openUrl = mapOpenUrl(cinema);
return (
<aside
className="flex flex-col gap-6 self-start rounded-xl p-6"
style={{ border: `1px solid ${COLORS.border}` }}
>
<div className="flex flex-col gap-4">
<div className="flex items-center justify-between gap-3">
<h2 className="text-2xl font-semibold leading-[1.3]">
{messages.detail.location}
</h2>
{openUrl ? (
<a
href={openUrl}
target="_blank"
rel="noreferrer"
className="inline-flex items-center gap-1 text-sm text-[#D47272] transition hover:text-white"
>
<IconMap size={16} />
{messages.detail.openMap}
</a>
) : null}
</div>
{embedUrl ? (
<div
className="relative h-[183px] overflow-hidden rounded-xl"
style={{
border: `1px solid ${COLORS.border}`,
background: COLORS.surfaceMuted,
}}
>
{/* ลายตารางใต้แผนที่ — กันช่องว่างขาวตอน iframe ยังโหลดไม่เสร็จ */}
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0"
style={{
backgroundImage:
"linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px)",
backgroundSize: "24px 24px",
}}
/>
<iframe
title={`${messages.detail.location} — ${cinemaName(cinema, locale)}`}
src={embedUrl}
loading="lazy"
referrerPolicy="no-referrer-when-downgrade"
allowFullScreen
className="relative size-full border-0"
/>
</div>
) : (
<div
className="flex h-[183px] items-center justify-center rounded-xl text-sm text-[#777]"
style={{
border: `1px dashed ${COLORS.border}`,
background: COLORS.surfaceMuted,
}}
>
{messages.detail.noData}
</div>
)}
</div>
<p className="text-sm leading-[1.3] text-[#999]">
{addressLines.length > 0
? addressLines.map((line) => (
<span key={line} className="block">
{line}
</span>
))
: messages.detail.addressFallback}
</p>
</aside>
);
}
+49
View File
@@ -0,0 +1,49 @@
import {
IconBus,
IconCar,
IconTrain,
type Icon as TablerIcon,
} from "@tabler/icons-react";
import { transportValue, type TransportMode } from "@/lib/cinemas";
import { useI18n } from "@/lib/i18n";
import { COLORS } from "@/lib/design-tokens";
const TRANSPORT_ICONS: Record<TransportMode["icon_name"], TablerIcon> = {
private_car: IconCar,
metro: IconTrain,
bus: IconBus,
};
/** วิธีเดินทางมาถึงโรงหนัง — ซ่อนทั้งบล็อกถ้ายังไม่มีข้อมูล */
export function TransportList({ transport }: { transport: TransportMode[] }) {
const { locale, messages } = useI18n();
// แถวที่ยังไม่ได้กรอกรายละเอียด (เพิ่มจากหลังบ้านแล้วเว้นว่าง) ไม่ต้องแสดง
const routes = transport.filter((route) => route.value.trim() !== "");
if (routes.length === 0) return null;
return (
<div className="flex flex-col">
{routes.map((route, index) => {
const Icon = TRANSPORT_ICONS[route.icon_name];
const isLast = index === routes.length - 1;
return (
<div
key={`${route.icon_name}-${index}`}
className="flex flex-col justify-between gap-1 py-2.5 sm:min-h-10 sm:flex-row sm:gap-4"
style={{
borderBottom: isLast ? undefined : `1px solid ${COLORS.border}`,
}}
>
<div className="flex items-center gap-2 font-medium">
<Icon size={20} />
{messages.transport[route.icon_name]}
</div>
<div className="sm:text-right">{transportValue(route, locale)}</div>
</div>
);
})}
</div>
);
}