feat(ui): full i18n (th/en) + highway stop search + real km list
i18n: - LangProvider (client context) + cookie/lang localStorage sync - locales/th.json + en.json จาก design (269 keys) - แปล header/nav/footer/home/route/stop/check ผ่าน t() - server pages อ่าน cookie lang (SSR แปลตรง) + client context Stop search (หน้า /stops): - code search 5 หลัก (kilometer '36+020' → pad5 '36020') + numpad - place search (ชื่อสถานที่) + suggest - near-me (geolocation → ป้ายทางหลวงใกล้สุด 8 อัน, haversine) - data: busstop_list.json (154 ป้ายทางหลวง) Route detail: km list ใช้ระยะจริงจาก stop-km.json (แทน stop_sequence) Note: 'nearby ใกล้เคียงป้าย' ไม่ทำ — stations.json ไม่มี landmarks data
This commit is contained in:
1 parent
0c3936df69
commit
1526c5b6d0
18 files changed
+3146
-141
No files matched your search
@@ -3,6 +3,8 @@ import { api, type RouteListItem, type Schedule, type RouteStop, type RouteDetai
|
||||
import { RouteSelect } from "@/components/RouteSelect";
|
||||
import { VisitTracker } from "@/lib/visit-tracker";
|
||||
import { Icon } from "@/components/Icons";
|
||||
import { headers } from "next/headers";
|
||||
import { t, langFromCookie } from "@/lib/i18n";
|
||||
|
||||
const TONES = ["sky", "purple", "pink", "mint", "amber"] as const;
|
||||
|
||||
@@ -23,6 +25,9 @@ type CheckPageProps = {
|
||||
|
||||
export default async function CheckPage({ searchParams }: CheckPageProps) {
|
||||
const sp = await searchParams;
|
||||
const h = await headers();
|
||||
const lang = langFromCookie(h.get("cookie"));
|
||||
const T = (k: string, v?: Record<string, string | number>) => t(k, lang, v);
|
||||
|
||||
const { items: allRoutes } = await api.routes().catch(() => ({ items: [] as RouteListItem[] }));
|
||||
const routeId =
|
||||
@@ -68,14 +73,14 @@ export default async function CheckPage({ searchParams }: CheckPageProps) {
|
||||
<div className="hero__blob three" aria-hidden />
|
||||
<div className="container hero__inner">
|
||||
<span className="hero__badge">
|
||||
<Icon name="clock" size={14} className="icon" /> เช็กเวลาเดินรถ
|
||||
<Icon name="clock" size={14} className="icon" /> {T("cta.check")}
|
||||
</span>
|
||||
<h1>
|
||||
ตารางเวลาเดินรถ
|
||||
{T("check.title")}
|
||||
<br />
|
||||
<span className="hero__grad">{route?.name_th ?? "เลือกสายรถด้านล่าง"}</span>
|
||||
<span className="hero__grad">{route?.name_th ?? (lang === "en" ? "Select a route below" : "เลือกสายรถด้านล่าง")}</span>
|
||||
</h1>
|
||||
<p className="hero__lead">เลือกสายรถ แล้วดูรอบรถทุกจุดจอดในหน้าเดียว</p>
|
||||
<p className="hero__lead">{T("check.lead")}</p>
|
||||
|
||||
{allRoutes.length > 0 && (
|
||||
<div className="check-selector">
|
||||
@@ -92,16 +97,16 @@ export default async function CheckPage({ searchParams }: CheckPageProps) {
|
||||
<div className="container">
|
||||
{/* สรุปเส้นทาง */}
|
||||
<div className="check-stats">
|
||||
<div className="check-stat"><b>{stops.length}</b><span>จุดจอดหลัก</span></div>
|
||||
<div className="check-stat"><b>{provinceSet.size}</b><span>จังหวัดที่ผ่าน</span></div>
|
||||
<div className="check-stat"><b>{allTimes.length}</b><span>รอบต่อวัน</span></div>
|
||||
<div className="check-stat"><b>{next ?? "—"}</b><span>{next ? "รอบถัดไป" : "ไม่มีรอบวันนี้"}</span></div>
|
||||
<div className="check-stat"><b>{stops.length}</b><span>{T("check.kpiStops")}</span></div>
|
||||
<div className="check-stat"><b>{provinceSet.size}</b><span>{T("check.kpiProvince")}</span></div>
|
||||
<div className="check-stat"><b>{allTimes.length}</b><span>{T("check.kpiTrips")}</span></div>
|
||||
<div className="check-stat"><b>{next ?? "—"}</b><span>{next ? T("check.kpiNext") : (lang === "en" ? "No trips today" : "ไม่มีรอบวันนี้")}</span></div>
|
||||
</div>
|
||||
|
||||
{/* ตารางเวลาทุกจุดจอด */}
|
||||
<section className="check-schedule">
|
||||
<h2 className="section-title">
|
||||
ตารางเวลาเดินรถทุกจุดจอด {route ? `— สาย ${route.route_id}` : ""}
|
||||
{T("check.scheduleAll")} {route ? `— ${lang === "en" ? "Route" : "สาย"} ${route.route_id}` : ""}
|
||||
</h2>
|
||||
{schedules.length === 0 ? (
|
||||
<p className="muted">ยังไม่มีข้อมูลตารางเวลาสำหรับสายนี้</p>
|
||||
|
||||
@@ -1275,4 +1275,68 @@ a.contact-item:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(
|
||||
}
|
||||
.toolbar__search .toolbar__clear:hover { background: #e7e1f4; }
|
||||
|
||||
/* ---------- Stop search (รหัส 5 หลัก + ชื่อสถานที่ + ป้ายใกล้ฉัน) ---------- */
|
||||
.stop-search {
|
||||
background: #fff; border: 1px solid var(--line); border-radius: 16px;
|
||||
padding: 16px 18px; margin: 0 0 18px; box-shadow: 0 8px 20px rgba(63, 43, 94, .06);
|
||||
}
|
||||
.stop-search__tabs { display: flex; gap: 8px; margin-bottom: 14px; }
|
||||
.stop-search__tab {
|
||||
display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
|
||||
border-radius: 999px; border: 1px solid #e6dff5; background: #f7f4fd;
|
||||
color: #6b5b8a; font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer;
|
||||
}
|
||||
.stop-search__tab.on { background: var(--grad-cta); color: #fff; border-color: transparent; }
|
||||
.stop-search__panel { display: flex; flex-direction: column; gap: 12px; }
|
||||
.code-boxes { display: flex; gap: 8px; justify-content: center; }
|
||||
.code-cell {
|
||||
width: 46px; height: 54px; display: flex; align-items: center; justify-content: center;
|
||||
border-radius: 10px; border: 1px solid #d9d2ea; background: #faf9ff;
|
||||
font-size: 1.3rem; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.code-cell.filled { border-color: #a78bfa; background: #f5eeff; }
|
||||
.numpad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; max-width: 360px; margin: 0 auto; }
|
||||
.numpad button {
|
||||
height: 46px; border-radius: 10px; border: 1px solid #e6dff5; background: #fff;
|
||||
font: inherit; font-size: 1.05rem; font-weight: 700; color: var(--ink); cursor: pointer;
|
||||
}
|
||||
.numpad button:hover { background: #f5eeff; }
|
||||
.stop-search__actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
|
||||
.mu-btn.ghost {
|
||||
display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
|
||||
border-radius: 999px; border: 1px solid #e6dff5; background: #fff; color: #6b5b8a;
|
||||
font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer;
|
||||
}
|
||||
.stop-search__field { display: flex; align-items: center; gap: 8px; border: 1px solid #d9d2ea; border-radius: 12px; padding: 10px 12px; }
|
||||
.stop-search__field .icon { color: #8b5cf6; flex: none; }
|
||||
.stop-search__field input { flex: 1; border: none; outline: none; font: inherit; font-size: .95rem; color: var(--ink); }
|
||||
.stop-search__suggest { list-style: none; margin: 8px 0 0; padding: 0; border: 1px solid #e6dff5; border-radius: 12px; overflow: hidden; }
|
||||
.stop-search__suggest li { border-bottom: 1px solid #f0ecf8; }
|
||||
.stop-search__suggest li:last-child { border-bottom: 0; }
|
||||
.stop-search__suggest button {
|
||||
display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px;
|
||||
background: #fff; border: 0; font: inherit; text-align: left; cursor: pointer;
|
||||
}
|
||||
.stop-search__suggest button:hover { background: #f7f4fd; }
|
||||
.stop-search__suggest .km { flex: none; font-weight: 800; color: #7a4cc0; font-variant-numeric: tabular-nums; }
|
||||
.stop-search__suggest .name { flex: 1; color: var(--ink); font-weight: 600; }
|
||||
.stop-search__suggest .meta { flex: none; color: var(--muted); font-size: .8rem; }
|
||||
.stop-search__err { margin: 8px 0 0; color: #c0392b; font-size: .85rem; }
|
||||
|
||||
.busstop-result {
|
||||
margin-top: 14px; padding: 14px 16px; border: 1px solid #e7e0f6; border-radius: 14px;
|
||||
background: linear-gradient(135deg, #faf7ff, #fdf2f8); box-shadow: 0 6px 14px rgba(122, 76, 192, .08);
|
||||
}
|
||||
.busstop-result__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
|
||||
.busstop-result__km {
|
||||
flex: none; background: linear-gradient(135deg, #7a4cc0, #b07ce0); color: #fff;
|
||||
padding: 4px 10px; border-radius: 8px; font-weight: 800; font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.busstop-result__name { flex: 1; color: var(--ink); font-weight: 700; }
|
||||
.busstop-result__dist { flex: none; color: #7a4cc0; font-weight: 700; font-size: .85rem; }
|
||||
.busstop-result__meta { margin: 6px 0 0; color: var(--muted); font-size: .85rem; }
|
||||
.busstop-result__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
|
||||
.stop-search__nearby { margin-top: 14px; }
|
||||
.stop-search__nearby h3 { margin: 0 0 10px; font-size: .95rem; color: var(--ink); }
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import "./globals.css";
|
||||
import type { Metadata, Viewport } from "next";
|
||||
import { headers } from "next/headers";
|
||||
import { Header } from "@/components/Header";
|
||||
import { Footer } from "@/components/Footer";
|
||||
import { LangProvider } from "@/components/LangProvider";
|
||||
import { langFromCookie } from "@/lib/i18n";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Atroute — สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง",
|
||||
@@ -17,9 +20,12 @@ export const viewport: Viewport = {
|
||||
themeColor: "#7a4cc0",
|
||||
};
|
||||
|
||||
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
||||
export default async function RootLayout({ children }: { children: React.ReactNode }) {
|
||||
const h = await headers();
|
||||
const lang = langFromCookie(h.get("cookie"));
|
||||
|
||||
return (
|
||||
<html lang="th">
|
||||
<html lang={lang}>
|
||||
<head>
|
||||
{/* K2D (offline, local woff2 — ตรงกับ design) + Noto/Prompt fallback (CDN) */}
|
||||
<link rel="stylesheet" href="/fonts/k2d.css" />
|
||||
@@ -29,9 +35,11 @@ export default function RootLayout({ children }: { children: React.ReactNode })
|
||||
/>
|
||||
</head>
|
||||
<body>
|
||||
<Header />
|
||||
{children}
|
||||
<Footer />
|
||||
<LangProvider initial={lang}>
|
||||
<Header />
|
||||
{children}
|
||||
<Footer />
|
||||
</LangProvider>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
|
||||
@@ -15,7 +15,10 @@ import { VisitTracker } from "@/lib/visit-tracker";
|
||||
import { routePhoto } from "@/lib/images";
|
||||
import { routePath } from "@/lib/geojson";
|
||||
import { captionFor } from "@/lib/captions";
|
||||
import { kmFor } from "@/lib/stop-km";
|
||||
import { Icon } from "@/components/Icons";
|
||||
import { headers } from "next/headers";
|
||||
import { t, langFromCookie } from "@/lib/i18n";
|
||||
|
||||
const TONES = ["sky", "purple", "pink", "mint", "amber"] as const;
|
||||
|
||||
@@ -38,6 +41,9 @@ function nextTrip(schedules: Schedule[]): string | null {
|
||||
|
||||
export default async function RouteDetailPage({ params }: RouteDetailPageProps) {
|
||||
const { routeId } = await params;
|
||||
const h = await headers();
|
||||
const lang = langFromCookie(h.get("cookie"));
|
||||
const T = (k: string, v?: Record<string, string | number>) => t(k, lang, v);
|
||||
|
||||
let route: RouteDetail | null = null;
|
||||
let stops: RouteStop[] = [];
|
||||
@@ -179,7 +185,7 @@ export default async function RouteDetailPage({ params }: RouteDetailPageProps)
|
||||
<img className="vehicle-card__img" src={photo} alt={`รถของสาย ${route.route_id}`} />
|
||||
)}
|
||||
<div className="vehicle-card__meta">
|
||||
<p className="vehicle-card__label">รถประจำสาย</p>
|
||||
<p className="vehicle-card__label">{T("route.vehicle")}</p>
|
||||
{cap?.vehicle_title && <h2>{cap.vehicle_title}</h2>}
|
||||
{cap?.vehicle_desc && <p>{cap.vehicle_desc}</p>}
|
||||
{!cap?.vehicle_title && !cap?.vehicle_desc && (
|
||||
@@ -212,7 +218,7 @@ export default async function RouteDetailPage({ params }: RouteDetailPageProps)
|
||||
{/* แผนที่เส้นทาง + จุดจอดตามเส้นทาง */}
|
||||
<section className="route-map-section">
|
||||
<div className="route-map-section__head">
|
||||
<h2 className="section-title">เส้นทางเดินรถ</h2>
|
||||
<h2 className="section-title">{T("route.mapTitle")}</h2>
|
||||
<span className="route-map-section__legend">
|
||||
<span><i className="dot dot--start" /> ต้นทาง</span>
|
||||
<span><i className="dot dot--mid" /> จุดผ่าน</span>
|
||||
@@ -229,15 +235,18 @@ export default async function RouteDetailPage({ params }: RouteDetailPageProps)
|
||||
|
||||
{stops.length > 0 && (
|
||||
<div className="km-wrap">
|
||||
<h3 className="km-wrap__title">จุดจอดตามเส้นทาง (กม. จากต้นทาง)</h3>
|
||||
<h3 className="km-wrap__title">{T("map.alongRoute")}</h3>
|
||||
<ol className="km-list">
|
||||
{stops.map((s) => (
|
||||
<li key={s.station_id}>
|
||||
<span className="km-list__num">{s.stop_sequence}</span>
|
||||
<span className="km-list__name">{s.name_th}</span>
|
||||
{s.city_th && <span className="km-list__loc">{s.city_th}</span>}
|
||||
</li>
|
||||
))}
|
||||
{stops.map((s) => {
|
||||
const km = kmFor(route.route_id, s.station_id);
|
||||
return (
|
||||
<li key={s.station_id}>
|
||||
<span className="km-list__num">{km != null ? km.toFixed(1) : s.stop_sequence}</span>
|
||||
<span className="km-list__name">{s.name_th}</span>
|
||||
<span className="km-list__loc">{km != null ? "กม." : s.city_th ?? ""}</span>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ol>
|
||||
</div>
|
||||
)}
|
||||
@@ -245,7 +254,7 @@ export default async function RouteDetailPage({ params }: RouteDetailPageProps)
|
||||
|
||||
{/* จุดจอดตามลำดับ (รายละเอียด) */}
|
||||
<section>
|
||||
<h2 className="section-title">จุดจอดตามลำดับ ({stops.length})</h2>
|
||||
<h2 className="section-title">{T("route.stopsTitle")} ({stops.length})</h2>
|
||||
<ol className="stop-timeline">
|
||||
{stops.map((s, i) => {
|
||||
const tone = TONES[i % TONES.length];
|
||||
@@ -292,7 +301,7 @@ export default async function RouteDetailPage({ params }: RouteDetailPageProps)
|
||||
|
||||
{/* ตารางเวลา */}
|
||||
<section>
|
||||
<h2 className="section-title">ตารางเวลา ({schedules.length})</h2>
|
||||
<h2 className="section-title">{T("route.scheduleTitle")} ({schedules.length})</h2>
|
||||
{schedules.length === 0 ? (
|
||||
<p className="muted">ยังไม่มีข้อมูลตารางเวลา</p>
|
||||
) : (
|
||||
|
||||
@@ -6,6 +6,8 @@ import { LiveClock } from "@/components/LiveClock";
|
||||
import { VisitTracker } from "@/lib/visit-tracker";
|
||||
import { stopPhoto } from "@/lib/images";
|
||||
import { Icon } from "@/components/Icons";
|
||||
import { headers } from "next/headers";
|
||||
import { t, langFromCookie } from "@/lib/i18n";
|
||||
|
||||
const TYPE_LABEL: Record<string, string> = {
|
||||
main_terminal: "สถานีขนส่ง",
|
||||
@@ -30,6 +32,10 @@ export default async function StopDetailsPage({ searchParams }: StopDetailsPageP
|
||||
const { code } = await searchParams;
|
||||
if (!code) notFound();
|
||||
|
||||
const h = await headers();
|
||||
const lang = langFromCookie(h.get("cookie"));
|
||||
const T = (k: string, v?: Record<string, string | number>) => t(k, lang, v);
|
||||
|
||||
let stop: StopDetail | null = null;
|
||||
let schedules: Schedule[] = [];
|
||||
|
||||
@@ -132,7 +138,7 @@ export default async function StopDetailsPage({ searchParams }: StopDetailsPageP
|
||||
|
||||
<div className="stop-layout">
|
||||
<div className="stop-panel">
|
||||
<h2 className="section-title">สายรถที่ผ่านจุดนี้</h2>
|
||||
<h2 className="section-title">{T("stop.routes")}</h2>
|
||||
{routes.length === 0 ? (
|
||||
<p className="muted">ยังไม่มีข้อมูลสายที่ผ่าน</p>
|
||||
) : (
|
||||
@@ -171,7 +177,7 @@ export default async function StopDetailsPage({ searchParams }: StopDetailsPageP
|
||||
</div>
|
||||
|
||||
<aside className="stop-panel">
|
||||
<h2 className="section-title">แผนที่และข้อมูลป้าย</h2>
|
||||
<h2 className="section-title">{T("stop.mapInfo")}</h2>
|
||||
{hasMap ? (
|
||||
<div className="map-wrap map-wrap--soft">
|
||||
<LazyMapView points={mapPoints} />
|
||||
|
||||
@@ -3,6 +3,7 @@ import { api } from "@/lib/api";
|
||||
import LazyMapView from "@/components/LazyMapView";
|
||||
import { VisitTracker } from "@/lib/visit-tracker";
|
||||
import { Icon, type IconName } from "@/components/Icons";
|
||||
import { StopSearch } from "@/components/StopSearch";
|
||||
|
||||
const TONES = ["sky", "purple", "pink", "mint", "amber"] as const;
|
||||
const TYPE_TONE: Record<string, (typeof TONES)[number]> = {
|
||||
@@ -82,6 +83,9 @@ export default async function StopsPage({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ค้นหาป้ายทางหลวง: รหัส 5 หลัก + ชื่อสถานที่ + ป้ายใกล้ฉัน */}
|
||||
<StopSearch />
|
||||
|
||||
<div className="toolbar">
|
||||
<form className="toolbar__search" action="/stops" method="get" role="search">
|
||||
<Icon name="search" size={16} className="icon" />
|
||||
|
||||
@@ -3,24 +3,29 @@ import Image from "next/image";
|
||||
import { LOGO, PARTNERS } from "@/lib/images";
|
||||
import { Icon } from "@/components/Icons";
|
||||
import { api } from "@/lib/api";
|
||||
import { headers } from "next/headers";
|
||||
import { t, langFromCookie } from "@/lib/i18n";
|
||||
|
||||
const popularRoutes = [
|
||||
{ id: "101", label: "สาย 101 · อ่างทอง-อยุธยา" },
|
||||
{ id: "902", label: "สาย 902 · กรุงเทพ-อ่างทอง" },
|
||||
{ id: "15", label: "สาย 15 · สายใน" },
|
||||
{ id: "464", label: "สาย 464 · สุพรรณ-สระบุรี" },
|
||||
{ id: "101", label_th: "สาย 101 · อ่างทอง-อยุธยา", label_en: "Route 101 · Ang Thong–Ayutthaya" },
|
||||
{ id: "902", label_th: "สาย 902 · กรุงเทพ-อ่างทอง", label_en: "Route 902 · Bangkok–Ang Thong" },
|
||||
{ id: "15", label_th: "สาย 15 · สายใน", label_en: "Route 15 · Local" },
|
||||
{ id: "464", label_th: "สาย 464 · สุพรรณ-สระบุรี", label_en: "Route 464 · Suphan–Saraburi" },
|
||||
];
|
||||
|
||||
const MENU = [
|
||||
{ href: "/", label: "หน้าแรก" },
|
||||
{ href: "/stops", label: "ค้นหาป้ายหยุดรถ" },
|
||||
{ href: "/routes", label: "รายละเอียดสายรถ" },
|
||||
{ href: "/about", label: "เกี่ยวกับเรา" },
|
||||
{ href: "/blog", label: "บ่นไปเรื่อย" },
|
||||
{ href: "/credits", label: "เครดิต" },
|
||||
{ href: "/", key: "nav.home" },
|
||||
{ href: "/stops", key: "nav.stops" },
|
||||
{ href: "/routes", key: "nav.routes" },
|
||||
{ href: "/about", key: "nav.about" },
|
||||
{ href: "/blog", key: "nav.blog" },
|
||||
{ href: "/credits", key: "nav.credits" },
|
||||
];
|
||||
|
||||
export async function Footer() {
|
||||
const h = await headers();
|
||||
const lang = langFromCookie(h.get("cookie"));
|
||||
const T = (k: string, v?: Record<string, string | number>) => t(k, lang, v);
|
||||
let visits: number | null = null;
|
||||
try {
|
||||
const s = await api.visitsSummary();
|
||||
@@ -38,39 +43,40 @@ export async function Footer() {
|
||||
<Image src={LOGO} alt="Atroute" width={48} height={48} />
|
||||
<div>
|
||||
<strong>Atroute</strong>
|
||||
<span>สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง</span>
|
||||
<span>{T("brand.subtitle")}</span>
|
||||
</div>
|
||||
</div>
|
||||
<p>
|
||||
ศูนย์รวมข้อมูลตารางเดินรถ จุดจอด และเส้นทางในจังหวัดอ่างทองและจังหวัดใกล้เคียง
|
||||
อัปเดตข้อมูลล่าสุดจากผู้ประกอบการแต่ละสายโดยตรง
|
||||
{lang === "en"
|
||||
? "A hub for bus schedules, stops and routes in Ang Thong and nearby provinces, updated directly by each operator."
|
||||
: "ศูนย์รวมข้อมูลตารางเดินรถ จุดจอด และเส้นทางในจังหวัดอ่างทองและจังหวัดใกล้เคียง อัปเดตข้อมูลล่าสุดจากผู้ประกอบการแต่ละสายโดยตรง"}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="footer__col">
|
||||
<h4>เมนู</h4>
|
||||
<h4>{T("footer.menu")}</h4>
|
||||
<ul>
|
||||
{MENU.map((m) => (
|
||||
<li key={m.href}>
|
||||
<Link href={m.href}>{m.label}</Link>
|
||||
<Link href={m.href}>{T(m.key)}</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div className="footer__col">
|
||||
<h4>สายยอดนิยม</h4>
|
||||
<h4>{T("footer.popular")}</h4>
|
||||
<ul>
|
||||
{popularRoutes.map((r) => (
|
||||
<li key={r.id}>
|
||||
<Link href={`/routes/${r.id}`}>{r.label}</Link>
|
||||
<Link href={`/routes/${r.id}`}>{lang === "en" ? r.label_en : r.label_th}</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div className="footer__col footer__contact">
|
||||
<h4>ติดต่อ</h4>
|
||||
<h4>{T("footer.contact")}</h4>
|
||||
<div className="row"><a href="tel:+66649639025"><Icon name="phone" className="icon" /> 064 963 9025</a></div>
|
||||
<div className="row"><span><Icon name="map-pin" className="icon" /> ถนนเทศบาล 1 อ.เมือง อ่างทอง</span></div>
|
||||
<div className="row"><span><Icon name="clock" className="icon" /> บริการ 04:30 - 21:00 น.</span></div>
|
||||
@@ -78,9 +84,9 @@ export async function Footer() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section className="footer__sponsors" aria-label="ผู้สนับสนุน">
|
||||
<h4>ผู้สนับสนุน & พาร์ทเนอร์</h4>
|
||||
<p className="lead">จองตั๋ว · สั่งของ · เช็กของฝาก ที่ร้านค้าและบริการพันธมิตรของเรา</p>
|
||||
<section className="footer__sponsors" aria-label={T("footer.sponsors")}>
|
||||
<h4>{T("footer.sponsors")}</h4>
|
||||
<p className="lead">{T("footer.sponsorsLead")}</p>
|
||||
<div className="sponsor-strip">
|
||||
{PARTNERS.map((p) => (
|
||||
<span
|
||||
@@ -96,9 +102,9 @@ export async function Footer() {
|
||||
</section>
|
||||
|
||||
<div className="footer__bottom">
|
||||
<p>© {new Date().getFullYear()} Atroute <span className="pill">สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง</span></p>
|
||||
<span className="footer__visitor" title="จำนวนผู้เข้าชมเว็บไซต์">
|
||||
<Icon name="globe" size={14} className="icon" /> ผู้เข้าชม{" "}
|
||||
<p>© {new Date().getFullYear()} Atroute <span className="pill">{T("brand.subtitle")}</span></p>
|
||||
<span className="footer__visitor" title={lang === "en" ? "Site visitors" : "จำนวนผู้เข้าชมเว็บไซต์"}>
|
||||
<Icon name="globe" size={14} className="icon" /> {lang === "en" ? "Visitors" : "ผู้เข้าชม"}{" "}
|
||||
<strong>{visits != null ? visits.toLocaleString("th-TH") : "—"}</strong>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -1,34 +1,9 @@
|
||||
"use client";
|
||||
import Link from "next/link";
|
||||
import Image from "next/image";
|
||||
import { useEffect, useState } from "react";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { LOGO } from "@/lib/images";
|
||||
|
||||
type Lang = "th" | "en";
|
||||
|
||||
const STRINGS: Record<Lang, Record<string, string>> = {
|
||||
th: {
|
||||
"nav.home": "หน้าแรก",
|
||||
"nav.stops": "ป้ายหยุดรถ",
|
||||
"nav.routes": "รายละเอียดสายรถ",
|
||||
"nav.about": "เกี่ยวกับเรา",
|
||||
"nav.blog": "บ่นไปเรื่อย",
|
||||
"nav.credits": "เครดิต",
|
||||
"brand.subtitle": "สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง",
|
||||
"cta": "เช็กเวลาเดินรถ",
|
||||
},
|
||||
en: {
|
||||
"nav.home": "Home",
|
||||
"nav.stops": "Bus Stops",
|
||||
"nav.routes": "Route Details",
|
||||
"nav.about": "About",
|
||||
"nav.blog": "Blog",
|
||||
"nav.credits": "Credits",
|
||||
"brand.subtitle": "Ang Thong Passenger Bus Terminal",
|
||||
"cta": "Check schedule",
|
||||
},
|
||||
};
|
||||
import { useLang } from "@/components/LangProvider";
|
||||
|
||||
const links = [
|
||||
{ href: "/", key: "nav.home" },
|
||||
@@ -41,26 +16,7 @@ const links = [
|
||||
|
||||
export function Header() {
|
||||
const pathname = usePathname();
|
||||
const [lang, setLang] = useState<Lang>("th");
|
||||
|
||||
useEffect(() => {
|
||||
const saved = localStorage.getItem("lang");
|
||||
if (saved === "en" || saved === "th") setLang(saved);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
document.documentElement.lang = lang;
|
||||
}, [lang]);
|
||||
|
||||
const toggleLang = () => {
|
||||
setLang((prev) => {
|
||||
const next: Lang = prev === "th" ? "en" : "th";
|
||||
localStorage.setItem("lang", next);
|
||||
return next;
|
||||
});
|
||||
};
|
||||
|
||||
const t = (key: string) => STRINGS[lang][key] ?? key;
|
||||
const { lang, toggle, t } = useLang();
|
||||
const isActive = (href: string) =>
|
||||
href === "/" ? pathname === "/" : pathname.startsWith(href);
|
||||
|
||||
@@ -92,14 +48,14 @@ export function Header() {
|
||||
<button
|
||||
type="button"
|
||||
className="lang-switch"
|
||||
onClick={toggleLang}
|
||||
onClick={toggle}
|
||||
aria-label="สลับภาษา / Switch language"
|
||||
>
|
||||
<span className={lang === "th" ? "on" : ""}>ไทย</span>
|
||||
<span className="sep">/</span>
|
||||
<span className={lang === "en" ? "on" : ""}>EN</span>
|
||||
</button>
|
||||
<Link href="/check" className="cta-pill">{t("cta")}</Link>
|
||||
<Link href="/check" className="cta-pill">{t("cta.check")}</Link>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -4,6 +4,7 @@ import Link from "next/link";
|
||||
import { useMemo, useState } from "react";
|
||||
import { Icon } from "@/components/Icons";
|
||||
import { HERO_MAP, PARTNERS } from "@/lib/images";
|
||||
import { useLang } from "@/components/LangProvider";
|
||||
import type { RouteGroup, RouteListItem, Province, StopListItem } from "@/lib/api";
|
||||
|
||||
const ZONE_TONES: Record<string, "sky" | "purple" | "pink" | "mint"> = {
|
||||
@@ -12,19 +13,25 @@ const ZONE_TONES: Record<string, "sky" | "purple" | "pink" | "mint"> = {
|
||||
in_province: "pink",
|
||||
municipal: "mint",
|
||||
};
|
||||
const ZONE_DESCS: Record<string, string> = {
|
||||
bangkok: "เส้นทางเชื่อมต่อกรุงเทพมหานคร",
|
||||
interprovincial: "เส้นทางเชื่อมต่อจังหวัดใกล้เคียง",
|
||||
in_province: "เส้นทางภายในจังหวัดอ่างทอง",
|
||||
municipal: "เส้นทางภายในเขตเทศบาล",
|
||||
const ZONE_TAG_KEY: Record<string, string> = {
|
||||
bangkok: "zone.bangkok",
|
||||
interprovincial: "zone.interprov",
|
||||
in_province: "zone.inprov",
|
||||
municipal: "zone.municipal",
|
||||
};
|
||||
const ZONE_DESC_KEY: Record<string, string> = {
|
||||
bangkok: "zone.bangkokDesc",
|
||||
interprovincial: "zone.interprovDesc",
|
||||
in_province: "zone.inprovDesc",
|
||||
municipal: "zone.municipalDesc",
|
||||
};
|
||||
const ZONE_ORDER = ["municipal", "bangkok", "interprovincial", "in_province"];
|
||||
const LEGEND = [
|
||||
{ tone: "sky", label: "หมวดเส้นทางเข้ากรุงเทพฯ — การ์ดสีน้ำเงิน" },
|
||||
{ tone: "purple", label: "หมวดเส้นทางระหว่างจังหวัด — การ์ดสีม่วง" },
|
||||
{ tone: "pink", label: "หมวดเส้นทางภายในจังหวัด — การ์ดสีชมพู" },
|
||||
{ tone: "mint", label: "หมวดเส้นทางภายในเทศบาล — การ์ดสีเขียวมินต์" },
|
||||
{ tone: "gray", label: "ยังไม่มีข้อมูล — การ์ดสีเทา แสดง N/A แทนเลขสาย" },
|
||||
const LEGEND_KEYS = [
|
||||
{ tone: "sky", key: "legend.bangkok" },
|
||||
{ tone: "purple", key: "legend.interprov" },
|
||||
{ tone: "pink", key: "legend.inprov" },
|
||||
{ tone: "mint", key: "legend.municipal" },
|
||||
{ tone: "gray", key: "legend.empty" },
|
||||
];
|
||||
const CHIP_CYCLE = ["purple", "sky", "pink", "mint"] as const;
|
||||
const DEFAULT_PROVINCE_NAME = "อ่างทอง";
|
||||
@@ -60,6 +67,7 @@ export default function HomeClient({
|
||||
initialProvinceId,
|
||||
initialStationCode,
|
||||
}: Props) {
|
||||
const { t } = useLang();
|
||||
const defaultProvince =
|
||||
provinces.find((p) => p.name_th === DEFAULT_PROVINCE_NAME) ?? provinces[0];
|
||||
|
||||
@@ -122,14 +130,15 @@ export default function HomeClient({
|
||||
const url = `${location.origin}/${params.size ? "?" + params.toString() : ""}`;
|
||||
try {
|
||||
await navigator.clipboard.writeText(url);
|
||||
alert("คัดลอกลิงก์แล้ว: " + url);
|
||||
alert(`${t("share.label")}: ${url}`);
|
||||
} catch {
|
||||
prompt("คัดลอกลิงก์:", url);
|
||||
prompt(t("share.label"), url);
|
||||
}
|
||||
};
|
||||
|
||||
const heroProvinceLabel =
|
||||
provinceName && provinceName !== "กรุงเทพมหานคร" ? `จังหวัด${provinceName}` : provinceName;
|
||||
const heroProvince = t("home.provincePrefix")
|
||||
? `${t("home.provincePrefix")}${provinceName}`
|
||||
: provinceName;
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -139,18 +148,17 @@ export default function HomeClient({
|
||||
<div className="hero__blob two" aria-hidden />
|
||||
<div className="hero__blob three" aria-hidden />
|
||||
<div className="container hero__inner">
|
||||
<span className="hero__badge">ยินดีต้อนรับ</span>
|
||||
<span className="hero__badge">{t("home.welcome")}</span>
|
||||
<h1>
|
||||
สถานีขนส่งผู้โดยสารภายใน
|
||||
{t("home.title1")}
|
||||
<br />
|
||||
<span className="hero__grad">{heroProvinceLabel}</span>
|
||||
<span className="hero__grad">{heroProvince}</span>
|
||||
</h1>
|
||||
|
||||
{/* ตัวเลือกระดับ จังหวัด → สถานีขนส่ง (จาก design) */}
|
||||
<div className="route-selector">
|
||||
<div className="select-field">
|
||||
<label htmlFor="province-select">
|
||||
<Icon name="map-pin" size={15} /> เลือกจังหวัด
|
||||
<Icon name="map-pin" size={15} /> {t("home.chooseProvince")}
|
||||
</label>
|
||||
<div className="select-box">
|
||||
<Icon name="map-pin" size={20} className="select-box__icon" />
|
||||
@@ -178,7 +186,7 @@ export default function HomeClient({
|
||||
|
||||
<div className="select-field">
|
||||
<label htmlFor="station-select">
|
||||
<Icon name="bus" size={15} /> สถานีขนส่งผู้โดยสาร
|
||||
<Icon name="bus" size={15} /> {t("home.chooseStation")}
|
||||
</label>
|
||||
<div className="select-box">
|
||||
<Icon name="bus" size={20} className="select-box__icon" />
|
||||
@@ -198,20 +206,18 @@ export default function HomeClient({
|
||||
</div>
|
||||
</div>
|
||||
<p className="select-hint" aria-live="polite">
|
||||
{stationCode
|
||||
? "แสดงเส้นทางที่ผ่านสถานีที่เลือก"
|
||||
: stationsInProvince.length > 0
|
||||
? `${stationsInProvince.length} สถานีใน${heroProvinceLabel}`
|
||||
: "ยังไม่มีสถานีในจังหวัดนี้"}
|
||||
{stationsInProvince.length > 0
|
||||
? t("home.stationCount", { n: stationsInProvince.length })
|
||||
: t("home.stationEmpty")}
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* ผู้สนับสนุน & พาร์ทเนอร์ (marquee) */}
|
||||
<section className="sponsor-section" aria-label="ผู้สนับสนุนและพาร์ทเนอร์">
|
||||
<section className="sponsor-section" aria-label={t("footer.sponsors")}>
|
||||
<div className="sponsor-section__head">
|
||||
<h4>ผู้สนับสนุน & พาร์ทเนอร์</h4>
|
||||
<p>ร่วมเป็นผู้สนับสนุนเราได้ เมื่อซื้อของออนไลน์ หรือซื้อตั๋วรถทัวร์ เครื่องบิน ออนไลน์</p>
|
||||
<h4>{t("footer.sponsors")}</h4>
|
||||
<p>{t("footer.sponsorsLead")}</p>
|
||||
</div>
|
||||
<div className="marquee">
|
||||
<div className="marquee__track">
|
||||
@@ -227,13 +233,13 @@ export default function HomeClient({
|
||||
<main className="main">
|
||||
<div className="container">
|
||||
{/* Legend */}
|
||||
<section className="legend" aria-label="คำอธิบายสีการ์ดตามหมวดเส้นทาง">
|
||||
<h2 className="legend__title">คำอธิบายสีการ์ดตามหมวดเส้นทาง</h2>
|
||||
<section className="legend" aria-label={t("legend.title")}>
|
||||
<h2 className="legend__title">{t("legend.title")}</h2>
|
||||
<ul className="legend__list">
|
||||
{LEGEND.map((l) => (
|
||||
{LEGEND_KEYS.map((l) => (
|
||||
<li key={l.tone}>
|
||||
<span className={`legend__sw legend__sw--${l.tone}`} aria-hidden />
|
||||
{l.label}
|
||||
{t(l.key)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
@@ -245,9 +251,11 @@ export default function HomeClient({
|
||||
return (
|
||||
<section key={g.id} className="zone">
|
||||
<div className="zone__head">
|
||||
<span className={`zone__tag ${tone}`}>{g.label_th}</span>
|
||||
<span className={`zone__tag ${tone}`}>
|
||||
{t(ZONE_TAG_KEY[g.code] ?? "") || g.label_th}
|
||||
</span>
|
||||
<p className="zone__desc">
|
||||
{ZONE_DESCS[g.code] ?? ""} · {items.length} เส้นทาง
|
||||
{t(ZONE_DESC_KEY[g.code] ?? "")} · {items.length}
|
||||
</p>
|
||||
</div>
|
||||
<div className="grid">
|
||||
@@ -257,9 +265,9 @@ export default function HomeClient({
|
||||
<p className="card__num">N/A</p>
|
||||
</div>
|
||||
<div className="card__body">
|
||||
<p className="card__name">ยังไม่มีข้อมูลเส้นทาง</p>
|
||||
<p className="card__name">{t("zone.municipalNA")}</p>
|
||||
<span className="chip gray">
|
||||
<Icon name="hourglass" size={12} className="icon" /> ยังไม่มีตาราง
|
||||
<Icon name="hourglass" size={12} className="icon" /> {t("card.noSchedule")}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -281,15 +289,15 @@ export default function HomeClient({
|
||||
<p className="card__name">{r.name_th}</p>
|
||||
{next ? (
|
||||
<span className={`chip ${chipTone}`}>
|
||||
<Icon name="clock" size={12} className="icon" /> เที่ยวถัดไป {next}
|
||||
<Icon name="clock" size={12} className="icon" /> {t("card.nextTrip")} {next}
|
||||
</span>
|
||||
) : times.length > 0 ? (
|
||||
<span className={`chip ${chipTone}`}>
|
||||
<Icon name="check" size={12} className="icon" /> ดูตาราง
|
||||
<Icon name="check" size={12} className="icon" /> {t("card.schedule")}
|
||||
</span>
|
||||
) : (
|
||||
<span className="chip gray">
|
||||
<Icon name="hourglass" size={12} className="icon" /> ยังไม่มีตาราง
|
||||
<Icon name="hourglass" size={12} className="icon" /> {t("card.noSchedule")}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
@@ -305,7 +313,7 @@ export default function HomeClient({
|
||||
{/* ปุ่มแชร์ลิงก์สั้น */}
|
||||
<div className="share-row">
|
||||
<button type="button" className="share-btn" onClick={share}>
|
||||
<Icon name="arrow-right" size={16} /> แชร์ลิงก์สั้น
|
||||
<Icon name="arrow-right" size={16} /> {t("share.label")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
"use client";
|
||||
|
||||
import { createContext, useContext, useEffect, useState, type ReactNode } from "react";
|
||||
import { t, type Lang } from "@/lib/i18n";
|
||||
|
||||
type Ctx = {
|
||||
lang: Lang;
|
||||
setLang: (l: Lang) => void;
|
||||
toggle: () => void;
|
||||
t: (key: string, vars?: Record<string, string | number>) => string;
|
||||
};
|
||||
|
||||
const LangCtx = createContext<Ctx>({
|
||||
lang: "th",
|
||||
setLang: () => {},
|
||||
toggle: () => {},
|
||||
t: (k) => k,
|
||||
});
|
||||
|
||||
export function LangProvider({ children, initial }: { children: ReactNode; initial: Lang }) {
|
||||
const [lang, setLangState] = useState<Lang>(initial);
|
||||
|
||||
const setLang = (l: Lang) => {
|
||||
setLangState(l);
|
||||
try {
|
||||
localStorage.setItem("lang", l);
|
||||
} catch {}
|
||||
document.cookie = `lang=${l}; path=/; max-age=31536000; SameSite=Lax`;
|
||||
document.documentElement.lang = l === "th" ? "th" : "en";
|
||||
};
|
||||
|
||||
const toggle = () => setLang(lang === "th" ? "en" : "th");
|
||||
|
||||
useEffect(() => {
|
||||
let saved: Lang | null = null;
|
||||
try {
|
||||
const v = localStorage.getItem("lang");
|
||||
if (v === "th" || v === "en") saved = v;
|
||||
} catch {}
|
||||
if (saved && saved !== lang) {
|
||||
setLangState(saved);
|
||||
document.documentElement.lang = saved === "th" ? "th" : "en";
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<LangCtx.Provider
|
||||
value={{ lang, setLang, toggle, t: (k, v) => t(k, lang, v) }}
|
||||
>
|
||||
{children}
|
||||
</LangCtx.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export const useLang = () => useContext(LangCtx);
|
||||
@@ -0,0 +1,177 @@
|
||||
"use client";
|
||||
|
||||
import { useMemo, useState } from "react";
|
||||
import { allBusStops, findBusStopByCode, nearestBusStops, type BusStop } from "@/lib/busstops";
|
||||
import { Icon } from "@/components/Icons";
|
||||
import { useLang } from "@/components/LangProvider";
|
||||
|
||||
type Mode = "code" | "place";
|
||||
|
||||
function BusStopCard({ stop, distM }: { stop: BusStop; distM?: number }) {
|
||||
const { lang } = useLang();
|
||||
return (
|
||||
<div className="busstop-result">
|
||||
<div className="busstop-result__head">
|
||||
<span className="busstop-result__km">{stop.kilometer}</span>
|
||||
<span className="busstop-result__name">{stop.route_name}</span>
|
||||
{distM != null && (
|
||||
<span className="busstop-result__dist">
|
||||
{distM < 1000 ? `${Math.round(distM)} m` : `${(distM / 1000).toFixed(1)} km`}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<p className="busstop-result__meta">
|
||||
{stop.position} · {stop.type}
|
||||
</p>
|
||||
{(stop["buses-line"] ?? []).length > 0 && (
|
||||
<div className="busstop-result__chips">
|
||||
{(stop["buses-line"] ?? []).map((r) => (
|
||||
<span key={r} className="chip-soft chip-soft--purple">{lang === "en" ? "Route" : "สาย"} {r}</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function StopSearch() {
|
||||
const { t, lang } = useLang();
|
||||
const [mode, setMode] = useState<Mode>("code");
|
||||
const [code, setCode] = useState("");
|
||||
const [query, setQuery] = useState("");
|
||||
const [nearby, setNearby] = useState<{ stop: BusStop; distM: number }[] | null>(null);
|
||||
const [geoErr, setGeoErr] = useState(false);
|
||||
|
||||
const pad = (d: string) => {
|
||||
if (code.length >= 5) return;
|
||||
setCode(code + d);
|
||||
setNearby(null);
|
||||
};
|
||||
const backspace = () => setCode(code.slice(0, -1));
|
||||
const clearAll = () => {
|
||||
setCode("");
|
||||
setQuery("");
|
||||
setNearby(null);
|
||||
setGeoErr(false);
|
||||
};
|
||||
|
||||
const codeResult = code.length === 5 ? findBusStopByCode(code) : undefined;
|
||||
|
||||
const placeResults = useMemo(() => {
|
||||
const q = query.trim();
|
||||
if (q.length < 2) return [];
|
||||
return allBusStops()
|
||||
.filter(
|
||||
(b) =>
|
||||
b.route_name.includes(q) || b.type.includes(q) || b.position.includes(q),
|
||||
)
|
||||
.slice(0, 20);
|
||||
}, [query]);
|
||||
|
||||
const nearMe = () => {
|
||||
if (typeof navigator === "undefined" || !navigator.geolocation) {
|
||||
setGeoErr(true);
|
||||
return;
|
||||
}
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
(pos) => setNearby(nearestBusStops(pos.coords.latitude, pos.coords.longitude, 8)),
|
||||
() => setGeoErr(true),
|
||||
{ timeout: 10000 },
|
||||
);
|
||||
};
|
||||
|
||||
const N = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
|
||||
|
||||
return (
|
||||
<div className="stop-search">
|
||||
<div className="stop-search__tabs" role="tablist" aria-label="รูปแบบการค้นหา">
|
||||
<button
|
||||
type="button"
|
||||
className={`stop-search__tab ${mode === "code" ? "on" : ""}`}
|
||||
onClick={() => setMode("code")}
|
||||
>
|
||||
<Icon name="map-pin" size={14} className="icon" /> {t("stops.modeCode")}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={`stop-search__tab ${mode === "place" ? "on" : ""}`}
|
||||
onClick={() => setMode("place")}
|
||||
>
|
||||
<Icon name="search" size={14} className="icon" /> {t("stops.modePlace")}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{mode === "code" ? (
|
||||
<div className="stop-search__panel">
|
||||
<div className="code-boxes" aria-label={t("stops.codePh")}>
|
||||
{[0, 1, 2, 3, 4].map((i) => (
|
||||
<span key={i} className={`code-cell ${i < code.length ? "filled" : ""}`}>
|
||||
{code[i] ?? ""}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
<div className="numpad">
|
||||
{N.map((n) => (
|
||||
<button key={n} type="button" onClick={() => pad(String(n))}>
|
||||
{n}
|
||||
</button>
|
||||
))}
|
||||
<button type="button" onClick={backspace} aria-label={t("stops.padDelete")}>
|
||||
<Icon name="arrow-right" size={16} className="icon" style={{ transform: "rotate(180deg)" }} />
|
||||
</button>
|
||||
</div>
|
||||
<div className="stop-search__actions">
|
||||
<button type="button" className="mu-btn ghost" onClick={clearAll}>
|
||||
{t("stops.reset")}
|
||||
</button>
|
||||
<button type="button" className="mu-btn ghost" onClick={nearMe}>
|
||||
<Icon name="map-pin" size={14} className="icon" /> {t("map.useMyLocation")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="stop-search__panel">
|
||||
<div className="stop-search__field">
|
||||
<Icon name="search" size={16} className="icon" />
|
||||
<input
|
||||
type="search"
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
placeholder={t("stops.searchPh")}
|
||||
/>
|
||||
</div>
|
||||
{placeResults.length > 0 && (
|
||||
<ul className="stop-search__suggest">
|
||||
{placeResults.map((b, i) => (
|
||||
<li key={`${b.kilometer}-${i}`}>
|
||||
<button type="button" onClick={() => setCode(b.kilometer.replace("+", ""))}>
|
||||
<span className="km">{b.kilometer}</span>
|
||||
<span className="name">{b.route_name}</span>
|
||||
<span className="meta">{b.position}</span>
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{geoErr && (
|
||||
<p className="stop-search__err">
|
||||
{lang === "en" ? "Cannot access your location." : "ไม่สามารถเข้าถึงตำแหน่งของคุณได้"}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{codeResult && <BusStopCard stop={codeResult} />}
|
||||
|
||||
{nearby && nearby.length > 0 && (
|
||||
<div className="stop-search__nearby">
|
||||
<h3>{t("map.nearestTitle")}</h3>
|
||||
{nearby.map((n, i) => (
|
||||
<BusStopCard key={`${n.stop.kilometer}-${i}`} stop={n.stop} distM={n.distM} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
{
|
||||
"brand.subtitle": "Ang Thong Provincial Bus Terminal",
|
||||
"nav.home": "Home",
|
||||
"nav.stops": "Bus Stops",
|
||||
"nav.routes": "Route Details",
|
||||
"nav.credits": "Credits",
|
||||
"nav.about": "About",
|
||||
"nav.blog": "Blog",
|
||||
"about.title": "About Us",
|
||||
"about.brand": "When will the bus come?",
|
||||
"about.lead": "Our story — read through the blocks below.",
|
||||
"blog.title": "Blog",
|
||||
"blog.subtitle": "News & travel know-how",
|
||||
"blog.lead": "Route news, timetable updates and useful tips — switch between grid and list view.",
|
||||
"blog.viewGrid": "Grid",
|
||||
"blog.viewList": "List",
|
||||
"blog.count": "All posts",
|
||||
"blog.items": "posts",
|
||||
"blog.minRead": "min read",
|
||||
"blog.readMore": "Read more",
|
||||
"blog.backList": "Back to all posts",
|
||||
"blog.empty": "No posts yet — add files under ui/partials/blog-data/",
|
||||
"blog.notFound": "Post not found",
|
||||
"blog.noGeo": "Route geometry not available yet",
|
||||
"blog.mapPick": "Tap a route on the map, or a row above, to see details",
|
||||
"blog.mapNoOrigin": "Origin coordinates not found — check station_code under \"map\"",
|
||||
"blog.mapNoRoutes": "No routes yet — add them under \"map\" → \"routes\"",
|
||||
"blog.mapNoCoord": "No coordinates yet",
|
||||
"blog.mapDest": "Destination",
|
||||
"blog.mapVia": "Via",
|
||||
"blog.mapNote": "Note",
|
||||
"blog.km": "km",
|
||||
"blog.min": "min",
|
||||
"blog.thb": "THB",
|
||||
"legend.title": "Card colours by route group",
|
||||
"legend.bangkok": "Bangkok routes — blue card",
|
||||
"legend.interprov": "Inter-provincial routes — purple card",
|
||||
"legend.inprov": "In-province routes — pink card",
|
||||
"legend.municipal": "Municipal routes — light yellow card",
|
||||
"legend.empty": "No data yet — grey card showing N/A instead of a route number",
|
||||
"legend.note": "Ang Thong has no group 1 (municipal) services yet, so the card is grey and shows N/A in place of the route number",
|
||||
"zone.municipal": "Municipal routes",
|
||||
"zone.municipalDesc": "Routes inside municipal areas",
|
||||
"zone.municipalNA": "No municipal routes in Ang Thong yet",
|
||||
"card.noData": "No data yet",
|
||||
"route.mapDesc": "Real geometry from our GIS data · stops along the route",
|
||||
"map.origin": "Origin",
|
||||
"map.destination": "Destination",
|
||||
"map.offline": "Offline — route only",
|
||||
"map.empty": "No route geometry for this service yet",
|
||||
"map.legendRoute": "Route",
|
||||
"map.legendStop": "Bus stop",
|
||||
"map.legendTerminal": "Bus terminal",
|
||||
"map.subStop": "Boarding point (sub-stop)",
|
||||
"map.viewBoardingPoints": "See boarding points for this route",
|
||||
"map.legendSubStop": "Boarding point (sub-stop)",
|
||||
"map.route": "Route",
|
||||
"map.noStationPin": "stop coordinates not in the system yet — showing serving routes",
|
||||
"map.captionRoute": "Route length {km} km · {n} stops along the route",
|
||||
"map.captionStop": "Routes serving this stop: {r} · {n} stops along the route",
|
||||
"map.stations": "terminals along route",
|
||||
"map.stationPinned": "stop location pinned on the map",
|
||||
"map.thisStop": "the stop you are viewing",
|
||||
"map.legendHere": "This stop",
|
||||
"map.noRoutesHere": "No routes recorded for this stop yet",
|
||||
"map.servedBy": "Routes served",
|
||||
"map.openInMaps": "Open in Google Maps",
|
||||
"map.viewStopPage": "View this stop",
|
||||
"map.km": "km",
|
||||
"map.offRoute": "off route",
|
||||
"map.alongRoute": "Stops along the route (km from origin)",
|
||||
"map.useMyLocation": "Stops near me",
|
||||
"map.locating": "Finding your location…",
|
||||
"map.geoDenied": "Location permission denied — allow it in your browser and try again",
|
||||
"map.noGeo": "This browser does not support geolocation",
|
||||
"map.nearestTitle": "Stops closest to you",
|
||||
"map.youAreHere": "Your location",
|
||||
"cta.check": "Check Schedules",
|
||||
"footer.menu": "Menu",
|
||||
"footer.popular": "Most Viewed Routes",
|
||||
"footer.popstops": "Popular Stops",
|
||||
"footer.contact": "Contact",
|
||||
"footer.about": "Every bus stop in Ang Thong and nearby provinces — locations and routes served.",
|
||||
"footer.sponsors": "Sponsors & Partners",
|
||||
"footer.sponsorsLead": "Support us at no extra cost: shop online or book bus and flight tickets through our affiliate links — you pay nothing more.",
|
||||
"home.welcome": "Welcome",
|
||||
"home.title1": "Ang Thong Provincial",
|
||||
"home.provincePrefix": "",
|
||||
"home.lead": "Browse routes, find stops, and preview a route right from this page",
|
||||
"home.chooseProvince": "Select Province",
|
||||
"home.chooseStation": "Select Terminal",
|
||||
"share.label": "Share short link",
|
||||
"share.copied": "Link copied",
|
||||
"share.short": "Short link",
|
||||
"share.line": "Share on LINE",
|
||||
"home.stationEmpty": "— No terminals in this province —",
|
||||
"home.stationEmptyHint": "No bus terminal in",
|
||||
"home.stationCount": "<b>{n}</b> terminals in",
|
||||
"zone.bangkok": "To Bangkok",
|
||||
"zone.bangkokDesc": "Routes to Bangkok",
|
||||
"zone.interprov": "Inter-province",
|
||||
"zone.interprovDesc": "Routes to nearby provinces",
|
||||
"zone.inprov": "Within Ang Thong",
|
||||
"zone.inprovDesc": "Routes inside Ang Thong",
|
||||
"card.schedule": "Schedule",
|
||||
"card.nextTrip": "Next trip",
|
||||
"card.noSchedule": "No schedule",
|
||||
"stops.title": "Find bus stops quickly and easily",
|
||||
"stops.subtitle": "All major terminals, local stops, van stations and private stops — mobile and desktop friendly",
|
||||
"stops.kpi.total": "Total stops",
|
||||
"stops.kpi.coverage": "Coverage",
|
||||
"stops.kpi.types": "Main types",
|
||||
"stops.kpi.routes": "Popular departures",
|
||||
"stops.searchPh": "Search a place, e.g. Ang Thong terminal",
|
||||
"stops.filterProvince": "Filter by province",
|
||||
"stops.allProvinces": "All provinces",
|
||||
"stops.allTypes": "All types",
|
||||
"stops.mapTitle": "Stop network map",
|
||||
"stops.onMap": "On map",
|
||||
"stops.kpi.places": "Key places",
|
||||
"stops.kpi.buses": "Busiest bus line",
|
||||
"stops.unitPoints": "stops",
|
||||
"stops.unitPlaces": "places",
|
||||
"stops.unitTypes": "types",
|
||||
"stops.unitRoutes": "highways",
|
||||
"stops.highway": "Highway",
|
||||
"stops.busPrefix": "Route",
|
||||
"stops.viewSchedule": "View schedule for route {n}",
|
||||
"stops.viewRoute": "View route {n}",
|
||||
"stops.subStop": "Boarding point (sub-stop)",
|
||||
"stops.noOffset": "No travel time from the first stop yet",
|
||||
"stops.noBusLine": "No bus line listed",
|
||||
"stops.modeCode": "Search by stop code",
|
||||
"stops.modePlace": "Search by place name",
|
||||
"stops.codePh": "3+000",
|
||||
"stops.codeHint": "Type 4 digits and the + sign is added automatically (e.g. 3000 → 3+000)",
|
||||
"stops.codeHintBox": "Type digits in the boxes — empty boxes are filled with 0 automatically. For 4-digit codes such as 8+591, enter 08+591",
|
||||
"stops.codeFull": "Stop code:",
|
||||
"stops.placePh": "Ang Thong Hospital",
|
||||
"stops.placeHint": "Type a place name such as a hospital or land office, then pick a match",
|
||||
"stops.padDelete": "Del",
|
||||
"stops.reset": "Clear",
|
||||
"stops.section": "Section",
|
||||
"stops.showing": "Showing {a} of {b} stops",
|
||||
"stops.showAll": "Show all stops",
|
||||
"stops.noResult": "No stops match your search",
|
||||
"stops.loading": "Loading stop data…",
|
||||
"type.terminal": "Passenger terminal",
|
||||
"type.station": "Major stop",
|
||||
"type.pickup": "Pickup point",
|
||||
"type.market": "Market / community",
|
||||
"type.landmark": "Landmark",
|
||||
"route.badge": "Inter-province route",
|
||||
"route.kpiProvince": "provinces",
|
||||
"route.kpiStops": "stops",
|
||||
"route.kpiTrips": "trips",
|
||||
"route.overview": "Route overview",
|
||||
"route.contact": "Contact operator",
|
||||
"route.call": "Call us",
|
||||
"route.openLink": "Open link",
|
||||
"route.zoomQr": "Enlarge QR to scan",
|
||||
"route.copyLink": "Copy link",
|
||||
"route.copied": "Copied",
|
||||
"common.close": "Close",
|
||||
"route.link.facebook": "Facebook",
|
||||
"route.link.line": "LINE Official",
|
||||
"route.link.www": "Website",
|
||||
"route.vehicle": "Route vehicle",
|
||||
"route.mapTitle": "Route map",
|
||||
"route.photos": "Buses on this network",
|
||||
"route.stopsTitle": "Stops along the route",
|
||||
"route.scheduleTitle": "Schedule",
|
||||
"route.selectRoute": "Select route",
|
||||
"route.selectStation": "Select station",
|
||||
"route.origin": "Origin",
|
||||
"route.transfer": "Intermediate stop",
|
||||
"route.intermediate": "Intermediate stop",
|
||||
"route.pass": "Passing",
|
||||
"route.destination": "Destination",
|
||||
"route.direction": "All directions",
|
||||
"route.empty": "No schedule data yet",
|
||||
"route.noSchedule": "— No trips yet —",
|
||||
"route.seeOther": "Other routes",
|
||||
"stop.code": "Code:",
|
||||
"stop.nearby": "Nearby",
|
||||
"stop.routes": "Routes through this stop",
|
||||
"stop.searchRoute": "Search route or destination",
|
||||
"stop.showing": "Showing {a} of {b} routes",
|
||||
"stop.mapInfo": "Map & stop info",
|
||||
"stop.nextArrival": "Next arrival",
|
||||
"stop.subGeneric": "A stop in {city} · see every route that passes here on one page",
|
||||
"stop.thisStop": "this stop",
|
||||
"stop.statRoutes": "Routes",
|
||||
"stop.statTrips": "Departures/day",
|
||||
"stop.statHours": "Service hours",
|
||||
"stop.statType": "Type",
|
||||
"stop.nRoutes": "{n} routes",
|
||||
"stop.tripsPerDay": "{n} trips/day",
|
||||
"stop.tripsPerDay1": "{n} trip/day",
|
||||
"stop.nRoutes1": "{n} route",
|
||||
"stop.noRoutes": "No routes recorded for this stop yet",
|
||||
"stop.noTimes": "No departure times for this stop yet",
|
||||
"stop.tomorrow": "Tomorrow",
|
||||
"stop.nextAt": "Next",
|
||||
"stop.notFound": "Stop not found",
|
||||
"stop.notFoundSub": "No stop with code “{code}” — check the code or go back to the stop list",
|
||||
"stop.nearbySub": "Places of interest and stops to wait for your bus",
|
||||
"stop.otherStopsTitle": "Other boarding points · route {n} ({m} stops)",
|
||||
"stop.otherMore": "(+{n} stops)",
|
||||
"stop.otherStopsAll": "All other boarding points ({m} stops)",
|
||||
"stop.noCoord": "No coordinates yet",
|
||||
"stop.open": "Open",
|
||||
"stop.close": "Close",
|
||||
"stop.nowAtStop": "Current time at this stop",
|
||||
"stop.autoNext": "Next departure is calculated automatically",
|
||||
"common.backHome": "← Back to home",
|
||||
"common.backStops": "← Back to stops",
|
||||
"common.search": "Search",
|
||||
"common.details": "Details",
|
||||
"common.bus": "Bus",
|
||||
"common.phone": "Call:",
|
||||
"common.noWebsite": "No website listed",
|
||||
"type.van": "Van station",
|
||||
"type.local": "Local stop",
|
||||
"type.busstop": "Bus shelter / stop",
|
||||
"type.startlocalpoint": "Local route origin",
|
||||
"type.other": "Other boarding points",
|
||||
"type.marketOpt": "Market / private stop",
|
||||
"route.mapTitleN": "Route {n} map",
|
||||
"stop.viewScheduleN": "View schedule of route {n}",
|
||||
"stop.openRoute": "Open route details",
|
||||
"credits.title": "Credits & Sources",
|
||||
"credits.icons": "Icons — Lucide",
|
||||
"credits.fonts": "Fonts — Google Fonts",
|
||||
"credits.map": "Maps",
|
||||
"credits.photos": "Bus photo credits",
|
||||
"credits.photosNote": "For all routes not listed here, our thanks go out to everyone as well.",
|
||||
"common.back": "Back",
|
||||
"check.scheduleAll": "Departure times at every stop",
|
||||
"check.title": "Departure Schedule",
|
||||
"check.lead": "Pick a route to see every stop’s departures on one page",
|
||||
"check.kpiStops": "Main stops",
|
||||
"check.kpiProvince": "Provinces",
|
||||
"check.kpiTrips": "Trips per day",
|
||||
"check.kpiNext": "Next departure",
|
||||
"check.direction": "Direction",
|
||||
"check.atStop": "Departures at",
|
||||
"check.dayWeekday": "Weekday timetable (Mon–Fri)",
|
||||
"check.dayHoliday": "Weekend/holiday timetable",
|
||||
"check.dayMixed": "This direction mixes weekday and holiday times — not split by day yet",
|
||||
"check.dayUnknown": "Timetable day not specified (showing all days)",
|
||||
"check.dayOfWeek": "today is",
|
||||
"time.estimated": "~ Estimated from the origin (not an operator timetable)",
|
||||
"time.derived": "~ Computed timetable (from {base} {n} min) — may change with real traffic conditions",
|
||||
"check.now": "Current time",
|
||||
"check.updatedAgo": "Last updated {ago}",
|
||||
"check.agoToday": "today",
|
||||
"check.agoYesterday": "yesterday",
|
||||
"check.agoDays": "{n} days ago",
|
||||
"check.agoWeeks": "{n} weeks ago",
|
||||
"check.agoMonths": "{n} months ago",
|
||||
"check.agoYears": "{y} years ago",
|
||||
"check.agoYearsMonths": "{y} years {m} months ago",
|
||||
"check.nextAt": "Next departure",
|
||||
"check.noMoreToday": "No departures left today",
|
||||
"check.stopsCount": "stops",
|
||||
"check.toStopDetail": "View stop detail",
|
||||
"common.routes": "routes"
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
{
|
||||
"brand.subtitle": "สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง",
|
||||
"nav.home": "หน้าแรก",
|
||||
"nav.stops": "ป้ายหยุดรถ",
|
||||
"nav.routes": "รายละเอียดสายรถ",
|
||||
"nav.credits": "เครดิต",
|
||||
"nav.about": "เกี่ยวกับเรา",
|
||||
"nav.blog": "บ่นไปเรื่อย",
|
||||
"about.title": "เกี่ยวกับเรา",
|
||||
"about.brand": "เมื่อไหร่รถจะมา",
|
||||
"about.lead": "เรื่องราวและที่มาของเว็บนี้ — อ่านเรียงตามบล็อกด้านล่างได้เลย",
|
||||
"blog.title": "บ่นไปเรื่อย",
|
||||
"blog.subtitle": "หาอะไรอ่านรอรถ",
|
||||
"blog.lead": "ความรู้สึกผมตั้งแต่รวบรวมข้อมูล ปัญหาที่เจอ บ่นไปเรื่อย",
|
||||
"blog.viewGrid": "ตาราง",
|
||||
"blog.viewList": "รายการ",
|
||||
"blog.count": "บ่นไปเรื่อยทั้งหมด",
|
||||
"blog.items": "เรื่อง",
|
||||
"blog.minRead": "นาที",
|
||||
"blog.readMore": "อ่านต่อ",
|
||||
"blog.backList": "กลับไปรายการบ่นไปเรื่อย",
|
||||
"blog.empty": "ยังไม่มีเรื่องบ่น — เพิ่มไฟล์ใน ui/partials/blog-data/ ได้เลย",
|
||||
"blog.notFound": "ไม่พบเรื่องบ่นนี้",
|
||||
"blog.noGeo": "ยังไม่มีข้อมูลเส้นทางสายนี้",
|
||||
"blog.mapPick": "กดเส้นทางบนแผนที่ หรือแตะรายการด้านบน เพื่อดูรายละเอียด",
|
||||
"blog.mapNoOrigin": "ไม่พบพิกัดต้นทาง — ตรวจ station_code ในคีย์ \"map\"",
|
||||
"blog.mapNoRoutes": "ยังไม่มีเส้นทางในโครง — เพิ่มในคีย์ \"map\" → \"routes\"",
|
||||
"blog.mapNoCoord": "ยังไม่ใส่พิกัด",
|
||||
"blog.mapDest": "ปลายทาง",
|
||||
"blog.mapVia": "ผ่าน",
|
||||
"blog.mapNote": "หมายเหตุ",
|
||||
"blog.km": "กม.",
|
||||
"blog.min": "นาที",
|
||||
"blog.thb": "บาท",
|
||||
"legend.title": "คำอธิบายสีการ์ดตามหมวดเส้นทาง",
|
||||
"legend.bangkok": "หมวดเส้นทางเข้ากรุงเทพฯ — การ์ดสีน้ำเงิน",
|
||||
"legend.interprov": "หมวดเส้นทางระหว่างจังหวัด — การ์ดสีม่วง",
|
||||
"legend.inprov": "หมวดเส้นทางภายในจังหวัด — การ์ดสีชมพู",
|
||||
"legend.municipal": "หมวดเส้นทางภายในเทศบาล — การ์ดสีเหลืองอ่อน",
|
||||
"legend.empty": "ยังไม่มีข้อมูล — การ์ดสีเทา แสดง N/A แทนเลขสาย",
|
||||
"legend.note": "อ่างทองยังไม่มีรถหมวด 1 (เส้นทางภายในเทศบาล) จึงแสดงการ์ดสีเทาและใช้ N/A แทนตัวเลขสายเส้นทาง",
|
||||
"zone.municipal": "หมวดเส้นทางภายในเทศบาล",
|
||||
"zone.municipalDesc": "เส้นทางภายในเขตเทศบาล",
|
||||
"zone.municipalNA": "ยังไม่มีเส้นทางหมวดเทศบาลในอ่างทอง",
|
||||
"card.noData": "ยังไม่มีข้อมูล",
|
||||
"route.mapDesc": "เส้นทางจริงจากข้อมูล GIS · ป้ายหยุดรถตามเส้นทาง",
|
||||
"map.origin": "ต้นทาง",
|
||||
"map.destination": "ปลายทาง",
|
||||
"map.offline": "ออฟไลน์ — แสดงเฉพาะเส้นทาง",
|
||||
"map.empty": "ยังไม่มีข้อมูลเส้นทางสายนี้ในระบบ",
|
||||
"map.legendRoute": "เส้นทาง",
|
||||
"map.legendStop": "ป้ายหยุดรถ",
|
||||
"map.legendTerminal": "สถานีขนส่ง",
|
||||
"map.subStop": "จุดขึ้นรถ (จุดย่อย)",
|
||||
"map.viewBoardingPoints": "ดูจุดขึ้นรถของสายนี้",
|
||||
"map.legendSubStop": "จุดขึ้นรถ (จุดย่อย)",
|
||||
"map.route": "สาย",
|
||||
"map.noStationPin": "พิกัดป้ายนี้ยังไม่มีในระบบ — แสดงเส้นทางที่ผ่าน",
|
||||
"map.captionRoute": "ความยาวเส้นทาง {km} กม. · ป้ายตามเส้นทาง {n} แห่ง",
|
||||
"map.captionStop": "เส้นทางที่ผ่านป้ายนี้ {r} · ป้ายตามเส้นทาง {n} แห่ง",
|
||||
"map.stations": "สถานีขนส่งตามเส้นทาง",
|
||||
"map.stationPinned": "ปักหมุดตำแหน่งป้ายแล้ว",
|
||||
"map.thisStop": "ป้ายที่กำลังดูอยู่",
|
||||
"map.legendHere": "ป้ายที่กำลังดู",
|
||||
"map.noRoutesHere": "ยังไม่มีข้อมูลสายรถที่ผ่านป้ายนี้ในระบบ",
|
||||
"map.servedBy": "สายที่ผ่าน",
|
||||
"map.openInMaps": "เปิดใน Google Maps",
|
||||
"map.viewStopPage": "ดูรายละเอียดป้ายนี้",
|
||||
"map.km": "กม.",
|
||||
"map.offRoute": "นอกเส้นทาง",
|
||||
"map.alongRoute": "จุดจอดตามเส้นทาง (กม. จากต้นทาง)",
|
||||
"map.useMyLocation": "ป้ายใกล้ฉัน",
|
||||
"map.locating": "กำลังหาตำแหน่งของคุณ…",
|
||||
"map.geoDenied": "ไม่ได้รับอนุญาตให้เข้าถึงตำแหน่ง — เปิดสิทธิ์ตำแหน่งในเบราว์เซอร์แล้วลองใหม่",
|
||||
"map.noGeo": "เบราว์เซอร์นี้ไม่รองรับการระบุตำแหน่ง",
|
||||
"map.nearestTitle": "ป้ายที่ใกล้คุณที่สุด",
|
||||
"map.youAreHere": "ตำแหน่งของคุณ",
|
||||
"cta.check": "เช็กเวลาเดินรถ",
|
||||
"footer.menu": "เมนู",
|
||||
"footer.popular": "สายที่เปิดดูบ่อย",
|
||||
"footer.popstops": "ป้ายยอดนิยม",
|
||||
"footer.contact": "ติดต่อ",
|
||||
"footer.about": "รวมป้ายขึ้น-ลงรถทุกจุดในจังหวัดอ่างทองและจังหวัดใกล้เคียง พร้อมตำแหน่งและสายรถที่ผ่าน",
|
||||
"footer.sponsors": "ผู้สนับสนุน & พาร์ทเนอร์",
|
||||
"footer.sponsorsLead": "ร่วมเป็นผู้สนับสนุนเราได้ เมื่อซื้อของออนไลน์ หรือซื้อตั๋วรถทัวร์ เครื่องบิน ออนไลน์กดเลือกสินค้า หรือบริการผ่านลิงค์นายหน้าของเราไม่มีค่าใช้จ่ายเพิ่ม",
|
||||
"home.welcome": "ยินดีต้อนรับ",
|
||||
"home.title1": "สถานีขนส่งผู้โดยสารภายใน",
|
||||
"home.provincePrefix": "จังหวัด",
|
||||
"home.lead": "ดูสายรถ, ค้นหาป้าย และเปิดตัวอย่างเส้นทางได้ทันทีจากหน้าแรก",
|
||||
"home.chooseProvince": "เลือกจังหวัด",
|
||||
"home.chooseStation": "เลือกสถานีขนส่งผู้โดยสาร",
|
||||
"share.label": "แชร์ลิงก์สั้น",
|
||||
"share.copied": "คัดลอกลิงก์แล้ว",
|
||||
"share.short": "ลิงก์สั้น",
|
||||
"share.line": "แชร์ผ่าน LINE",
|
||||
"home.stationEmpty": "— ยังไม่มีสถานีขนส่งในจังหวัดนี้ —",
|
||||
"home.stationEmptyHint": "ยังไม่มีสถานีขนส่งผู้โดยสารในจังหวัด",
|
||||
"home.stationCount": "มี <b>{n}</b> สถานีขนส่งในจังหวัด",
|
||||
"zone.bangkok": "หมวดเส้นทางเข้ากรุงเทพฯ",
|
||||
"zone.bangkokDesc": "เส้นทางเชื่อมต่อกรุงเทพมหานคร",
|
||||
"zone.interprov": "หมวดเส้นทางระหว่างจังหวัด",
|
||||
"zone.interprovDesc": "เส้นทางเชื่อมต่อจังหวัดใกล้เคียง",
|
||||
"zone.inprov": "หมวดเส้นทางภายในจังหวัด",
|
||||
"zone.inprovDesc": "เส้นทางภายในจังหวัดอ่างทอง",
|
||||
"card.schedule": "ดูตาราง",
|
||||
"card.nextTrip": "เที่ยวถัดไป",
|
||||
"card.noSchedule": "ยังไม่มีตาราง",
|
||||
"stops.title": "ค้นหาป้ายหยุดรถแบบรวดเร็ว",
|
||||
"stops.subtitle": "รวมสถานีขนส่งหลัก จุดจอดท้องถิ่น สถานีรถตู้ และจุดเอกชน — ใช้งานได้ทั้งบนมือถือและเดสก์ท็อป",
|
||||
"stops.kpi.total": "จำนวนจุดทั้งหมด",
|
||||
"stops.kpi.coverage": "ครอบคลุม",
|
||||
"stops.kpi.types": "ประเภทหลัก",
|
||||
"stops.kpi.routes": "เที่ยวใช้งานบ่อย",
|
||||
"stops.searchPh": "ค้นหาชื่อสถานที่ เช่น บขส.อ่างทอง",
|
||||
"stops.filterProvince": "กรองตามจังหวัด",
|
||||
"stops.allProvinces": "ทุกจังหวัด",
|
||||
"stops.allTypes": "ทุกประเภท",
|
||||
"stops.mapTitle": "แผนที่ย่อของเครือข่ายป้าย",
|
||||
"stops.onMap": "บนแผนที่",
|
||||
"stops.kpi.places": "สถานที่สำคัญ",
|
||||
"stops.kpi.buses": "สายที่ผ่านมากสุด",
|
||||
"stops.unitPoints": "จุด",
|
||||
"stops.unitPlaces": "แห่ง",
|
||||
"stops.unitTypes": "ประเภท",
|
||||
"stops.unitRoutes": "สายทางหลวง",
|
||||
"stops.highway": "ทางหลวง",
|
||||
"stops.busPrefix": "สาย",
|
||||
"stops.viewSchedule": "ดูตารางเวลาสาย {n}",
|
||||
"stops.viewRoute": "ดูรายละเอียดสาย {n}",
|
||||
"stops.subStop": "จุดขึ้นรถ (จุดย่อย)",
|
||||
"stops.noOffset": "ยังไม่ระบุเวลาเดินทางจากจุดแรก",
|
||||
"stops.noBusLine": "ยังไม่ระบุสายรถ",
|
||||
"stops.modeCode": "ค้นหาด้วยรหัสป้าย",
|
||||
"stops.modePlace": "ค้นหาด้วยชื่อสถานที่",
|
||||
"stops.codePh": "3+000",
|
||||
"stops.codeHint": "พิมพ์ตัวเลข 4 หลัก ระบบจะเติมเครื่องหมาย + ให้อัตโนมัติ (เช่น 3000 → 3+000)",
|
||||
"stops.codeHintBox": "พิมพ์ตัวเลขในช่อง ระบบจะเติม 0 ให้อัตโนมัติเมื่อเว้นว่าง และถ้าเจอรหัส 4 หลัก เช่น 8+591 ให้กรอก 08+591",
|
||||
"stops.codeFull": "รหัสป้าย:",
|
||||
"stops.placePh": "โรงพยาบาลอ่างทอง",
|
||||
"stops.placeHint": "พิมพ์ชื่อสถานที่สำคัญ เช่น โรงพยาบาล สำนักงานที่ดิน แล้วเลือกรายการที่ตรงกัน",
|
||||
"stops.padDelete": "ลบ",
|
||||
"stops.reset": "ล้างค่า",
|
||||
"stops.section": "ตอน",
|
||||
"stops.showing": "แสดง {a} จาก {b} ป้าย",
|
||||
"stops.showAll": "แสดงป้ายทั้งหมด",
|
||||
"stops.noResult": "ไม่พบป้ายหยุดรถที่ตรงกับเงื่อนไข",
|
||||
"stops.loading": "กำลังโหลดข้อมูลป้าย…",
|
||||
"type.terminal": "สถานีขนส่งผู้โดยสาร",
|
||||
"type.station": "ป้ายหลัก",
|
||||
"type.pickup": "จุดรับส่ง",
|
||||
"type.market": "ตลาด/ชุมชน",
|
||||
"type.landmark": "จุดสังเกต",
|
||||
"route.badge": "สายระหว่างจังหวัด",
|
||||
"route.kpiProvince": "จังหวัด",
|
||||
"route.kpiStops": "จุดจอด",
|
||||
"route.kpiTrips": "รอบเวลา",
|
||||
"route.overview": "ภาพรวมของสาย",
|
||||
"route.contact": "ติดต่อผู้ประกอบการ",
|
||||
"route.call": "โทรสอบถาม",
|
||||
"route.openLink": "เปิดลิงก์",
|
||||
"route.zoomQr": "ขยาย QR ให้ใหญ่ (กดเพื่อสแกน)",
|
||||
"route.copyLink": "คัดลอกลิงก์",
|
||||
"route.copied": "คัดลอกแล้ว",
|
||||
"common.close": "ปิด",
|
||||
"route.link.facebook": "Facebook",
|
||||
"route.link.line": "LINE Official",
|
||||
"route.link.www": "เว็บไซต์",
|
||||
"route.vehicle": "รถประจำสาย",
|
||||
"route.mapTitle": "เส้นทางเดินรถ",
|
||||
"route.photos": "รูปรถประจำเส้นทางในเครือข่าย",
|
||||
"route.stopsTitle": "จุดจอดสำคัญบนเส้นทาง",
|
||||
"route.scheduleTitle": "ตารางเวลา",
|
||||
"route.selectRoute": "เลือกสายรถ",
|
||||
"route.selectStation": "เลือกสถานี",
|
||||
"route.origin": "ต้นทาง",
|
||||
"route.transfer": "กลางทาง",
|
||||
"route.intermediate": "จุดจอดกลางทาง",
|
||||
"route.pass": "ผ่านทาง",
|
||||
"route.destination": "ปลายทาง",
|
||||
"route.direction": "ทุกทิศทาง",
|
||||
"route.empty": "ยังไม่มีข้อมูลตารางเวลา",
|
||||
"route.noSchedule": "— ยังไม่มีรอบ —",
|
||||
"route.seeOther": "เลือกสายรถอื่น",
|
||||
"stop.code": "รหัส:",
|
||||
"stop.nearby": "ใกล้เคียงป้าย",
|
||||
"stop.routes": "สายรถที่ผ่านจุดนี้",
|
||||
"stop.searchRoute": "ค้นหาสายรถหรือปลายทาง",
|
||||
"stop.showing": "แสดง {a} จาก {b} สาย",
|
||||
"stop.mapInfo": "แผนที่และข้อมูลป้าย",
|
||||
"stop.nextArrival": "เที่ยวถัดไป",
|
||||
"stop.subGeneric": "จุดจอดใน{city} · ดูเวลารถทุกสายที่ผ่านป้ายนี้ได้ในหน้าเดียว",
|
||||
"stop.thisStop": "ป้ายนี้",
|
||||
"stop.statRoutes": "จำนวนสายรถ",
|
||||
"stop.statTrips": "เที่ยวต่อวัน",
|
||||
"stop.statHours": "เวลาบริการ",
|
||||
"stop.statType": "ประเภท",
|
||||
"stop.nRoutes": "{n} สาย",
|
||||
"stop.tripsPerDay": "{n} รอบ/วัน",
|
||||
"stop.tripsPerDay1": "{n} รอบ/วัน",
|
||||
"stop.nRoutes1": "{n} สาย",
|
||||
"stop.noRoutes": "ยังไม่มีสายรถที่บันทึกว่าผ่านป้ายนี้",
|
||||
"stop.noTimes": "ยังไม่มีข้อมูลเวลาเดินรถที่ป้ายนี้",
|
||||
"stop.tomorrow": "พรุ่งนี้",
|
||||
"stop.nextAt": "ถัดไป",
|
||||
"stop.notFound": "ไม่พบป้ายนี้",
|
||||
"stop.notFoundSub": "ไม่พบรหัสป้าย “{code}” ในระบบ — ตรวจรหัสหรือกลับไปหน้ารายการป้าย",
|
||||
"stop.nearbySub": "สถานที่น่าสนใจและจุดแวะระหว่างรอรถ",
|
||||
"stop.otherStopsTitle": "จุดขึ้นรถประจำทางอื่นๆ · สาย {n} ({m} จุด)",
|
||||
"stop.otherMore": "(+{n} จุด)",
|
||||
"stop.otherStopsAll": "จุดขึ้นรถประจำทางอื่นๆ ทั้งหมด ({m} จุด)",
|
||||
"stop.noCoord": "ยังไม่มีพิกัด",
|
||||
"stop.open": "เปิด",
|
||||
"stop.close": "ปิด",
|
||||
"stop.nowAtStop": "เวลาปัจจุบัน ณ ป้ายนี้",
|
||||
"stop.autoNext": "กำลังคำนวณเที่ยวถัดไปอัตโนมัติ",
|
||||
"common.backHome": "← กลับหน้าแรก",
|
||||
"common.backStops": "← กลับไปยังรายการป้าย",
|
||||
"common.search": "ค้นหา",
|
||||
"common.details": "ดูรายละเอียด",
|
||||
"common.bus": "รถบัส",
|
||||
"common.phone": "โทร:",
|
||||
"common.noWebsite": "ยังไม่ระบุเว็บไซต์",
|
||||
"type.van": "สถานีรถตู้",
|
||||
"type.local": "จุดจอดท้องถิ่น",
|
||||
"type.busstop": "ศาลารอรถ หรือป้ายหยุดรถ",
|
||||
"type.startlocalpoint": "ต้นทางรถสายท้องถิ่น",
|
||||
"type.other": "จุดขึ้นรถประจำทางอื่นๆ",
|
||||
"type.marketOpt": "ตลาด/จุดเอกชน",
|
||||
"route.mapTitleN": "เส้นทางเดินรถสาย {n}",
|
||||
"stop.viewScheduleN": "ดูตารางเวลาสายรถ {n}",
|
||||
"stop.openRoute": "เปิดหน้ารายละเอียดสายรถนี้",
|
||||
"credits.title": "เครดิตและแหล่งที่มา",
|
||||
"credits.icons": "ไอคอน — Lucide",
|
||||
"credits.fonts": "ฟอนต์ — Google Fonts",
|
||||
"credits.map": "แผนที่",
|
||||
"credits.photos": "ขอขอบคุณภาพรถประจำทาง",
|
||||
"credits.photosNote": "และสายอื่น ๆ ที่ไม่ได้ระบุ ขอขอบคุณมา ณ ที่นี้",
|
||||
"common.back": "ย้อนกลับ",
|
||||
"check.scheduleAll": "ตารางเวลาเดินรถทุกจุดจอด",
|
||||
"check.title": "ตารางเวลาเดินรถ",
|
||||
"check.lead": "เลือกสายรถ แล้วดูรอบรถทุกจุดจอดในหน้าเดียว",
|
||||
"check.kpiStops": "จุดจอดหลัก",
|
||||
"check.kpiProvince": "จังหวัดที่ผ่าน",
|
||||
"check.kpiTrips": "รอบต่อวัน",
|
||||
"check.kpiNext": "รอบถัดไป",
|
||||
"check.direction": "ทิศทาง",
|
||||
"check.atStop": "ตารางเดินรถ ณ",
|
||||
"time.derived": "~ ตารางจากการคำนวณ (จาก {base} {n} นาที) — อาจเปลี่ยนแปลงตามการจราจรจริง",
|
||||
"check.dayWeekday": "ตารางวันทำงาน (จ–ศ)",
|
||||
"check.dayHoliday": "ตารางวันหยุด (ส–อา/นักขัตฤกษ์)",
|
||||
"check.dayMixed": "ทิศนี้มีทั้งตารางวันทำงานและวันหยุดในตัวเดียวกัน — ยังไม่แยกตามวัน",
|
||||
"check.dayUnknown": "ยังไม่ระบุวันของตาราง (แสดงทุกวัน)",
|
||||
"check.dayOfWeek": "วันนี้",
|
||||
"time.estimated": "~ เวลาคำนวณจากต้นทาง (ประมาณ — ไม่ใช่ตารางของผู้ประกอบการ)",
|
||||
"check.now": "เวลาปัจจุบัน",
|
||||
"check.updatedAgo": "อัปเดตล่าสุด {ago}",
|
||||
"check.agoToday": "วันนี้",
|
||||
"check.agoYesterday": "เมื่อวาน",
|
||||
"check.agoDays": "{n} วันที่แล้ว",
|
||||
"check.agoWeeks": "{n} สัปดาห์ที่แล้ว",
|
||||
"check.agoMonths": "{n} เดือนที่แล้ว",
|
||||
"check.agoYears": "{y} ปีที่แล้ว",
|
||||
"check.agoYearsMonths": "{y} ปี {m} เดือนที่แล้ว",
|
||||
"check.nextAt": "เที่ยวถัดไป",
|
||||
"check.noMoreToday": "ไม่มีรถเหลือในวันนี้แล้ว",
|
||||
"check.stopsCount": "จุดจอด",
|
||||
"check.toStopDetail": "ไปหน้ารายละเอียดจุดจอด",
|
||||
"common.routes": "เส้นทาง"
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"8": {
|
||||
"13": 197.42,
|
||||
"6": 0.01
|
||||
},
|
||||
"15": {
|
||||
"1": 0.02,
|
||||
"2": 14.32,
|
||||
"6": 109.52
|
||||
},
|
||||
"101": {
|
||||
"3": 39.76,
|
||||
"1": 0.02,
|
||||
"2": 14.39
|
||||
},
|
||||
"324": {
|
||||
"1": 29.52,
|
||||
"8": 9.76
|
||||
},
|
||||
"464": {
|
||||
"9": 0.0,
|
||||
"10": 103.15,
|
||||
"1": 44.95
|
||||
},
|
||||
"641": {
|
||||
"1": 0.0,
|
||||
"7": 43.53
|
||||
},
|
||||
"902": {
|
||||
"1": 0.0,
|
||||
"6": 100.28,
|
||||
"15": 77
|
||||
|
||||
},
|
||||
"951": {
|
||||
"9": 0.0,
|
||||
"20": 42.25
|
||||
},
|
||||
"952": {
|
||||
"12": 129.46
|
||||
},
|
||||
"954": {
|
||||
"8": 0.0
|
||||
},
|
||||
"1011": {
|
||||
"1": 36.02,
|
||||
"8": 0.36
|
||||
},
|
||||
"2194": {
|
||||
"8": 1.11,
|
||||
"4": 40.84
|
||||
},
|
||||
"2231": {
|
||||
"1": 0.0,
|
||||
"8": 20.13
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import busstops from "@/data/network/busstop_list.json";
|
||||
|
||||
export type BusStop = {
|
||||
route_code: string;
|
||||
section_code: string;
|
||||
route_name: string;
|
||||
kilometer: string; // e.g. "36+020"
|
||||
position: string;
|
||||
type: string;
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
"buses-line": number[];
|
||||
};
|
||||
|
||||
/** "36+020" → "36020" (รหัสป้าย 5 หลักตาม design) */
|
||||
export function pad5(km: string): string {
|
||||
return km.replace("+", "");
|
||||
}
|
||||
|
||||
export function allBusStops(): BusStop[] {
|
||||
return busstops as BusStop[];
|
||||
}
|
||||
|
||||
/** ค้นป้ายทางหลวงด้วยรหัส 5 หลัก */
|
||||
export function findBusStopByCode(code: string): BusStop | undefined {
|
||||
return (busstops as BusStop[]).find((b) => pad5(b.kilometer) === code);
|
||||
}
|
||||
|
||||
/** ระยะทางแบบ haversine (เมตร) */
|
||||
export function haversineM(lat1: number, lng1: number, lat2: number, lng2: number): number {
|
||||
const R = 6371000;
|
||||
const toRad = (d: number) => (d * Math.PI) / 180;
|
||||
const dLat = toRad(lat2 - lat1);
|
||||
const dLng = toRad(lng2 - lng1);
|
||||
const a =
|
||||
Math.sin(dLat / 2) ** 2 +
|
||||
Math.cos(toRad(lat1)) * Math.cos(toRad(lat2)) * Math.sin(dLng / 2) ** 2;
|
||||
return 2 * R * Math.asin(Math.sqrt(a));
|
||||
}
|
||||
|
||||
/** ป้ายทางหลวงที่ใกล้จุดพิกัดมากสุด N อัน (เรียงตามระยะ) */
|
||||
export function nearestBusStops(lat: number, lng: number, limit = 8): { stop: BusStop; distM: number }[] {
|
||||
return (busstops as BusStop[])
|
||||
.map((stop) => ({ stop, distM: haversineM(lat, lng, stop.latitude, stop.longitude) }))
|
||||
.sort((a, b) => a.distM - b.distM)
|
||||
.slice(0, limit);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import th from "@/data/locales/th.json";
|
||||
import en from "@/data/locales/en.json";
|
||||
|
||||
export type Lang = "th" | "en";
|
||||
|
||||
const DICTS: Record<Lang, Record<string, string>> = {
|
||||
th: th as Record<string, string>,
|
||||
en: en as Record<string, string>,
|
||||
};
|
||||
|
||||
/** แปลข้อความตามคีย์ (จาก design locales/th.json + en.json) */
|
||||
export function t(
|
||||
key: string,
|
||||
lang: Lang,
|
||||
vars?: Record<string, string | number>,
|
||||
): string {
|
||||
let s = DICTS[lang]?.[key] ?? DICTS.th[key] ?? key;
|
||||
if (vars) {
|
||||
for (const [k, v] of Object.entries(vars)) {
|
||||
s = s.replace(new RegExp(`\\{${k}\\}`, "g"), String(v));
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/** อ่าน lang จากคุกกี้ (server-side) */
|
||||
export function langFromCookie(cookieHeader: string | null | undefined): Lang {
|
||||
if (!cookieHeader) return "th";
|
||||
const m = cookieHeader.match(/(?:^|;\s*)lang=(th|en)\b/);
|
||||
return m ? (m[1] as Lang) : "th";
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import km from "@/data/network/stop-km.json";
|
||||
|
||||
/** ระยะทาง (กม.) ของจุดจอดจากต้นทาง (design: stop-km.json route_id → station_id → km) */
|
||||
export function kmFor(routeId: string, stationId: number): number | null {
|
||||
const m = (km as Record<string, Record<string, number>>)[String(routeId)];
|
||||
const v = m?.[String(stationId)];
|
||||
return typeof v === "number" ? v : null;
|
||||
}
|
||||
Reference in new issue
Block a user