import { CinemaCard } from "@/components/site/CinemaCard"; import type { Cinema, CinemaCategory, VenueType } from "@/lib/cinemas"; import { useI18n } from "@/lib/i18n"; /** กริดการ์ดโรงหนัง — ใช้ทั้งหน้าแรกและส่วน "โรงหนังอิสระอื่นๆ" */ export function CinemaGrid({ cinemas, source = "list", searchQuery, }: { cinemas: Cinema[]; source?: string; searchQuery?: string; }) { return (
{cinemas.map((cinema, index) => ( ))}
); } type CategoryFilterProps = { /** เก็บคีย์หมวดเป็นภาษาไทยเสมอ เพื่อใช้กรองข้อมูลได้ทุกภาษา */ active: CinemaCategory; categories: readonly CinemaCategory[]; onChange: (category: CinemaCategory) => void; /** ชั้นกรองที่ 1 — ประเภทโรงหนัง (แสดงต่อจาก "ทั้งหมด") */ venues?: readonly VenueType[]; activeVenue?: VenueType | null; onVenueChange?: (venue: VenueType | null) => void; }; const chipClass = (isActive: boolean) => `relative rounded-[18px] border px-4 py-2 text-sm after:absolute after:-inset-y-1.5 after:inset-x-0 after:content-[''] ${ isActive ? "border-[#A92626] bg-gradient-to-b from-[#8F0808]/30 to-[#1B1B1B]/0 text-[#D47272]" : "border-[#303030] bg-[#242424] text-[#B3B3B3] transition hover:border-[#A92626]/60" }`; /** * แถบกรองสองชั้นในแถวเดียว * 1) ประเภทโรงหนัง (ท้องถิ่น / อินดี้ / กลุ่มคนฉายหนัง) — แทรกหลัง "ทั้งหมด" * 2) หมวดภาพยนตร์แบบเดิม (อาร์ตเฮาส์ / สารคดี / …) * เลือกได้ทีละชั้น: กดประเภท → ล้างหมวด, กดหมวด → ล้างประเภท (กันการกรองซ้อนที่ผู้ใช้คาดไม่ถึง) */ export function CategoryFilter({ active, categories, onChange, venues = [], activeVenue = null, onVenueChange, }: CategoryFilterProps) { const { messages } = useI18n(); const [allCategory, ...restCategories] = categories; const hasVenues = venues.length > 0 && typeof onVenueChange === "function"; const allActive = active === allCategory && activeVenue === null; return (
{hasVenues ? venues.map((venue) => { const isActive = activeVenue === venue; return ( ); }) : null} {hasVenues ? (
); }