feat(app): TH/EN language switch, tel/external contact links, auto-persist image uploads, lighter images
No files matched your search
@@ -0,0 +1,213 @@
|
|||||||
|
import {
|
||||||
|
createContext,
|
||||||
|
useCallback,
|
||||||
|
useContext,
|
||||||
|
useEffect,
|
||||||
|
useMemo,
|
||||||
|
useState,
|
||||||
|
} from "react";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ระบบสองภาษา ไทย/อังกฤษ สำหรับหน้าใหม่ (/, /cinema/:slug)
|
||||||
|
* ------------------------------------------------------------
|
||||||
|
* ★ แยกไฟล์จาก lib/i18n.tsx เดิม (ซึ่งหน้า /single ใช้อยู่) — ไม่ชนกัน
|
||||||
|
* ★ เก็บภาษาที่เลือกใน localStorage ("alterflix_lang") → จำข้ามหน้า
|
||||||
|
* ★ ตั้ง <html lang> ให้ถูกต้อง (a11y + SEO)
|
||||||
|
* ★ ข้อมูลจาก JSON (ชื่อโรง/คำอธิบาย) เป็นเนื้อหา ไม่แปล — แปลเฉพาะ UI
|
||||||
|
* ★ หมวดหนังเก็บเป็นข้อความไทยใน JSON → แปลงป้ายด้วย categoryLabel()
|
||||||
|
*/
|
||||||
|
|
||||||
|
export type Lang = "th" | "en";
|
||||||
|
|
||||||
|
type Dict = Record<string, { th: string; en: string }>;
|
||||||
|
|
||||||
|
const DICT: Dict = {
|
||||||
|
"nav.manage": { th: "จัดการข้อมูล", en: "Manage" },
|
||||||
|
"nav.lang": { th: "ภาษา", en: "Language" },
|
||||||
|
|
||||||
|
"home.heroA": { th: "ค้นพบ", en: "Discover" },
|
||||||
|
"home.heroB": { th: "โรงหนังอิสระ", en: "indie cinemas" },
|
||||||
|
"home.heroC": { th: "ใกล้คุณ", en: "near you" },
|
||||||
|
"home.lead": {
|
||||||
|
th: "ค้นหาโรงภาพยนตร์อิสระ ทางเลือกในการดูหนัง",
|
||||||
|
en: "Find independent cinemas — a different way to watch films",
|
||||||
|
},
|
||||||
|
"home.searchPlaceholder": {
|
||||||
|
th: "ค้นหาชื่อโรงหนังหรือสถานที่ / จังหวัด / ประเภทหนัง",
|
||||||
|
en: "Search cinema, area, province or genre",
|
||||||
|
},
|
||||||
|
"home.nearMe": { th: "ใกล้ฉัน", en: "Near me" },
|
||||||
|
"home.searchButton": { th: "ค้นหา", en: "Search" },
|
||||||
|
"home.listTitle": { th: "รายชื่อโรงหนังอิสระ", en: "Independent cinemas" },
|
||||||
|
"home.count": { th: "{n} โรง", en: "{n} cinemas" },
|
||||||
|
"home.empty": {
|
||||||
|
th: "ยังไม่มีโรงหนังในหมวดนี้",
|
||||||
|
en: "No cinemas in this genre yet",
|
||||||
|
},
|
||||||
|
"home.more": { th: "แสดงเพิ่ม", en: "Show more" },
|
||||||
|
"home.cardDetail": { th: "ดูรายละเอียด", en: "Details" },
|
||||||
|
|
||||||
|
"detail.back": { th: "ย้อนกลับ", en: "Back" },
|
||||||
|
"detail.map": { th: "เปิด Google map", en: "Open Google map" },
|
||||||
|
"detail.contactTitle": {
|
||||||
|
th: "สอบถามข้อมูลและจองตั๋ว",
|
||||||
|
en: "Contact & tickets",
|
||||||
|
},
|
||||||
|
"detail.contactEmpty": {
|
||||||
|
th: "ยังไม่มีช่องทางติดต่อของโรงนี้",
|
||||||
|
en: "No contact channels yet",
|
||||||
|
},
|
||||||
|
"detail.payment": { th: "ชำระเงิน", en: "Payment" },
|
||||||
|
"detail.schedule": { th: "ดูรอบฉาย", en: "Showtimes" },
|
||||||
|
"detail.facilities": { th: "สิ่งอำนวยความสะดวก", en: "Facilities" },
|
||||||
|
"detail.facilitiesEmpty": {
|
||||||
|
th: "ยังไม่มีข้อมูลสิ่งอำนวยความสะดวก",
|
||||||
|
en: "No facility information yet",
|
||||||
|
},
|
||||||
|
"detail.location": { th: "ที่ตั้ง", en: "Location" },
|
||||||
|
"detail.others": { th: "โรงหนังอิสระอื่นๆ", en: "Other indie cinemas" },
|
||||||
|
"detail.hidden": { th: "ซ่อนจากหน้าแรก", en: "Hidden from home" },
|
||||||
|
"detail.noDescription": {
|
||||||
|
th: "ยังไม่มีข้อมูลรายละเอียดของโรงหนังนี้ — อยู่ระหว่างรวบรวมข้อมูล",
|
||||||
|
en: "No description yet for this cinema",
|
||||||
|
},
|
||||||
|
"detail.notFoundTitle": { th: "ไม่พบโรงหนังที่ค้นหา", en: "Cinema not found" },
|
||||||
|
"detail.notFoundLead": {
|
||||||
|
th: "ลิงก์อาจเปลี่ยนไปแล้ว หรือโรงนี้ยังไม่มีในระบบ",
|
||||||
|
en: "The link may have changed, or this cinema is not in the system",
|
||||||
|
},
|
||||||
|
"detail.notFoundBack": {
|
||||||
|
th: "กลับไปหน้ารายชื่อโรงหนัง",
|
||||||
|
en: "Back to the cinema list",
|
||||||
|
},
|
||||||
|
|
||||||
|
"a11y.prevPhoto": { th: "รูปก่อนหน้า", en: "Previous photo" },
|
||||||
|
"a11y.nextPhoto": { th: "รูปถัดไป", en: "Next photo" },
|
||||||
|
"a11y.switchLang": { th: "เปลี่ยนภาษา", en: "Switch language" },
|
||||||
|
};
|
||||||
|
|
||||||
|
/** แปลงชื่อหมวด (ข้อความไทยใน JSON) → ป้ายตามภาษา */
|
||||||
|
const CATEGORY_EN: Record<string, string> = {
|
||||||
|
ทั้งหมด: "All",
|
||||||
|
ยอดนิยม: "Popular",
|
||||||
|
อาร์ตเฮาส์: "Art house",
|
||||||
|
สารคดี: "Documentary",
|
||||||
|
หนังสั้น: "Short films",
|
||||||
|
หนังคลาสสิก: "Classics",
|
||||||
|
หนังนานาชาติ: "International",
|
||||||
|
หนังนอกกระแส: "Offbeat",
|
||||||
|
หนังในกระแส: "Mainstream",
|
||||||
|
หนังฝรั่งเศส: "French cinema",
|
||||||
|
};
|
||||||
|
|
||||||
|
/** ป้ายชื่อช่องทางติดต่อ (JSON เก็บเป็นอังกฤษ) */
|
||||||
|
const CONTACT_LABEL_TH: Record<string, string> = {
|
||||||
|
Website: "เว็บไซต์",
|
||||||
|
"Mobile Application": "แอปพลิเคชัน",
|
||||||
|
Facebook: "เฟซบุ๊ก",
|
||||||
|
Instagram: "อินสตาแกรม",
|
||||||
|
Line: "ไลน์",
|
||||||
|
Email: "อีเมล",
|
||||||
|
Call: "โทร",
|
||||||
|
};
|
||||||
|
|
||||||
|
type LangContextValue = {
|
||||||
|
lang: Lang;
|
||||||
|
setLang: (lang: Lang) => void;
|
||||||
|
t: (key: string, vars?: Record<string, string | number>) => string;
|
||||||
|
categoryLabel: (value: string) => string;
|
||||||
|
contactLabel: (value: string) => string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const LangContext = createContext<LangContextValue | null>(null);
|
||||||
|
|
||||||
|
const STORAGE_KEY = "alterflix_lang";
|
||||||
|
|
||||||
|
export function LangProvider({ children }: { children: React.ReactNode }) {
|
||||||
|
const [lang, setLangState] = useState<Lang>("th");
|
||||||
|
|
||||||
|
/* อ่านค่าที่เคยเลือกหลัง mount (กัน SSR/CSR ไม่ตรงกัน) */
|
||||||
|
useEffect(() => {
|
||||||
|
try {
|
||||||
|
const stored = window.localStorage.getItem(STORAGE_KEY);
|
||||||
|
if (stored === "th" || stored === "en") setLangState(stored);
|
||||||
|
} catch {
|
||||||
|
/* storage ถูกบล็อก — ใช้ค่าเริ่มต้น */
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
document.documentElement.lang = lang;
|
||||||
|
try {
|
||||||
|
window.localStorage.setItem(STORAGE_KEY, lang);
|
||||||
|
} catch {
|
||||||
|
/* ignore */
|
||||||
|
}
|
||||||
|
}, [lang]);
|
||||||
|
|
||||||
|
const setLang = useCallback((next: Lang) => setLangState(next), []);
|
||||||
|
|
||||||
|
const t = useCallback(
|
||||||
|
(key: string, vars?: Record<string, string | number>) => {
|
||||||
|
const entry = DICT[key];
|
||||||
|
let text = entry ? entry[lang] : key;
|
||||||
|
if (vars) {
|
||||||
|
for (const [name, value] of Object.entries(vars)) {
|
||||||
|
text = text.replace(`{${name}}`, String(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
},
|
||||||
|
[lang],
|
||||||
|
);
|
||||||
|
|
||||||
|
const categoryLabel = useCallback(
|
||||||
|
(value: string) => (lang === "en" ? (CATEGORY_EN[value] ?? value) : value),
|
||||||
|
[lang],
|
||||||
|
);
|
||||||
|
|
||||||
|
const contactLabel = useCallback(
|
||||||
|
(value: string) => (lang === "th" ? (CONTACT_LABEL_TH[value] ?? value) : value),
|
||||||
|
[lang],
|
||||||
|
);
|
||||||
|
|
||||||
|
const value = useMemo<LangContextValue>(
|
||||||
|
() => ({ lang, setLang, t, categoryLabel, contactLabel }),
|
||||||
|
[lang, setLang, t, categoryLabel, contactLabel],
|
||||||
|
);
|
||||||
|
|
||||||
|
return <LangContext.Provider value={value}>{children}</LangContext.Provider>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useLang(): LangContextValue {
|
||||||
|
const context = useContext(LangContext);
|
||||||
|
if (!context) throw new Error("useLang ต้องใช้ภายใน <LangProvider>");
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** ปุ่มสลับภาษา ไทย/อังกฤษ */
|
||||||
|
export function LangSwitch({ className = "" }: { className?: string }) {
|
||||||
|
const { lang, setLang, t } = useLang();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => setLang(lang === "th" ? "en" : "th")}
|
||||||
|
aria-label={t("a11y.switchLang")}
|
||||||
|
title={t("a11y.switchLang")}
|
||||||
|
className={`flex items-center gap-1.5 rounded-lg border border-[#303030] px-2.5 py-1.5 text-sm text-[#B3B3B3] transition hover:border-[#A92626] hover:text-white ${className}`}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="block h-4 w-[21px] shrink-0 rounded-[1px]"
|
||||||
|
aria-hidden="true"
|
||||||
|
style={{
|
||||||
|
background:
|
||||||
|
lang === "th"
|
||||||
|
? "linear-gradient(#A51931 0 17%, #F4F5F8 17% 34%, #2D2A4A 34% 66%, #F4F5F8 66% 83%, #A51931 83%)"
|
||||||
|
: "linear-gradient(#012169 0 52%, #ffffff 52% 66%, #C8102E 66%)",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{lang === "th" ? "TH" : "EN"}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* แปลงค่าช่องทางติดต่อ → ลิงก์ที่กดใช้ได้
|
||||||
|
* ------------------------------------------------------------
|
||||||
|
* ★ เบอร์โทร → tel: (กดโทรจากมือถือได้)
|
||||||
|
* ★ เว็บไซต์/โดเมน → https://… เปิดแท็บใหม่
|
||||||
|
* ★ ค่าที่ไม่ใช่ทั้งสองอย่าง (เช่น ชื่อเพจ) → คืน null (แสดงเป็นข้อความ)
|
||||||
|
*/
|
||||||
|
export type ContactLink = { href: string; external: boolean } | null;
|
||||||
|
|
||||||
|
const PHONE_LIKE = /^[+()\d][\d\s()+.-]{5,}$/;
|
||||||
|
const DOMAIN_LIKE = /^[\w-]+(\.[\w-]+)+(\/\S*)?$/;
|
||||||
|
const HAS_SCHEME = /^[a-z][a-z0-9+.-]*:\/\//i;
|
||||||
|
|
||||||
|
/** เบอร์โทร → tel: (ตัดช่องว่างและขีดออก ให้ถูกฟอร์แมต) */
|
||||||
|
export function telHref(value: string): string | null {
|
||||||
|
const trimmed = value.trim();
|
||||||
|
if (!PHONE_LIKE.test(trimmed)) return null;
|
||||||
|
const digits = trimmed.replace(/[^\d+]/g, "");
|
||||||
|
if (digits.replace(/\D/g, "").length < 6) return null;
|
||||||
|
return `tel:${digits}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** เว็บไซต์ → URL เต็ม */
|
||||||
|
export function websiteHref(value: string): string | null {
|
||||||
|
const trimmed = value.trim();
|
||||||
|
if (!trimmed || /\s/.test(trimmed)) return null;
|
||||||
|
if (HAS_SCHEME.test(trimmed)) return trimmed;
|
||||||
|
if (DOMAIN_LIKE.test(trimmed)) return `https://${trimmed}`;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** ใช้กับช่องทางติดต่อในหน้าละเอียด */
|
||||||
|
export function contactHref(label: string, value: string): ContactLink {
|
||||||
|
const phone = telHref(value);
|
||||||
|
if (phone) return { href: phone, external: false };
|
||||||
|
|
||||||
|
const site = websiteHref(value);
|
||||||
|
if (site) return { href: site, external: true };
|
||||||
|
|
||||||
|
// ป้าย "Website" แต่ค่าอาจเป็นชื่อ ไม่มีโดเมน → ไม่ทำลิงก์ปลอม
|
||||||
|
void label;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ import type { LinksFunction } from "react-router";
|
|||||||
import { Layout as AppLayout } from "@/components/layout/Layout";
|
import { Layout as AppLayout } from "@/components/layout/Layout";
|
||||||
import { AppToolkitProvider } from "@/components/ui/toolkit-provider";
|
import { AppToolkitProvider } from "@/components/ui/toolkit-provider";
|
||||||
import { useNavigationState } from "@/hooks/use-navigation-state";
|
import { useNavigationState } from "@/hooks/use-navigation-state";
|
||||||
|
import { LangProvider } from "@/lib/lang";
|
||||||
import { APP_NAME, APP_TITLE } from "@/lib/app-config";
|
import { APP_NAME, APP_TITLE } from "@/lib/app-config";
|
||||||
import { TAB_ID } from "@/lib/tab-id";
|
import { TAB_ID } from "@/lib/tab-id";
|
||||||
|
|
||||||
@@ -128,7 +129,9 @@ export default function Root() {
|
|||||||
<AppProviders queryClient={queryClient}>
|
<AppProviders queryClient={queryClient}>
|
||||||
<DbSyncSetup />
|
<DbSyncSetup />
|
||||||
<AppLayout>
|
<AppLayout>
|
||||||
<Outlet />
|
<LangProvider>
|
||||||
|
<Outlet />
|
||||||
|
</LangProvider>
|
||||||
</AppLayout>
|
</AppLayout>
|
||||||
</AppProviders>
|
</AppProviders>
|
||||||
</AppToolkitProvider>
|
</AppToolkitProvider>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { Link, useLoaderData } from "react-router";
|
import { Link, useLoaderData } from "react-router";
|
||||||
|
|
||||||
|
import { LangSwitch, useLang } from "@/lib/lang";
|
||||||
import { readTheatersFile } from "@/lib/theaters-store.server";
|
import { readTheatersFile } from "@/lib/theaters-store.server";
|
||||||
import type { Theater } from "@/lib/theaters";
|
import type { Theater } from "@/lib/theaters";
|
||||||
|
|
||||||
@@ -85,6 +86,7 @@ export default function HomeRoute() {
|
|||||||
theaters: Theater[];
|
theaters: Theater[];
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
};
|
};
|
||||||
|
const { t, categoryLabel, lang } = useLang();
|
||||||
const [active, setActive] = useState(CATEGORIES[0]);
|
const [active, setActive] = useState(CATEGORIES[0]);
|
||||||
|
|
||||||
// โรงที่ถูกซ่อนในหลังบ้าน (hidden=true) ไม่ขึ้นหน้าแรก
|
// โรงที่ถูกซ่อนในหลังบ้าน (hidden=true) ไม่ขึ้นหน้าแรก
|
||||||
@@ -108,25 +110,15 @@ export default function HomeRoute() {
|
|||||||
|
|
||||||
<header className="relative z-10 mx-auto flex h-[68px] max-w-[1440px] items-center justify-between px-5 md:px-[108px]">
|
<header className="relative z-10 mx-auto flex h-[68px] max-w-[1440px] items-center justify-between px-5 md:px-[108px]">
|
||||||
<Logo />
|
<Logo />
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex items-center gap-2 sm:gap-3">
|
||||||
<Link
|
<Link
|
||||||
to="/admin"
|
to="/admin"
|
||||||
className="flex items-center gap-2 rounded-lg border border-[#303030] px-3 py-1.5 text-sm text-[#B3B3B3] transition hover:border-[#A92626] hover:text-white"
|
className="flex items-center gap-2 rounded-lg border border-[#303030] px-3 py-1.5 text-sm text-[#B3B3B3] transition hover:border-[#A92626] hover:text-white"
|
||||||
>
|
>
|
||||||
<IconSettings size={16} />
|
<IconSettings size={16} />
|
||||||
จัดการข้อมูล
|
<span className="hidden sm:inline">{t("nav.manage")}</span>
|
||||||
</Link>
|
</Link>
|
||||||
<button className="flex items-center gap-2 text-lg font-medium">
|
<LangSwitch />
|
||||||
<span
|
|
||||||
className="block h-4 w-[21px] shrink-0 rounded-[1px]"
|
|
||||||
style={{
|
|
||||||
background:
|
|
||||||
"linear-gradient(#A51931 0 17%, #F4F5F8 17% 34%, #2D2A4A 34% 66%, #F4F5F8 66% 83%, #A51931 83%)",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
TH
|
|
||||||
<IconChevronDown size={16} />
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
@@ -134,26 +126,28 @@ export default function HomeRoute() {
|
|||||||
<section className="mx-auto flex max-w-[1016px] flex-col items-center gap-10 pt-24 md:pt-[167px]">
|
<section className="mx-auto flex max-w-[1016px] flex-col items-center gap-10 pt-24 md:pt-[167px]">
|
||||||
<div className="flex max-w-[745px] flex-col items-center gap-4 text-center">
|
<div className="flex max-w-[745px] flex-col items-center gap-4 text-center">
|
||||||
<h1 className="text-4xl font-bold leading-[1.3] md:text-[56px]">
|
<h1 className="text-4xl font-bold leading-[1.3] md:text-[56px]">
|
||||||
ค้นพบ<span className="text-[#A92626]">โรงหนังอิสระ</span>ใกล้คุณ
|
{t("home.heroA")}
|
||||||
|
{lang === "en" ? " " : ""}
|
||||||
|
<span className="text-[#A92626]">{t("home.heroB")}</span>
|
||||||
|
{lang === "en" ? " " : ""}
|
||||||
|
{t("home.heroC")}
|
||||||
</h1>
|
</h1>
|
||||||
<p className="text-base md:text-xl">
|
<p className="text-base md:text-xl">{t("home.lead")}</p>
|
||||||
ค้นหาโรงภาพยนตร์อิสระ ทางเลือกในการดูหนัง
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full rounded-2xl border border-[#303030] bg-[#1B1B1B]/80 px-4 py-6 backdrop-blur-[32px] md:px-10">
|
<div className="w-full rounded-2xl border border-[#303030] bg-[#1B1B1B]/80 px-4 py-6 backdrop-blur-[32px] md:px-10">
|
||||||
<div className="flex h-14 items-center gap-3 rounded-lg border border-[#1B1B1B] bg-[#1F1F1F] px-5">
|
<div className="flex h-14 items-center gap-3 rounded-lg border border-[#1B1B1B] bg-[#1F1F1F] px-5">
|
||||||
<IconSearch size={16} className="shrink-0 text-[#999]" />
|
<IconSearch size={16} className="shrink-0 text-[#999]" />
|
||||||
<input
|
<input
|
||||||
placeholder="ค้นหาชื่อโรงหนังหรือสถานที่ / จังหวัด / ประเภทหนัง"
|
placeholder={t("home.searchPlaceholder")}
|
||||||
className="min-w-0 flex-1 bg-transparent text-sm text-white outline-none placeholder:text-[#454545]"
|
className="min-w-0 flex-1 bg-transparent text-sm text-white outline-none placeholder:text-[#7a7a7a]"
|
||||||
/>
|
/>
|
||||||
<div className="hidden items-center gap-2 border-l border-[#999] px-4 text-sm text-[#999] sm:flex">
|
<div className="hidden items-center gap-2 border-l border-[#999] px-4 text-sm text-[#999] sm:flex">
|
||||||
<IconMapPin size={16} />
|
<IconMapPin size={16} />
|
||||||
ใกล้ฉัน
|
{t("home.nearMe")}
|
||||||
</div>
|
</div>
|
||||||
<button className="h-8 rounded-lg border border-[#8F0808] bg-[#8F0808] px-6 text-sm font-medium transition hover:bg-[#a30a0a]">
|
<button className="h-8 rounded-lg border border-[#8F0808] bg-[#8F0808] px-6 text-sm font-medium transition hover:bg-[#a30a0a]">
|
||||||
ค้นหา
|
{t("home.searchButton")}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -161,9 +155,9 @@ export default function HomeRoute() {
|
|||||||
|
|
||||||
<section className="mt-16 flex flex-col gap-6 md:mt-[65px]">
|
<section className="mt-16 flex flex-col gap-6 md:mt-[65px]">
|
||||||
<div className="flex h-[72px] items-center border-b border-[#1F1F1F] py-2">
|
<div className="flex h-[72px] items-center border-b border-[#1F1F1F] py-2">
|
||||||
<h2 className="text-[28px] font-semibold">รายชื่อโรงหนังอิสระ</h2>
|
<h2 className="text-[28px] font-semibold">{t("home.listTitle")}</h2>
|
||||||
<span className="ml-3 text-sm text-[#B3B3B3]">
|
<span className="ml-3 text-sm text-[#B3B3B3]">
|
||||||
{visible.length} โรง
|
{t("home.count", { n: visible.length })}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -178,45 +172,45 @@ export default function HomeRoute() {
|
|||||||
: "rounded-[18px] border border-[#303030] bg-[#242424] px-4 py-2 text-sm text-[#B3B3B3] transition hover:border-[#A92626]/60"
|
: "rounded-[18px] border border-[#303030] bg-[#242424] px-4 py-2 text-sm text-[#B3B3B3] transition hover:border-[#A92626]/60"
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{c}
|
{categoryLabel(c)}
|
||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mt-2 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
<div className="mt-2 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
||||||
{theaters.map((t, i) => (
|
{theaters.map((theater, i) => (
|
||||||
<article
|
<article
|
||||||
key={t.slug}
|
key={theater.slug}
|
||||||
className={`relative flex aspect-[3/4] flex-col justify-end overflow-hidden rounded-[20px] bg-gradient-to-br p-2 lg:aspect-auto lg:h-[308px] ${CARD_GRADIENTS[i % CARD_GRADIENTS.length]}`}
|
className={`relative flex aspect-[3/4] flex-col justify-end overflow-hidden rounded-[20px] bg-gradient-to-br p-2 lg:aspect-auto lg:h-[308px] ${CARD_GRADIENTS[i % CARD_GRADIENTS.length]}`}
|
||||||
>
|
>
|
||||||
{t.image ? (
|
{theater.image ? (
|
||||||
<>
|
<>
|
||||||
<img
|
<img
|
||||||
src={t.image}
|
src={theater.image}
|
||||||
alt={t.name}
|
alt={theater.name}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
|
decoding="async"
|
||||||
className="absolute inset-0 h-full w-full object-cover"
|
className="absolute inset-0 h-full w-full object-cover"
|
||||||
/>
|
/>
|
||||||
<div className="absolute inset-0 bg-gradient-to-t from-black/80 via-black/25 to-transparent" />
|
<div className="absolute inset-0 bg-gradient-to-t from-black/80 via-black/25 to-transparent" />
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
<div className="relative flex flex-col gap-1.5 rounded-2xl border border-white/10 bg-[#1B1B1B]/80 p-3 backdrop-blur-xl">
|
<div className="relative flex flex-col gap-1.5 rounded-2xl border border-white/10 bg-[#1B1B1B]/80 p-3 backdrop-blur-xl">
|
||||||
<span className="text-[10px] text-[#B3B3B3]">
|
<span className="text-[11px] text-[#C9C9C9]">
|
||||||
{t.distance}
|
{theater.distance}
|
||||||
</span>
|
</span>
|
||||||
<h3 className="text-sm font-semibold">{t.name}</h3>
|
<h3 className="text-sm font-semibold">{theater.name}</h3>
|
||||||
<p className="flex items-center gap-1.5 text-xs text-[#B3B3B3]">
|
<p className="flex items-center gap-1.5 text-xs text-[#C9C9C9]">
|
||||||
<IconMapPin size={12} /> {t.area}
|
<IconMapPin size={12} /> {theater.area}
|
||||||
</p>
|
</p>
|
||||||
<p className="flex items-center gap-1.5 text-xs text-[#B3B3B3]">
|
<p className="flex items-center gap-1.5 text-xs text-[#C9C9C9]">
|
||||||
<IconBuildingCommunity size={12} />{" "}
|
<IconBuildingCommunity size={12} />{" "}
|
||||||
{t.categories.join(" · ")}
|
{theater.categories.map(categoryLabel).join(" · ")}
|
||||||
</p>
|
</p>
|
||||||
<Link
|
<Link
|
||||||
to={`/cinema/${t.slug}`}
|
to={`/cinema/${theater.slug}`}
|
||||||
className="mt-3 flex items-center justify-end gap-2 text-xs font-medium transition hover:text-[#D47272]"
|
className="mt-3 flex items-center justify-end gap-2 text-xs font-medium transition hover:text-[#D47272]"
|
||||||
>
|
>
|
||||||
ดูรายละเอียด <IconArrowRight size={12} />
|
{t("home.cardDetail")} <IconArrowRight size={12} />
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
@@ -225,13 +219,13 @@ export default function HomeRoute() {
|
|||||||
|
|
||||||
{theaters.length === 0 ? (
|
{theaters.length === 0 ? (
|
||||||
<p className="py-10 text-center text-sm text-[#B3B3B3]">
|
<p className="py-10 text-center text-sm text-[#B3B3B3]">
|
||||||
ยังไม่มีโรงหนังในหมวดนี้
|
{t("home.empty")}
|
||||||
</p>
|
</p>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<div className="flex justify-center pt-2">
|
<div className="flex justify-center pt-2">
|
||||||
<button className="h-10 w-[200px] rounded-lg border border-[#8F0808] bg-[#8F0808] transition hover:bg-[#a30a0a]">
|
<button className="h-10 w-[200px] rounded-lg border border-[#8F0808] bg-[#8F0808] transition hover:bg-[#a30a0a]">
|
||||||
แสดงเพิ่ม
|
{t("home.more")}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -1,13 +1,23 @@
|
|||||||
import { requireAdmin } from "@/lib/auth.server";
|
import { requireAdmin } from "@/lib/auth.server";
|
||||||
import { deleteTheaterImage, saveTheaterImage } from "@/lib/images.server";
|
import { deleteTheaterImage, saveTheaterImage } from "@/lib/images.server";
|
||||||
|
import { readTheatersFile, writeTheaters } from "@/lib/theaters-store.server";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* อัปโหลด / ลบรูปโรงหนัง — /admin/image
|
* อัปโหลด / ลบรูปโรงหนัง — /admin/image (POST)
|
||||||
* ------------------------------------------------------------
|
* ------------------------------------------------------------
|
||||||
* ★ multipart/form-data: slug + file → บันทึกไฟล์ คืน { ok, url }
|
* ★ อัปไฟล์แล้ว "บันทึกเข้าข้อมูลทันที" — ไม่ต้องกดปุ่มบันทึกซ้ำ
|
||||||
* ★ JSON { url } + ?action=delete → ลบไฟล์ คืน { ok, url: null }
|
* (สาเหตุเดิมที่รูปขึ้นไม่ครบ: อัปแล้วยังไม่ทับ JSON)
|
||||||
|
* ★ ลบไฟล์รูปเดิมให้อัตโนมัติเมื่อเปลี่ยนรูป
|
||||||
* ★ ต้องมี session หลังบ้าน (cookie) ทุกครั้ง
|
* ★ ต้องมี session หลังบ้าน (cookie) ทุกครั้ง
|
||||||
*/
|
*/
|
||||||
|
async function persistImage(slug: string, url: string | null) {
|
||||||
|
const file = await readTheatersFile();
|
||||||
|
const theaters = file.theaters.map((theater) =>
|
||||||
|
theater.slug === slug ? { ...theater, image: url } : theater,
|
||||||
|
);
|
||||||
|
await writeTheaters(theaters);
|
||||||
|
}
|
||||||
|
|
||||||
export async function action({ request }: { request: Request }) {
|
export async function action({ request }: { request: Request }) {
|
||||||
try {
|
try {
|
||||||
requireAdmin(request);
|
requireAdmin(request);
|
||||||
@@ -38,11 +48,22 @@ export async function action({ request }: { request: Request }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await saveTheaterImage(slug, file);
|
const saved = await saveTheaterImage(slug, file);
|
||||||
if (!result.ok) {
|
if (!saved.ok) {
|
||||||
return Response.json(result, { status: 400 });
|
return Response.json(saved, { status: 400 });
|
||||||
}
|
}
|
||||||
return Response.json({ ok: true, url: result.url, bytes: result.bytes });
|
|
||||||
|
// ลบไฟล์เดิมก่อน แล้วบันทึก path ใหม่ลง JSON ทันที
|
||||||
|
const current = (await readTheatersFile()).theaters.find((t) => t.slug === slug);
|
||||||
|
if (current?.image) await deleteTheaterImage(current.image);
|
||||||
|
await persistImage(slug, saved.url);
|
||||||
|
|
||||||
|
return Response.json({
|
||||||
|
ok: true,
|
||||||
|
url: saved.url,
|
||||||
|
bytes: saved.bytes,
|
||||||
|
persisted: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const body = (await request.json().catch(() => ({}))) as { url?: string };
|
const body = (await request.json().catch(() => ({}))) as { url?: string };
|
||||||
|
|||||||
@@ -43,6 +43,43 @@ const inputClass =
|
|||||||
const labelClass = "text-xs font-medium text-[#B3B3B3]";
|
const labelClass = "text-xs font-medium text-[#B3B3B3]";
|
||||||
const panelClass = "rounded-xl border border-[#2A2A2A] bg-[#111] p-4";
|
const panelClass = "rounded-xl border border-[#2A2A2A] bg-[#111] p-4";
|
||||||
|
|
||||||
|
/** ย่อรูปก่อนอัป: ด้านยาวสุด 1600px, JPEG q0.85 — ไฟล์เล็กลงเร็วขึ้นมาก */
|
||||||
|
const MAX_EDGE = 1600;
|
||||||
|
const TARGET_BYTES = 400 * 1024;
|
||||||
|
|
||||||
|
async function shrinkImage(file: File): Promise<File> {
|
||||||
|
if (!file.type.startsWith("image/") || file.type === "image/svg+xml") return file;
|
||||||
|
try {
|
||||||
|
const bitmap = await createImageBitmap(file);
|
||||||
|
const scale = Math.min(1, MAX_EDGE / Math.max(bitmap.width, bitmap.height));
|
||||||
|
if (scale === 1 && file.size <= TARGET_BYTES) {
|
||||||
|
bitmap.close();
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
const width = Math.round(bitmap.width * scale);
|
||||||
|
const height = Math.round(bitmap.height * scale);
|
||||||
|
const canvas = document.createElement("canvas");
|
||||||
|
canvas.width = width;
|
||||||
|
canvas.height = height;
|
||||||
|
const context = canvas.getContext("2d");
|
||||||
|
if (!context) {
|
||||||
|
bitmap.close();
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
context.drawImage(bitmap, 0, 0, width, height);
|
||||||
|
bitmap.close();
|
||||||
|
|
||||||
|
const blob = await new Promise<Blob | null>((resolve) =>
|
||||||
|
canvas.toBlob(resolve, "image/jpeg", 0.85),
|
||||||
|
);
|
||||||
|
if (!blob || blob.size >= file.size) return file;
|
||||||
|
const name = `${file.name.replace(/\.\w+$/, "")}.jpg`;
|
||||||
|
return new File([blob], name, { type: "image/jpeg" });
|
||||||
|
} catch {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function Field({
|
function Field({
|
||||||
label,
|
label,
|
||||||
value,
|
value,
|
||||||
@@ -223,14 +260,15 @@ export default function AdminRoute() {
|
|||||||
revalidator.revalidate();
|
revalidator.revalidate();
|
||||||
};
|
};
|
||||||
|
|
||||||
/** อัปโหลดรูป (multipart) → เก็บไฟล์จริงใน public/images/theaters/ */
|
/** อัปโหลดรูป (multipart) → ย่อรูป → server บันทึกไฟล์ + JSON ให้เลย */
|
||||||
const uploadImage = async (file: File) => {
|
const uploadImage = async (file: File) => {
|
||||||
if (!active) return;
|
if (!active) return;
|
||||||
setUploading(true);
|
setUploading(true);
|
||||||
try {
|
try {
|
||||||
|
const prepared = await shrinkImage(file);
|
||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
form.append("slug", active.slug);
|
form.append("slug", active.slug);
|
||||||
form.append("image", file);
|
form.append("image", prepared);
|
||||||
const response = await fetch("/admin/image", { method: "POST", body: form });
|
const response = await fetch("/admin/image", { method: "POST", body: form });
|
||||||
const result = (await response.json()) as {
|
const result = (await response.json()) as {
|
||||||
ok?: boolean;
|
ok?: boolean;
|
||||||
@@ -245,20 +283,12 @@ export default function AdminRoute() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ลบไฟล์รูปเก่าทิ้ง (ถ้าเป็นไฟล์ที่เก็บในเว็บนี้)
|
|
||||||
if (active.image) {
|
|
||||||
await fetch("/admin/image?action=delete", {
|
|
||||||
method: "POST",
|
|
||||||
headers: { "content-type": "application/json" },
|
|
||||||
body: JSON.stringify({ url: active.image }),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
patchActive({ image: result.url });
|
patchActive({ image: result.url });
|
||||||
setStatus({
|
setStatus({
|
||||||
kind: "ok",
|
kind: "ok",
|
||||||
text: "อัปโหลดรูปแล้ว — กด \"บันทึก\" เพื่อเขียนลงไฟล์ JSON",
|
text: "อัปโหลดรูปและบันทึกเข้าข้อมูลแล้ว — หน้าเว็บเห็นทันที",
|
||||||
});
|
});
|
||||||
|
revalidator.revalidate();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setStatus({
|
setStatus({
|
||||||
kind: "error",
|
kind: "error",
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import {
|
|||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { Link, useLoaderData, useParams } from "react-router";
|
import { Link, useLoaderData, useParams } from "react-router";
|
||||||
|
|
||||||
|
import { LangSwitch, useLang } from "@/lib/lang";
|
||||||
|
import { contactHref } from "@/lib/links";
|
||||||
import type { Theater } from "@/lib/theaters";
|
import type { Theater } from "@/lib/theaters";
|
||||||
import { getTheater, resolveIcon } from "@/lib/theaters";
|
import { getTheater, resolveIcon } from "@/lib/theaters";
|
||||||
import { readTheatersFile } from "@/lib/theaters-store.server";
|
import { readTheatersFile } from "@/lib/theaters-store.server";
|
||||||
@@ -54,18 +56,17 @@ function Logo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function NotFound() {
|
function NotFound() {
|
||||||
|
const { t } = useLang();
|
||||||
return (
|
return (
|
||||||
<div className="flex min-h-screen flex-col items-center justify-center gap-6 bg-[#0D0D0D] px-6 text-center text-white">
|
<div className="flex min-h-screen flex-col items-center justify-center gap-6 bg-[#0D0D0D] px-6 text-center text-white">
|
||||||
<h1 className="text-3xl font-bold">ไม่พบโรงหนังที่ค้นหา</h1>
|
<h1 className="text-3xl font-bold">{t("detail.notFoundTitle")}</h1>
|
||||||
<p className="text-sm text-[#999]">
|
<p className="text-sm text-[#999]">{t("detail.notFoundLead")}</p>
|
||||||
ลิงก์อาจเปลี่ยนไปแล้ว หรือโรงนี้ยังไม่มีในระบบ
|
|
||||||
</p>
|
|
||||||
<Link
|
<Link
|
||||||
to="/"
|
to="/"
|
||||||
className="flex items-center gap-2 rounded-lg px-5 py-3"
|
className="flex items-center gap-2 rounded-lg px-5 py-3"
|
||||||
style={{ background: BRAND }}
|
style={{ background: BRAND }}
|
||||||
>
|
>
|
||||||
<IconArrowBackUp size={20} /> กลับไปหน้ารายชื่อโรงหนัง
|
<IconArrowBackUp size={20} /> {t("detail.notFoundBack")}
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -83,6 +84,7 @@ export default function CinemaDetailRoute() {
|
|||||||
};
|
};
|
||||||
const slug = useParams().slug;
|
const slug = useParams().slug;
|
||||||
const theater = getTheater(theaters, slug);
|
const theater = getTheater(theaters, slug);
|
||||||
|
const { t, categoryLabel, contactLabel } = useLang();
|
||||||
|
|
||||||
if (!theater) return <NotFound />;
|
if (!theater) return <NotFound />;
|
||||||
|
|
||||||
@@ -98,13 +100,7 @@ export default function CinemaDetailRoute() {
|
|||||||
<header className="relative flex items-center justify-between px-4 py-4 md:px-[108px]">
|
<header className="relative flex items-center justify-between px-4 py-4 md:px-[108px]">
|
||||||
<Logo />
|
<Logo />
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<div className="h-4 w-[21px] overflow-hidden">
|
<LangSwitch />
|
||||||
<div className="h-[2.75px] bg-[#A51931]" />
|
|
||||||
<div className="mt-[2.67px] h-[5.33px] bg-[#2D2A4A]" />
|
|
||||||
<div className="mt-[2.66px] h-[2.67px] bg-[#A51931]" />
|
|
||||||
</div>
|
|
||||||
<span className="text-lg font-medium">TH</span>
|
|
||||||
<IconChevronDown size={16} />
|
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
@@ -114,7 +110,7 @@ export default function CinemaDetailRoute() {
|
|||||||
className="inline-flex w-fit items-center gap-2 text-xl font-medium transition hover:text-[#D47272]"
|
className="inline-flex w-fit items-center gap-2 text-xl font-medium transition hover:text-[#D47272]"
|
||||||
>
|
>
|
||||||
<IconArrowBackUp size={24} />
|
<IconArrowBackUp size={24} />
|
||||||
ย้อนกลับ
|
{t("detail.back")}
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<section className="grid gap-6 lg:grid-cols-[minmax(0,807px)_minmax(0,387px)]">
|
<section className="grid gap-6 lg:grid-cols-[minmax(0,807px)_minmax(0,387px)]">
|
||||||
@@ -123,6 +119,8 @@ export default function CinemaDetailRoute() {
|
|||||||
<img
|
<img
|
||||||
src={theater.image}
|
src={theater.image}
|
||||||
alt={`รูปโรงหนัง ${theater.name}`}
|
alt={`รูปโรงหนัง ${theater.name}`}
|
||||||
|
decoding="async"
|
||||||
|
fetchPriority="high"
|
||||||
className="absolute inset-0 h-full w-full object-cover"
|
className="absolute inset-0 h-full w-full object-cover"
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
@@ -154,16 +152,16 @@ export default function CinemaDetailRoute() {
|
|||||||
<div className="flex flex-col gap-6">
|
<div className="flex flex-col gap-6">
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
<div className="flex flex-wrap gap-2">
|
<div className="flex flex-wrap gap-2">
|
||||||
{theater.categories.map((t) => (
|
{theater.categories.map((category) => (
|
||||||
<span
|
<span
|
||||||
key={t}
|
key={category}
|
||||||
className="rounded-[18px] border border-[#A92626] px-4 py-2 text-sm text-[#D47272]"
|
className="rounded-[18px] border border-[#A92626] px-4 py-2 text-sm text-[#D47272]"
|
||||||
style={{
|
style={{
|
||||||
background:
|
background:
|
||||||
"linear-gradient(180deg, rgba(143,8,8,0.3) 0%, rgba(27,27,27,0) 100%)",
|
"linear-gradient(180deg, rgba(143,8,8,0.3) 0%, rgba(27,27,27,0) 100%)",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t}
|
{categoryLabel(category)}
|
||||||
</span>
|
</span>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -172,7 +170,7 @@ export default function CinemaDetailRoute() {
|
|||||||
</h1>
|
</h1>
|
||||||
{theater.hidden ? (
|
{theater.hidden ? (
|
||||||
<span className="w-fit rounded border border-[#5a3a00] bg-[#2a1f00] px-2 py-1 text-xs text-[#e0b357]">
|
<span className="w-fit rounded border border-[#5a3a00] bg-[#2a1f00] px-2 py-1 text-xs text-[#e0b357]">
|
||||||
ซ่อนจากหน้าแรก
|
{t("detail.hidden")}
|
||||||
</span>
|
</span>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
@@ -188,14 +186,13 @@ export default function CinemaDetailRoute() {
|
|||||||
rel="noreferrer"
|
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 transition hover:bg-white/10"
|
className="flex w-[200px] items-center justify-center gap-2 rounded-lg border border-white px-4 py-2 text-lg font-medium transition hover:bg-white/10"
|
||||||
>
|
>
|
||||||
เปิด Google map
|
{t("detail.map")}
|
||||||
<IconMap size={24} />
|
<IconMap size={24} />
|
||||||
</a>
|
</a>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
<p className="text-xl leading-[1.3]">
|
<p className="text-xl leading-[1.3]">
|
||||||
{theater.description ??
|
{theater.description ?? t("detail.noDescription")}
|
||||||
"ยังไม่มีข้อมูลรายละเอียดของโรงหนังนี้ — อยู่ระหว่างรวบรวมข้อมูล"}
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -232,28 +229,43 @@ export default function CinemaDetailRoute() {
|
|||||||
>
|
>
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
<h2 className="text-2xl font-semibold leading-[1.3]">
|
<h2 className="text-2xl font-semibold leading-[1.3]">
|
||||||
สอบถามข้อมูลและจองตั๋ว
|
{t("detail.contactTitle")}
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
{theater.contacts.length > 0 ? (
|
{theater.contacts.length > 0 ? (
|
||||||
theater.contacts.map((c) => (
|
theater.contacts.map((c) => {
|
||||||
<div key={c.label} className="flex flex-col gap-2">
|
const link = contactHref(c.label, c.value);
|
||||||
<span className="text-sm text-[#999]">{c.label}</span>
|
return (
|
||||||
<div className="flex items-center justify-between">
|
<div key={c.label} className="flex flex-col gap-2">
|
||||||
<span>{c.value}</span>
|
<span className="text-sm text-[#B3B3B3]">
|
||||||
<IconExternalLink size={16} />
|
{contactLabel(c.label)}
|
||||||
|
</span>
|
||||||
|
<div className="flex items-center justify-between gap-3">
|
||||||
|
{link ? (
|
||||||
|
<a
|
||||||
|
href={link.href}
|
||||||
|
{...(link.external
|
||||||
|
? { target: "_blank", rel: "noreferrer" }
|
||||||
|
: {})}
|
||||||
|
className="min-w-0 break-words underline decoration-[#5a3a3a] underline-offset-4 transition hover:text-[#ffb3b3] hover:decoration-[#ffb3b3]"
|
||||||
|
>
|
||||||
|
{c.value}
|
||||||
|
</a>
|
||||||
|
) : (
|
||||||
|
<span className="min-w-0 break-words">{c.value}</span>
|
||||||
|
)}
|
||||||
|
{link ? <IconExternalLink size={16} className="shrink-0" /> : null}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
);
|
||||||
))
|
})
|
||||||
) : (
|
) : (
|
||||||
<p className="text-sm text-[#999]">
|
<p className="text-sm text-[#999]">{t("detail.contactEmpty")}</p>
|
||||||
ยังไม่มีช่องทางติดต่อของโรงนี้
|
|
||||||
</p>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{theater.payments.length > 0 ? (
|
{theater.payments.length > 0 ? (
|
||||||
<div className="flex flex-col gap-3">
|
<div className="flex flex-col gap-3">
|
||||||
<span className="text-sm text-[#999]">Payment</span>
|
<span className="text-sm text-[#B3B3B3]">{t("detail.payment")}</span>
|
||||||
<div className="flex flex-wrap items-center gap-6">
|
<div className="flex flex-wrap items-center gap-6">
|
||||||
{theater.payments.map((p) => (
|
{theater.payments.map((p) => (
|
||||||
<span key={p} className="flex items-center gap-1 text-sm">
|
<span key={p} className="flex items-center gap-1 text-sm">
|
||||||
@@ -269,7 +281,7 @@ export default function CinemaDetailRoute() {
|
|||||||
className="flex h-12 items-center justify-center gap-2 rounded-lg px-4 transition hover:bg-[#a30a0a]"
|
className="flex h-12 items-center justify-center gap-2 rounded-lg px-4 transition hover:bg-[#a30a0a]"
|
||||||
style={{ background: BRAND, border: `1px solid ${BRAND}` }}
|
style={{ background: BRAND, border: `1px solid ${BRAND}` }}
|
||||||
>
|
>
|
||||||
ดูรอบฉาย
|
{t("detail.schedule")}
|
||||||
</button>
|
</button>
|
||||||
</aside>
|
</aside>
|
||||||
</section>
|
</section>
|
||||||
@@ -277,7 +289,7 @@ export default function CinemaDetailRoute() {
|
|||||||
<section className="grid gap-10 lg:grid-cols-[minmax(0,749px)_minmax(0,384px)] lg:justify-between">
|
<section className="grid gap-10 lg:grid-cols-[minmax(0,749px)_minmax(0,384px)] lg:justify-between">
|
||||||
<div className="flex flex-col gap-8">
|
<div className="flex flex-col gap-8">
|
||||||
<h2 className="text-2xl font-semibold leading-[1.3]">
|
<h2 className="text-2xl font-semibold leading-[1.3]">
|
||||||
สิ่งอำนวยความสะดวก
|
{t("detail.facilities")}
|
||||||
</h2>
|
</h2>
|
||||||
{theater.facilities.length > 0 ? (
|
{theater.facilities.length > 0 ? (
|
||||||
<div className="grid grid-cols-2 gap-x-4 gap-y-10 sm:grid-cols-4">
|
<div className="grid grid-cols-2 gap-x-4 gap-y-10 sm:grid-cols-4">
|
||||||
@@ -303,9 +315,7 @@ export default function CinemaDetailRoute() {
|
|||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<p className="text-sm text-[#999]">
|
<p className="text-sm text-[#999]">{t("detail.facilitiesEmpty")}</p>
|
||||||
ยังไม่มีข้อมูลสิ่งอำนวยความสะดวก
|
|
||||||
</p>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -314,7 +324,9 @@ export default function CinemaDetailRoute() {
|
|||||||
style={{ border: `1px solid ${BORDER}` }}
|
style={{ border: `1px solid ${BORDER}` }}
|
||||||
>
|
>
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
<h2 className="text-2xl font-semibold leading-[1.3]">ที่ตั้ง</h2>
|
<h2 className="text-2xl font-semibold leading-[1.3]">
|
||||||
|
{t("detail.location")}
|
||||||
|
</h2>
|
||||||
<div className="h-[183px] rounded-xl bg-[#E8E8E8]" />
|
<div className="h-[183px] rounded-xl bg-[#E8E8E8]" />
|
||||||
</div>
|
</div>
|
||||||
<p className="text-sm leading-[1.3] text-[#999]">
|
<p className="text-sm leading-[1.3] text-[#999]">
|
||||||
@@ -325,18 +337,30 @@ export default function CinemaDetailRoute() {
|
|||||||
|
|
||||||
<section className="flex flex-col gap-8">
|
<section className="flex flex-col gap-8">
|
||||||
<h2 className="text-2xl font-semibold leading-[1.3]">
|
<h2 className="text-2xl font-semibold leading-[1.3]">
|
||||||
โรงหนังอิสระอื่นๆ
|
{t("detail.others")}
|
||||||
</h2>
|
</h2>
|
||||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-3">
|
<div className="grid grid-cols-1 gap-4 sm:grid-cols-3">
|
||||||
{others.map((other) => (
|
{others.map((other) => (
|
||||||
<Link
|
<Link
|
||||||
key={other.slug}
|
key={other.slug}
|
||||||
to={`/cinema/${other.slug}`}
|
to={`/cinema/${other.slug}`}
|
||||||
className="flex h-[180px] flex-col justify-end rounded-[20px] bg-gradient-to-br from-[#3a2a22] via-[#2a2a3a] to-[#1b1b1b] p-2 transition hover:from-[#4a3320]"
|
className="relative flex h-[180px] flex-col justify-end overflow-hidden rounded-[20px] bg-gradient-to-br from-[#3a2a22] via-[#2a2a3a] to-[#1b1b1b] p-2 transition hover:from-[#4a3320]"
|
||||||
>
|
>
|
||||||
<div className="flex flex-col gap-1.5 rounded-2xl border border-white/10 bg-[#1B1B1B]/80 p-3 backdrop-blur-xl">
|
{other.image ? (
|
||||||
|
<>
|
||||||
|
<img
|
||||||
|
src={other.image}
|
||||||
|
alt={other.name}
|
||||||
|
loading="lazy"
|
||||||
|
decoding="async"
|
||||||
|
className="absolute inset-0 h-full w-full object-cover"
|
||||||
|
/>
|
||||||
|
<div className="absolute inset-0 bg-gradient-to-t from-black/85 via-black/30 to-transparent" />
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
<div className="relative flex flex-col gap-1.5 rounded-2xl border border-white/10 bg-[#1B1B1B]/80 p-3 backdrop-blur-xl">
|
||||||
<h3 className="text-sm font-semibold">{other.name}</h3>
|
<h3 className="text-sm font-semibold">{other.name}</h3>
|
||||||
<p className="flex items-center gap-1.5 text-xs text-[#B3B3B3]">
|
<p className="flex items-center gap-1.5 text-xs text-[#C9C9C9]">
|
||||||
<IconMapPin size={12} /> {other.area}
|
<IconMapPin size={12} /> {other.area}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"updated_at": "2026-10-27T15:43:35.189Z",
|
"updated_at": "2026-10-27T16:08:42.921Z",
|
||||||
"theaters": [
|
"theaters": [
|
||||||
{
|
{
|
||||||
"slug": "house-cinema-samyan",
|
"slug": "house-cinema-samyan",
|
||||||
@@ -95,7 +95,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"hidden": false,
|
"hidden": false,
|
||||||
"image": "/images/theaters/house-cinema-samyan-1793115815167.png"
|
"image": "/images/theaters/house-cinema-samyan-1793116793628.jpg"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"slug": "major-hollywood",
|
"slug": "major-hollywood",
|
||||||
@@ -113,11 +113,11 @@
|
|||||||
"payments": [],
|
"payments": [],
|
||||||
"facilities": [],
|
"facilities": [],
|
||||||
"hidden": false,
|
"hidden": false,
|
||||||
"image": null
|
"image": "/images/theaters/major-hollywood-1793116832469.jpg"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"slug": "century",
|
"slug": "century-the-movie-plaza-victory-monument",
|
||||||
"name": "CENTURY",
|
"name": "CENTURY THE MOVIE PLAZA victory monument",
|
||||||
"area": "กรุงเทพฯ",
|
"area": "กรุงเทพฯ",
|
||||||
"distance": "—",
|
"distance": "—",
|
||||||
"categories": [
|
"categories": [
|
||||||
@@ -125,13 +125,15 @@
|
|||||||
],
|
],
|
||||||
"description": null,
|
"description": null,
|
||||||
"address": null,
|
"address": null,
|
||||||
"map_url": null,
|
"map_url": "https://maps.app.goo.gl/udAurcsQGy9tQktp9",
|
||||||
"transport": [],
|
"transport": [],
|
||||||
"contacts": [],
|
"contacts": [],
|
||||||
"payments": [],
|
"payments": [
|
||||||
|
"เงินสด"
|
||||||
|
],
|
||||||
"facilities": [],
|
"facilities": [],
|
||||||
"hidden": false,
|
"hidden": false,
|
||||||
"image": null
|
"image": "/images/theaters/century-the-movie-plaza-victory-monument-1793117166474.jpg"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"slug": "ck-plaza",
|
"slug": "ck-plaza",
|
||||||
@@ -149,7 +151,7 @@
|
|||||||
"payments": [],
|
"payments": [],
|
||||||
"facilities": [],
|
"facilities": [],
|
||||||
"hidden": false,
|
"hidden": false,
|
||||||
"image": null
|
"image": "/images/theaters/ck-plaza-1793117233428.jpg"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"slug": "thana-cineplex",
|
"slug": "thana-cineplex",
|
||||||
@@ -167,7 +169,7 @@
|
|||||||
"payments": [],
|
"payments": [],
|
||||||
"facilities": [],
|
"facilities": [],
|
||||||
"hidden": false,
|
"hidden": false,
|
||||||
"image": null
|
"image": "/images/theaters/thana-cineplex-1793117214796.jpg"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"slug": "coliseum-paradise",
|
"slug": "coliseum-paradise",
|
||||||
@@ -186,7 +188,7 @@
|
|||||||
"payments": [],
|
"payments": [],
|
||||||
"facilities": [],
|
"facilities": [],
|
||||||
"hidden": false,
|
"hidden": false,
|
||||||
"image": null
|
"image": "/images/theaters/coliseum-paradise-1793117225935.jpg"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
After Width: | Height: | Size: 2.9 MiB |
|
After Width: | Height: | Size: 61 KiB |
|
After Width: | Height: | Size: 166 KiB |
|
Before Width: | Height: | Size: 350 KiB |
|
After Width: | Height: | Size: 119 KiB |
|
After Width: | Height: | Size: 185 KiB |
|
After Width: | Height: | Size: 286 KiB |