feat(ui): port route/stop/check pages to match mock + tidy layout
Route detail: - breadcrumb + route-select dropdown (เปลี่ยนสายในหน้าเดียว) - vehicle card (รถ + caption + QR + ติดต่อโทร/LINE รวมการ์ดเดียว) - summary เพิ่ม 'รอบถัดไป' (คำนวณจาก schedules) - km list (จุดจอดตามเส้นทาง กม.) Stop detail: - stop-hero (title/meta pills/metric grid 4 + live clock เที่ยวถัดไป) - route expander (สายที่ผ่าน + เวลาต่อสาย) + map aside + chips - breadcrumb Stop list: - search form จริง (server-side ?q=) + breadcrumb - fix TYPE_LABEL/TONE/ICON ให้ตรง station_type จริง (main_terminal/local_stop/market/private_stop) Check page (ใหม่ /check): เช็กเวลาเดินรถ + selector + 4 สถิติ + ตารางทุกจุดจอด Header CTA -> /check Assets: caption<id>.json + qrcode/* จาก mock (lib/captions.ts)
This commit is contained in:
1 parent
b022a85178
commit
0c3936df69
24 files changed
+1084
-303
No files matched your search
@@ -0,0 +1,145 @@
|
||||
import Link from "next/link";
|
||||
import { api, type RouteListItem, type Schedule, type RouteStop, type RouteDetail } from "@/lib/api";
|
||||
import { RouteSelect } from "@/components/RouteSelect";
|
||||
import { VisitTracker } from "@/lib/visit-tracker";
|
||||
import { Icon } from "@/components/Icons";
|
||||
|
||||
const TONES = ["sky", "purple", "pink", "mint", "amber"] as const;
|
||||
|
||||
function nextTrip(times: string[]): string | null {
|
||||
if (times.length === 0) return null;
|
||||
const now = new Date();
|
||||
const cur = now.getHours() * 60 + now.getMinutes();
|
||||
for (const t of [...times].sort()) {
|
||||
const [h, m] = t.split(":").map(Number);
|
||||
if (h * 60 + m >= cur) return t;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
type CheckPageProps = {
|
||||
searchParams: Promise<{ route?: string }>;
|
||||
};
|
||||
|
||||
export default async function CheckPage({ searchParams }: CheckPageProps) {
|
||||
const sp = await searchParams;
|
||||
|
||||
const { items: allRoutes } = await api.routes().catch(() => ({ items: [] as RouteListItem[] }));
|
||||
const routeId =
|
||||
sp.route && allRoutes.some((r) => r.route_id === sp.route)
|
||||
? sp.route
|
||||
: allRoutes[0]?.route_id;
|
||||
|
||||
let route: RouteDetail | null = null;
|
||||
let schedules: Schedule[] = [];
|
||||
let stops: RouteStop[] = [];
|
||||
|
||||
if (routeId) {
|
||||
try {
|
||||
[route, { items: schedules }, { items: stops }] = await Promise.all([
|
||||
api.route(routeId),
|
||||
api.schedules({ route_id: routeId }),
|
||||
api.routeStops(routeId),
|
||||
]);
|
||||
} catch {
|
||||
route = null;
|
||||
schedules = [];
|
||||
stops = [];
|
||||
}
|
||||
}
|
||||
|
||||
const allTimes = schedules.flatMap((s) => s.departure_times);
|
||||
const next = nextTrip(allTimes);
|
||||
const provinceSet = new Set(stops.map((s) => s.province_th).filter((x): x is string => !!x));
|
||||
|
||||
return (
|
||||
<main className="page">
|
||||
<VisitTracker path="/check" />
|
||||
|
||||
<div className="container">
|
||||
<p className="breadcrumb">
|
||||
<Link href="/">หน้าแรก</Link> / <span>เช็กเวลาเดินรถ</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<section className="hero hero--short">
|
||||
<div className="hero__blob one" aria-hidden />
|
||||
<div className="hero__blob two" aria-hidden />
|
||||
<div className="hero__blob three" aria-hidden />
|
||||
<div className="container hero__inner">
|
||||
<span className="hero__badge">
|
||||
<Icon name="clock" size={14} className="icon" /> เช็กเวลาเดินรถ
|
||||
</span>
|
||||
<h1>
|
||||
ตารางเวลาเดินรถ
|
||||
<br />
|
||||
<span className="hero__grad">{route?.name_th ?? "เลือกสายรถด้านล่าง"}</span>
|
||||
</h1>
|
||||
<p className="hero__lead">เลือกสายรถ แล้วดูรอบรถทุกจุดจอดในหน้าเดียว</p>
|
||||
|
||||
{allRoutes.length > 0 && (
|
||||
<div className="check-selector">
|
||||
<RouteSelect
|
||||
routes={allRoutes.map((r) => ({ route_id: r.route_id, name_th: r.name_th }))}
|
||||
current={routeId ?? ""}
|
||||
to={(id) => `/check?route=${encodeURIComponent(id)}`}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<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>
|
||||
|
||||
{/* ตารางเวลาทุกจุดจอด */}
|
||||
<section className="check-schedule">
|
||||
<h2 className="section-title">
|
||||
ตารางเวลาเดินรถทุกจุดจอด {route ? `— สาย ${route.route_id}` : ""}
|
||||
</h2>
|
||||
{schedules.length === 0 ? (
|
||||
<p className="muted">ยังไม่มีข้อมูลตารางเวลาสำหรับสายนี้</p>
|
||||
) : (
|
||||
<div className="schedule-list">
|
||||
{schedules.map((s, i) => {
|
||||
const tone = TONES[i % TONES.length];
|
||||
return (
|
||||
<article key={s.id} className={`schedule-card schedule-card--${tone}`}>
|
||||
<span className="schedule-card__rail" aria-hidden />
|
||||
<div className="schedule-card__head">
|
||||
<div className={`schedule-card__route ${tone}`}>
|
||||
<span>{s.station_name_th}</span>
|
||||
<small>จุดต้นทาง</small>
|
||||
</div>
|
||||
<div className="schedule-card__meta">
|
||||
<strong>{s.direction_note || "ทุกทิศทาง"}</strong>
|
||||
{s.schedule_note && <span>{s.schedule_note}</span>}
|
||||
</div>
|
||||
</div>
|
||||
{s.departure_times.length === 0 ? (
|
||||
<span className="schedule-card__empty">— ยังไม่มีรอบ —</span>
|
||||
) : (
|
||||
<div className="schedule-card__times">
|
||||
{s.departure_times.map((t, j) => (
|
||||
<span key={`${s.id}-${j}`} className="schedule-card__time">
|
||||
<Icon name="clock" size={13} className="icon" /> {t}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</article>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -1074,4 +1074,205 @@ img { max-width: 100%; display: block; }
|
||||
font-size: .85rem; color: #4a5573; line-height: 1.6;
|
||||
}
|
||||
|
||||
/* ---------- Breadcrumb ---------- */
|
||||
.breadcrumb { color: var(--muted); font-size: .85rem; margin: 18px 0 4px; }
|
||||
.breadcrumb a { color: #7a4cc0; font-weight: 600; text-decoration: none; }
|
||||
.breadcrumb a:hover { text-decoration: underline; }
|
||||
.breadcrumb span { color: var(--ink-muted); }
|
||||
|
||||
/* ---------- Route selector (toolbar) ---------- */
|
||||
.route-select-wrap { flex: 1; min-width: 260px; }
|
||||
.route-select-wrap__label {
|
||||
display: flex; align-items: center; gap: 6px; margin: 0 0 6px 4px;
|
||||
font-size: .8rem; font-weight: 700; color: var(--muted);
|
||||
}
|
||||
.route-select-wrap__label svg { color: #8b5cf6; flex: none; }
|
||||
.select-box--toolbar { max-width: 480px; }
|
||||
|
||||
/* ---------- Vehicle card (รถ + ติดต่อ + QR) ---------- */
|
||||
.vehicle-card {
|
||||
display: grid; grid-template-columns: 1.3fr 1fr;
|
||||
background: #fff; border: 1px solid var(--line); border-radius: 18px;
|
||||
overflow: hidden; box-shadow: 0 4px 14px rgba(20, 40, 90, .06);
|
||||
margin-bottom: 26px;
|
||||
}
|
||||
.vehicle-card__img { grid-column: 1; width: 100%; height: 100%; min-height: 240px; object-fit: cover; display: block; }
|
||||
.vehicle-card__meta { grid-column: 2; padding: 24px; display: flex; flex-direction: column; justify-content: center; gap: 8px; }
|
||||
.vehicle-card__label { margin: 0; font-size: .78rem; font-weight: 700; color: #7a4cc0; text-transform: uppercase; letter-spacing: .05em; }
|
||||
.vehicle-card__meta h2 { margin: 0; font-size: 1.25rem; color: var(--ink); }
|
||||
.vehicle-card__meta p { margin: 0; color: var(--muted); font-size: .95rem; line-height: 1.6; }
|
||||
.vehicle-card__contact {
|
||||
grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px;
|
||||
padding: 14px 18px; border-top: 1px solid var(--line); background: #faf9ff;
|
||||
}
|
||||
.contact-item {
|
||||
flex: 1; min-width: 220px; display: flex; align-items: center; gap: 12px;
|
||||
padding: 12px 14px; border-radius: 12px; background: #fff; border: 1px solid #eee;
|
||||
text-decoration: none; color: inherit; transition: transform .15s ease, box-shadow .15s ease;
|
||||
}
|
||||
a.contact-item:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(20, 40, 90, .08); }
|
||||
.contact-item .ic-wrap {
|
||||
width: 42px; height: 42px; flex: none; display: flex; align-items: center; justify-content: center;
|
||||
border-radius: 12px; background: linear-gradient(135deg, #7a4cc0, #b07ce0); color: #fff;
|
||||
}
|
||||
.contact-item .ic-wrap.tone-green { background: linear-gradient(135deg, #1f8765, #51c39c); }
|
||||
.contact-item .txt { flex: 1; min-width: 0; }
|
||||
.contact-item .txt strong { display: block; color: var(--ink); font-size: .98rem; margin-bottom: 2px; }
|
||||
.contact-item .txt span { display: block; color: var(--muted); font-size: .86rem; }
|
||||
.contact-item--qr { flex: 0 1 260px; cursor: zoom-in; }
|
||||
.qr-img {
|
||||
width: 56px; height: 56px; flex: none; object-fit: contain;
|
||||
border-radius: 8px; padding: 4px; border: 1px solid #eee; background: #fff;
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
.vehicle-card { grid-template-columns: 1fr; }
|
||||
.vehicle-card__img { grid-column: 1; min-height: 200px; }
|
||||
.vehicle-card__meta { grid-column: 1; padding: 18px; }
|
||||
.vehicle-card__contact { grid-column: 1; flex-direction: column; }
|
||||
.contact-item { min-width: 0; }
|
||||
}
|
||||
|
||||
/* ---------- KM list (จุดจอดตามเส้นทาง) ---------- */
|
||||
.km-wrap { margin-top: 18px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
|
||||
.km-wrap__title { margin: 0 0 12px; font-size: .92rem; color: var(--ink); font-weight: 700; }
|
||||
.km-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
|
||||
.km-list li { display: flex; align-items: center; gap: 10px; font-size: .9rem; color: var(--ink-muted); }
|
||||
.km-list__num {
|
||||
flex: none; width: 26px; height: 26px; border-radius: 50%; background: #f1e9ff;
|
||||
color: #7a4cc0; font-size: .78rem; font-weight: 700; display: flex; align-items: center; justify-content: center;
|
||||
}
|
||||
.km-list__name { font-weight: 600; color: var(--ink); }
|
||||
.km-list__loc { margin-left: auto; font-size: .78rem; color: var(--muted); }
|
||||
|
||||
/* ---------- Stop detail ---------- */
|
||||
.stop-hero {
|
||||
display: grid; grid-template-columns: 1.2fr .8fr; gap: 16px;
|
||||
background: linear-gradient(135deg, #f8f4ff 0%, #f2f6ff 45%, #eefaf5 100%);
|
||||
border: 1px solid var(--line); border-radius: 22px;
|
||||
box-shadow: 0 16px 34px rgba(122, 76, 192, .12);
|
||||
padding: 18px; margin-bottom: 18px;
|
||||
}
|
||||
.stop-hero__title { margin: 0; font-size: 1.7rem; color: var(--ink); line-height: 1.2; display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
|
||||
.stop-hero__title .icon { color: #7a4cc0; flex: none; }
|
||||
.stop-hero__sub { margin: 8px 0 0; color: var(--muted); font-size: .9rem; }
|
||||
.stop-hero__meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
|
||||
.meta-pill {
|
||||
background: linear-gradient(135deg, #fff, #f7f9ff); border: 1px solid var(--line);
|
||||
color: #5b3b71; padding: 6px 14px; border-radius: 999px; font-size: .85rem; font-weight: 600;
|
||||
}
|
||||
.meta-pill.purple { background: linear-gradient(135deg, #f5eeff, #fce7f3); color: #7a4cc0; }
|
||||
.meta-pill.sky { background: linear-gradient(135deg, #ebf5ff, #eff6ff); color: #3071b8; }
|
||||
.meta-pill.mint { background: linear-gradient(135deg, #eafaf4, #ecfeff); color: #1f8765; }
|
||||
.stop-hero__metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 14px; }
|
||||
.stop-metric {
|
||||
border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: #fff;
|
||||
box-shadow: 0 6px 14px rgba(122, 76, 192, .08); min-width: 0;
|
||||
}
|
||||
.stop-metric:nth-child(1) { background: linear-gradient(135deg, #f5efff, #fdf2f8); }
|
||||
.stop-metric:nth-child(2) { background: linear-gradient(135deg, #ecfeff, #eef6ff); }
|
||||
.stop-metric:nth-child(3) { background: linear-gradient(135deg, #fff1f2, #fff7ed); }
|
||||
.stop-metric:nth-child(4) { background: linear-gradient(135deg, #ecfdf5, #f0fdfa); }
|
||||
.stop-metric__label { margin: 0; color: var(--muted); font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
|
||||
.stop-metric__value { margin: 4px 0 0; color: var(--ink); font-size: 1.05rem; font-weight: 800; line-height: 1.2; overflow-wrap: anywhere; }
|
||||
.stop-hero__side { display: flex; flex-direction: column; gap: 12px; }
|
||||
.stop-hero__photo { width: 100%; height: 220px; object-fit: cover; border-radius: 16px; display: block; box-shadow: 0 10px 24px rgba(63, 43, 94, .16); }
|
||||
.stop-hero__photo--empty {
|
||||
display: flex; align-items: center; justify-content: center; gap: 8px;
|
||||
color: var(--muted); background: #f7f4fd; border: 1px dashed #d9d2ea;
|
||||
}
|
||||
|
||||
/* live clock */
|
||||
.live-clock-card {
|
||||
display: flex; align-items: center; justify-content: space-between; gap: 14px;
|
||||
padding: 12px 14px; border: 1px solid rgba(240, 191, 224, .9); border-radius: 14px;
|
||||
background: linear-gradient(135deg, #ffe8f4 0%, #f5f0ff 50%, #e8f7ff 100%);
|
||||
box-shadow: 0 8px 20px rgba(122, 76, 192, .10);
|
||||
}
|
||||
.live-clock-title { margin: 0; color: var(--muted); font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
|
||||
.live-clock-time { margin: 2px 0 0; font-size: 1.65rem; line-height: 1; color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; }
|
||||
.live-clock-note {
|
||||
margin: 0; padding: 6px 10px; border-radius: 999px; background: linear-gradient(135deg, #fff, #fff7fb);
|
||||
border: 1px solid #eec7df; color: #9333ea; font-size: .78rem; font-weight: 600; white-space: nowrap;
|
||||
}
|
||||
.live-dot {
|
||||
display: inline-block; width: 10px; height: 10px; border-radius: 999px; background: #ec4899;
|
||||
margin-right: 6px; animation: livePulse 1.6s infinite; vertical-align: middle;
|
||||
}
|
||||
@keyframes livePulse {
|
||||
0% { box-shadow: 0 0 0 0 rgba(236, 72, 153, .38); }
|
||||
70% { box-shadow: 0 0 0 8px rgba(236, 72, 153, 0); }
|
||||
100% { box-shadow: 0 0 0 0 rgba(236, 72, 153, 0); }
|
||||
}
|
||||
|
||||
/* layout */
|
||||
.stop-layout { display: grid; grid-template-columns: 1.35fr .9fr; gap: 16px; align-items: start; margin: 8px 0 48px; }
|
||||
.stop-panel { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: 0 8px 24px rgba(67, 56, 202, .08); }
|
||||
.stop-panel__empty { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); padding: 40px 12px; border: 1px dashed #d9d2ea; border-radius: 12px; }
|
||||
|
||||
/* route expander */
|
||||
.route-expander-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
|
||||
.route-expander { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
|
||||
.route-expander summary {
|
||||
list-style: none; display: flex; align-items: center; gap: 10px; padding: 12px 14px;
|
||||
cursor: pointer; flex-wrap: wrap;
|
||||
}
|
||||
.route-expander summary::-webkit-details-marker { display: none; }
|
||||
.route-expander__id {
|
||||
flex: none; min-width: 44px; text-align: center; padding: 5px 10px; border-radius: 8px;
|
||||
color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; background: linear-gradient(135deg, #7a4cc0, #b07ce0);
|
||||
}
|
||||
.route-expander__id.sky { background: linear-gradient(135deg, #3071b8, #6ea7e8); }
|
||||
.route-expander__id.pink { background: linear-gradient(135deg, #bb3a78, #f08bb9); }
|
||||
.route-expander__id.mint { background: linear-gradient(135deg, #1f8765, #51c39c); }
|
||||
.route-expander__name { flex: 1; min-width: 0; color: var(--ink); font-weight: 700; font-size: .94rem; }
|
||||
.route-expander__count { flex: none; color: var(--muted); font-size: .8rem; font-weight: 700; }
|
||||
.route-expander__body { border-top: 1px solid var(--line); padding: 12px 14px; background: #fbfaff; }
|
||||
.route-expander__link { display: inline-block; margin-bottom: 8px; color: #7a4cc0; font-size: .85rem; font-weight: 700; text-decoration: none; }
|
||||
.route-expander__link:hover { text-decoration: underline; }
|
||||
.route-expander__times { display: flex; flex-wrap: wrap; gap: 8px; }
|
||||
.time-chip {
|
||||
padding: 6px 12px; border-radius: 10px; background: #f1f4fb; color: #2b2f42;
|
||||
font-weight: 700; font-size: .85rem; border: 1px solid #e6eaf3; font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* stop chips (map aside) */
|
||||
.stop-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
|
||||
|
||||
@media (max-width: 980px) {
|
||||
.stop-hero { grid-template-columns: 1fr; }
|
||||
.stop-layout { grid-template-columns: 1fr; }
|
||||
}
|
||||
|
||||
/* ---------- Check schedule (เช็กเวลาเดินรถ) ---------- */
|
||||
.check-selector { max-width: 520px; margin: 8px auto 0; }
|
||||
.check-selector .route-select-wrap { text-align: left; }
|
||||
.check-selector .select-box--toolbar { max-width: none; }
|
||||
.check-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 22px 0; }
|
||||
.check-stat {
|
||||
background: #fff; border: 1px solid var(--line); border-radius: 14px;
|
||||
padding: 14px 16px; text-align: center; box-shadow: 0 6px 14px rgba(67, 56, 202, .06);
|
||||
}
|
||||
.check-stat:nth-child(1) { background: linear-gradient(135deg, #f5efff, #fdf2f8); }
|
||||
.check-stat:nth-child(2) { background: linear-gradient(135deg, #ebf5ff, #eff6ff); }
|
||||
.check-stat:nth-child(3) { background: linear-gradient(135deg, #eafaf4, #ecfeff); }
|
||||
.check-stat:nth-child(4) { background: linear-gradient(135deg, #fff1f2, #fff7ed); }
|
||||
.check-stat b { display: block; font-size: 1.5rem; color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; }
|
||||
.check-stat span { display: block; margin-top: 4px; font-size: .78rem; color: var(--muted); font-weight: 700; }
|
||||
.check-schedule { margin: 8px 0 52px; }
|
||||
@media (max-width: 640px) {
|
||||
.check-stats { grid-template-columns: repeat(2, 1fr); }
|
||||
}
|
||||
|
||||
/* ---------- Search form (toolbar) ---------- */
|
||||
.toolbar__search .toolbar__submit {
|
||||
flex: none; background: var(--grad-cta); color: #fff; border: 0; border-radius: 8px;
|
||||
padding: 8px 14px; font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer;
|
||||
}
|
||||
.toolbar__search .toolbar__clear {
|
||||
flex: none; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
|
||||
border-radius: 50%; background: #f1eef8; color: var(--muted); text-decoration: none; font-size: .8rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
.toolbar__search .toolbar__clear:hover { background: #e7e1f4; }
|
||||
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
import { api, isApiNotFoundError, type RouteDetail, type RouteStop, type StopListItem, type Schedule } from "@/lib/api";
|
||||
import {
|
||||
api,
|
||||
isApiNotFoundError,
|
||||
type RouteDetail,
|
||||
type RouteStop,
|
||||
type StopListItem,
|
||||
type Schedule,
|
||||
type RouteListItem,
|
||||
} from "@/lib/api";
|
||||
import LazyMapView from "@/components/LazyMapView";
|
||||
import { RouteSelect } from "@/components/RouteSelect";
|
||||
import { VisitTracker } from "@/lib/visit-tracker";
|
||||
import { routePhoto } from "@/lib/images";
|
||||
import { routePath } from "@/lib/geojson";
|
||||
import { captionFor } from "@/lib/captions";
|
||||
import { Icon } from "@/components/Icons";
|
||||
|
||||
const TONES = ["sky", "purple", "pink", "mint", "amber"] as const;
|
||||
@@ -13,23 +23,37 @@ type RouteDetailPageProps = {
|
||||
params: Promise<{ routeId: string }>;
|
||||
};
|
||||
|
||||
export default async function RouteDetailPage({
|
||||
params,
|
||||
}: RouteDetailPageProps) {
|
||||
/** เที่ยวถัดไป = รอบแรกที่ยังไม่ผ่านของสายนี้ */
|
||||
function nextTrip(schedules: Schedule[]): string | null {
|
||||
const all = schedules.flatMap((s) => s.departure_times);
|
||||
if (all.length === 0) return null;
|
||||
const now = new Date();
|
||||
const cur = now.getHours() * 60 + now.getMinutes();
|
||||
for (const t of [...all].sort()) {
|
||||
const [h, m] = t.split(":").map(Number);
|
||||
if (h * 60 + m >= cur) return t;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export default async function RouteDetailPage({ params }: RouteDetailPageProps) {
|
||||
const { routeId } = await params;
|
||||
|
||||
let route: RouteDetail | null = null;
|
||||
let stops: RouteStop[] = [];
|
||||
let schedules: Schedule[] = [];
|
||||
let allStops: StopListItem[] = [];
|
||||
let allRoutes: RouteListItem[] = [];
|
||||
|
||||
try {
|
||||
[route, { items: stops }, { items: schedules }, { items: allStops }] = await Promise.all([
|
||||
api.route(routeId),
|
||||
api.routeStops(routeId),
|
||||
api.schedules({ route_id: routeId }),
|
||||
api.stops(),
|
||||
]);
|
||||
[route, { items: stops }, { items: schedules }, { items: allStops }, { items: allRoutes }] =
|
||||
await Promise.all([
|
||||
api.route(routeId),
|
||||
api.routeStops(routeId),
|
||||
api.schedules({ route_id: routeId }),
|
||||
api.stops(),
|
||||
api.routes(),
|
||||
]);
|
||||
} catch (error) {
|
||||
if (isApiNotFoundError(error)) {
|
||||
notFound();
|
||||
@@ -38,6 +62,7 @@ export default async function RouteDetailPage({
|
||||
stops = [];
|
||||
schedules = [];
|
||||
allStops = [];
|
||||
allRoutes = [];
|
||||
}
|
||||
|
||||
if (!route) {
|
||||
@@ -53,12 +78,9 @@ export default async function RouteDetailPage({
|
||||
);
|
||||
}
|
||||
|
||||
// Build coord lookup by station_id from /stops dataset
|
||||
const coordById = new Map<number, { lat: number; lng: number }>();
|
||||
for (const s of allStops) {
|
||||
if (s.lat != null && s.lng != null) {
|
||||
coordById.set(s.id, { lat: s.lat, lng: s.lng });
|
||||
}
|
||||
if (s.lat != null && s.lng != null) coordById.set(s.id, { lat: s.lat, lng: s.lng });
|
||||
}
|
||||
|
||||
const mapPoints = stops
|
||||
@@ -77,19 +99,33 @@ export default async function RouteDetailPage({
|
||||
.filter((x): x is NonNullable<typeof x> => x !== null);
|
||||
|
||||
const stopPath: [number, number][] = mapPoints.map((p) => [p.lat, p.lng]);
|
||||
// เส้นทางจริงจาก design (geojson-web/<id>.geojson) ถ้ามี — ไม่งั้นใช้เส้นตรงเชื่อมจุดจอด
|
||||
const path: [number, number][] = routePath(route.route_id) ?? stopPath;
|
||||
const provinceSet = new Set(
|
||||
stops.map((s) => s.province_th).filter((x): x is string => !!x),
|
||||
);
|
||||
const provinceSet = new Set(stops.map((s) => s.province_th).filter((x): x is string => !!x));
|
||||
|
||||
// รูปรถ/เส้นทางจาก design (.image/routes/<id>/car|hero)
|
||||
const photo = routePhoto(route.route_id, "car") ?? routePhoto(route.route_id, "hero");
|
||||
const cap = captionFor(route.route_id);
|
||||
const next = nextTrip(schedules);
|
||||
|
||||
// ติดต่อผู้ประกอบการ (จาก design routes.json)
|
||||
const contact = (route.contact ?? {}) as {
|
||||
phones?: { label?: string; number: string }[];
|
||||
web_url?: string;
|
||||
};
|
||||
const phones = Array.isArray(contact.phones) ? contact.phones : [];
|
||||
const lineUrl = typeof contact.web_url === "string" ? contact.web_url : "";
|
||||
const qr = cap?.qr ?? "";
|
||||
|
||||
return (
|
||||
<main className="page">
|
||||
<VisitTracker path={`/routes/${routeId}`} />
|
||||
|
||||
<div className="container">
|
||||
<p className="breadcrumb">
|
||||
<Link href="/">หน้าแรก</Link> / <Link href="/routes">รายละเอียดสายรถ</Link> /{" "}
|
||||
<span>{route.route_id}</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<section className="page-hero page-hero--alt route-hero">
|
||||
<span className="page-hero__blob page-hero__blob--a" aria-hidden />
|
||||
<span className="page-hero__blob page-hero__blob--b" aria-hidden />
|
||||
@@ -117,142 +153,181 @@ export default async function RouteDetailPage({
|
||||
<span className="page-hero__stat"><b>{stops.length}</b> จุดจอด</span>
|
||||
<span className="page-hero__stat"><b>{schedules.length}</b> รอบเวลา</span>
|
||||
<span className="page-hero__stat"><b>{provinceSet.size}</b> จังหวัด</span>
|
||||
<span className="page-hero__stat">
|
||||
<b>{next ?? "—"}</b> {next ? "รอบถัดไป" : "ไม่มีรอบวันนี้"}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="route-hero__actions">
|
||||
<Link href="/routes" className="route-hero__back">
|
||||
← กลับสายทั้งหมด
|
||||
</Link>
|
||||
<Link href="/routes" className="route-hero__back">← กลับสายทั้งหมด</Link>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div className="container">
|
||||
{/* เลือกสายรถ (จาก design: route-select) */}
|
||||
<div className="toolbar">
|
||||
<RouteSelect
|
||||
routes={allRoutes.map((r) => ({ route_id: r.route_id, name_th: r.name_th }))}
|
||||
current={route.route_id}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* ติดต่อ */}
|
||||
<section>
|
||||
<h2 className="section-title">ติดต่อ</h2>
|
||||
{Array.isArray((route.contact as any)?.phones) && (route.contact as any).phones.length > 0 ? (
|
||||
<ul>
|
||||
{(route.contact as any).phones.map((p: any, i: number) => (
|
||||
<li key={i}>
|
||||
<strong>{p.label || "โทร"}:</strong> <a href={`tel:${p.number}`}>{p.number}</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p className="muted">ไม่พบเบอร์ติดต่อ</p>
|
||||
{/* รถประจำสาย + ติดต่อผู้ประกอบการ (การ์ดเดียว) */}
|
||||
{(photo || cap || qr || phones.length > 0 || lineUrl) && (
|
||||
<section className="vehicle-card" aria-label="รถประจำสายและติดต่อผู้ประกอบการ">
|
||||
{photo && (
|
||||
<img className="vehicle-card__img" src={photo} alt={`รถของสาย ${route.route_id}`} />
|
||||
)}
|
||||
<div className="vehicle-card__meta">
|
||||
<p className="vehicle-card__label">รถประจำสาย</p>
|
||||
{cap?.vehicle_title && <h2>{cap.vehicle_title}</h2>}
|
||||
{cap?.vehicle_desc && <p>{cap.vehicle_desc}</p>}
|
||||
{!cap?.vehicle_title && !cap?.vehicle_desc && (
|
||||
<p className="muted">สาย {route.route_id} · {route.vehicle_type}</p>
|
||||
)}
|
||||
</section>
|
||||
</section>
|
||||
|
||||
{photo && (
|
||||
<section aria-label="รถประจำสาย">
|
||||
<h2 className="section-title">รถประจำสาย</h2>
|
||||
<img className="route-photo" src={photo} alt={`รถของสาย ${route.route_id}`} />
|
||||
</section>
|
||||
)}
|
||||
|
||||
<section className="route-map-section">
|
||||
<div className="route-map-section__head">
|
||||
<h2 className="section-title">เส้นทางวิ่ง</h2>
|
||||
<span className="route-map-section__legend">
|
||||
<span><i className="dot dot--start" /> ต้นทาง</span>
|
||||
<span><i className="dot dot--mid" /> จุดผ่าน</span>
|
||||
<span><i className="dot dot--end" /> ปลายทาง</span>
|
||||
</span>
|
||||
</div>
|
||||
{mapPoints.length >= 1 ? (
|
||||
<div className="map-wrap map-wrap--soft route-map">
|
||||
<LazyMapView points={mapPoints} path={path} />
|
||||
</div>
|
||||
) : (
|
||||
<p className="muted route-map-empty">— ยังไม่มีพิกัดสำหรับจุดจอดของสายนี้ —</p>
|
||||
</div>
|
||||
<div className="vehicle-card__contact">
|
||||
{qr && (
|
||||
<a className="contact-item contact-item--qr" href={lineUrl || "#"} target="_blank" rel="noopener">
|
||||
<img className="qr-img" src={qr} alt={`QR ติดตามสาย ${route.route_id}`} />
|
||||
<span className="txt"><strong>สแกนติดตาม</strong><span>LINE / กลุ่มข่าวสาย</span></span>
|
||||
</a>
|
||||
)}
|
||||
{phones.map((p, i) => (
|
||||
<a key={i} className="contact-item" href={`tel:${p.number.replace(/\s/g, "")}`}>
|
||||
<span className="ic-wrap"><Icon name="phone" size={20} /></span>
|
||||
<span className="txt"><strong>{p.label || "โทร"}</strong><span>{p.number}</span></span>
|
||||
</a>
|
||||
))}
|
||||
{lineUrl && (
|
||||
<a className="contact-item" href={lineUrl} target="_blank" rel="noopener">
|
||||
<span className="ic-wrap tone-green"><Icon name="message-circle" size={20} /></span>
|
||||
<span className="txt"><strong>LINE</strong><span>ติดตามข่าวสารสาย</span></span>
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2 className="section-title">จุดจอดตามลำดับ ({stops.length})</h2>
|
||||
<ol className="stop-timeline">
|
||||
{stops.map((s, i) => {
|
||||
const tone = TONES[i % TONES.length];
|
||||
const isStart = i === 0;
|
||||
const isEnd = i === stops.length - 1;
|
||||
const hasCoord = coordById.has(s.station_id);
|
||||
const stopHref = s.code ? `/stops/${encodeURIComponent(s.code)}` : null;
|
||||
return (
|
||||
<li key={s.station_id} className={`stop-node stop-node--${tone}`}>
|
||||
<span className="stop-node__line" aria-hidden />
|
||||
<span className={`stop-node__bullet ${isStart ? "is-start" : isEnd ? "is-end" : ""}`}>
|
||||
{s.stop_sequence}
|
||||
</span>
|
||||
<div className="stop-node__body">
|
||||
<div className="stop-node__head">
|
||||
{stopHref ? (
|
||||
<Link href={stopHref} className="stop-node__title">
|
||||
{s.name_th}
|
||||
</Link>
|
||||
) : (
|
||||
<span className="stop-node__title">{s.name_th}</span>
|
||||
)}
|
||||
{isStart && <span className="chip-soft chip-soft--mint">ต้นทาง</span>}
|
||||
{isEnd && <span className="chip-soft chip-soft--pink">ปลายทาง</span>}
|
||||
</div>
|
||||
<div className="stop-node__meta">
|
||||
<span className="chip-soft chip-soft--sky">{s.station_type}</span>
|
||||
{(s.city_th || s.province_th) && (
|
||||
<span className="stop-node__loc">
|
||||
<Icon name="map-pin" size={13} className="icon" /> {[s.city_th, s.province_th].filter(Boolean).join(" · ")}
|
||||
</span>
|
||||
)}
|
||||
{!hasCoord && (
|
||||
<span className="stop-node__warn">ไม่มีพิกัดบนแผนที่</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{stopHref ? (
|
||||
<Link href={stopHref} className="stop-node__arrow" aria-label="ดูจุดจอด">→</Link>
|
||||
) : (
|
||||
<span className="stop-node__arrow" aria-hidden>→</span>
|
||||
)}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ol>
|
||||
</section>
|
||||
{/* แผนที่เส้นทาง + จุดจอดตามเส้นทาง */}
|
||||
<section className="route-map-section">
|
||||
<div className="route-map-section__head">
|
||||
<h2 className="section-title">เส้นทางเดินรถ</h2>
|
||||
<span className="route-map-section__legend">
|
||||
<span><i className="dot dot--start" /> ต้นทาง</span>
|
||||
<span><i className="dot dot--mid" /> จุดผ่าน</span>
|
||||
<span><i className="dot dot--end" /> ปลายทาง</span>
|
||||
</span>
|
||||
</div>
|
||||
{mapPoints.length >= 1 ? (
|
||||
<div className="map-wrap map-wrap--soft route-map">
|
||||
<LazyMapView points={mapPoints} path={path} />
|
||||
</div>
|
||||
) : (
|
||||
<p className="muted route-map-empty">— ยังไม่มีพิกัดสำหรับจุดจอดของสายนี้ —</p>
|
||||
)}
|
||||
|
||||
<section>
|
||||
<h2 className="section-title">ตารางเวลา ({schedules.length})</h2>
|
||||
{schedules.length === 0 ? (
|
||||
<p className="muted">ยังไม่มีข้อมูลตารางเวลา</p>
|
||||
) : (
|
||||
<div className="schedule-list">
|
||||
{schedules.map((s, i) => {
|
||||
{stops.length > 0 && (
|
||||
<div className="km-wrap">
|
||||
<h3 className="km-wrap__title">จุดจอดตามเส้นทาง (กม. จากต้นทาง)</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>
|
||||
))}
|
||||
</ol>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
|
||||
{/* จุดจอดตามลำดับ (รายละเอียด) */}
|
||||
<section>
|
||||
<h2 className="section-title">จุดจอดตามลำดับ ({stops.length})</h2>
|
||||
<ol className="stop-timeline">
|
||||
{stops.map((s, i) => {
|
||||
const tone = TONES[i % TONES.length];
|
||||
const isStart = i === 0;
|
||||
const isEnd = i === stops.length - 1;
|
||||
const hasCoord = coordById.has(s.station_id);
|
||||
const stopHref = s.code ? `/stops/${encodeURIComponent(s.code)}` : null;
|
||||
return (
|
||||
<article key={s.id} className={`schedule-card schedule-card--${tone}`}>
|
||||
<span className="schedule-card__rail" aria-hidden />
|
||||
<div className="schedule-card__head">
|
||||
<div className={`schedule-card__route ${tone}`}>
|
||||
<span>{s.station_name_th}</span>
|
||||
<small>จุดต้นทาง</small>
|
||||
<li key={s.station_id} className={`stop-node stop-node--${tone}`}>
|
||||
<span className="stop-node__line" aria-hidden />
|
||||
<span className={`stop-node__bullet ${isStart ? "is-start" : isEnd ? "is-end" : ""}`}>
|
||||
{s.stop_sequence}
|
||||
</span>
|
||||
<div className="stop-node__body">
|
||||
<div className="stop-node__head">
|
||||
{stopHref ? (
|
||||
<Link href={stopHref} className="stop-node__title">{s.name_th}</Link>
|
||||
) : (
|
||||
<span className="stop-node__title">{s.name_th}</span>
|
||||
)}
|
||||
{isStart && <span className="chip-soft chip-soft--mint">ต้นทาง</span>}
|
||||
{isEnd && <span className="chip-soft chip-soft--pink">ปลายทาง</span>}
|
||||
</div>
|
||||
<div className="schedule-card__meta">
|
||||
<strong>{s.direction_note || "ทุกทิศทาง"}</strong>
|
||||
{s.schedule_note && <span>{s.schedule_note}</span>}
|
||||
<div className="stop-node__meta">
|
||||
<span className="chip-soft chip-soft--sky">{s.station_type}</span>
|
||||
{(s.city_th || s.province_th) && (
|
||||
<span className="stop-node__loc">
|
||||
<Icon name="map-pin" size={13} className="icon" /> {[s.city_th, s.province_th].filter(Boolean).join(" · ")}
|
||||
</span>
|
||||
)}
|
||||
{!hasCoord && <span className="stop-node__warn">ไม่มีพิกัดบนแผนที่</span>}
|
||||
</div>
|
||||
</div>
|
||||
{s.departure_times.length === 0 ? (
|
||||
<span className="schedule-card__empty">— ยังไม่มีรอบ —</span>
|
||||
{stopHref ? (
|
||||
<Link href={stopHref} className="stop-node__arrow" aria-label="ดูจุดจอด">→</Link>
|
||||
) : (
|
||||
<div className="schedule-card__times">
|
||||
{s.departure_times.map((t, j) => (
|
||||
<span key={`${s.id}-${j}`} className="schedule-card__time"><Icon name="clock" size={13} className="icon" /> {t}</span>
|
||||
))}
|
||||
</div>
|
||||
<span className="stop-node__arrow" aria-hidden>→</span>
|
||||
)}
|
||||
</article>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
{/* ตารางเวลา */}
|
||||
<section>
|
||||
<h2 className="section-title">ตารางเวลา ({schedules.length})</h2>
|
||||
{schedules.length === 0 ? (
|
||||
<p className="muted">ยังไม่มีข้อมูลตารางเวลา</p>
|
||||
) : (
|
||||
<div className="schedule-list">
|
||||
{schedules.map((s, i) => {
|
||||
const tone = TONES[i % TONES.length];
|
||||
return (
|
||||
<article key={s.id} className={`schedule-card schedule-card--${tone}`}>
|
||||
<span className="schedule-card__rail" aria-hidden />
|
||||
<div className="schedule-card__head">
|
||||
<div className={`schedule-card__route ${tone}`}>
|
||||
<span>{s.station_name_th}</span>
|
||||
<small>จุดต้นทาง</small>
|
||||
</div>
|
||||
<div className="schedule-card__meta">
|
||||
<strong>{s.direction_note || "ทุกทิศทาง"}</strong>
|
||||
{s.schedule_note && <span>{s.schedule_note}</span>}
|
||||
</div>
|
||||
</div>
|
||||
{s.departure_times.length === 0 ? (
|
||||
<span className="schedule-card__empty">— ยังไม่มีรอบ —</span>
|
||||
) : (
|
||||
<div className="schedule-card__times">
|
||||
{s.departure_times.map((t, j) => (
|
||||
<span key={`${s.id}-${j}`} className="schedule-card__time"><Icon name="clock" size={13} className="icon" /> {t}</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</article>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -1,12 +1,26 @@
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
import { api, isApiNotFoundError, resolveFileUrl, type Schedule, type StopDetail } from "@/lib/api";
|
||||
import { api, isApiNotFoundError, type Schedule, type StopDetail } from "@/lib/api";
|
||||
import LazyMapView from "@/components/LazyMapView";
|
||||
import { LiveClock } from "@/components/LiveClock";
|
||||
import { VisitTracker } from "@/lib/visit-tracker";
|
||||
import { stopPhoto } from "@/lib/images";
|
||||
import { Icon } from "@/components/Icons";
|
||||
|
||||
const TONES = ["sky", "purple", "pink", "mint", "amber"] as const;
|
||||
const TYPE_LABEL: Record<string, string> = {
|
||||
main_terminal: "สถานีขนส่ง",
|
||||
local_stop: "ป้ายหลัก",
|
||||
market: "ตลาด/ชุมชน",
|
||||
private_stop: "จุดรับส่ง",
|
||||
other: "อื่น ๆ",
|
||||
};
|
||||
|
||||
const GROUP_TONE: Record<string, string> = {
|
||||
bangkok: "sky",
|
||||
interprovincial: "purple",
|
||||
in_province: "pink",
|
||||
municipal: "mint",
|
||||
};
|
||||
|
||||
type StopDetailsPageProps = {
|
||||
searchParams: Promise<{ code?: string }>;
|
||||
@@ -23,9 +37,7 @@ export default async function StopDetailsPage({ searchParams }: StopDetailsPageP
|
||||
stop = await api.stop(code);
|
||||
({ items: schedules } = await api.schedules({ stop_code: stop.code }));
|
||||
} catch (error) {
|
||||
if (isApiNotFoundError(error)) {
|
||||
notFound();
|
||||
}
|
||||
if (isApiNotFoundError(error)) notFound();
|
||||
stop = null;
|
||||
schedules = [];
|
||||
}
|
||||
@@ -42,100 +54,145 @@ export default async function StopDetailsPage({ searchParams }: StopDetailsPageP
|
||||
</main>
|
||||
);
|
||||
}
|
||||
const place = [stop.city_th, stop.province_th].filter(Boolean).join(" / ") || "—";
|
||||
|
||||
const place = [stop.city_th, stop.province_th].filter(Boolean).join(" · ") || "—";
|
||||
const hasMap = stop.lat != null && stop.lng != null;
|
||||
const mapPoints = hasMap
|
||||
? [{ id: stop.id, lat: stop.lat as number, lng: stop.lng as number, label: stop.name_th, code: stop.code }]
|
||||
: [];
|
||||
|
||||
// รูปป้ายจาก design (.image/stops/<code>.jpg) — สำคัญกว่า backend images
|
||||
const designPhoto = stopPhoto(stop.code);
|
||||
const typeLabel = TYPE_LABEL[stop.station_type] ?? stop.station_type;
|
||||
const routes = stop.routes ?? [];
|
||||
|
||||
// route_id -> เวลาออกทั้งหมดที่ป้ายนี้
|
||||
const timesByRoute = new Map<string, string[]>();
|
||||
for (const s of schedules) {
|
||||
const l = timesByRoute.get(s.route_id) ?? [];
|
||||
l.push(...s.departure_times);
|
||||
timesByRoute.set(s.route_id, l);
|
||||
}
|
||||
const allTimes = schedules.flatMap((s) => s.departure_times);
|
||||
|
||||
return (
|
||||
<main className="page">
|
||||
<VisitTracker path={`/stops/details?code=${stop.code}`} />
|
||||
<section className="hero">
|
||||
<span className="pill">{stop.station_type}</span>
|
||||
<h1 style={{ marginTop: 10 }}>{stop.name_th}</h1>
|
||||
<p className="muted"><Icon name="map-pin" size={14} className="icon" /> {place}{hasMap ? ` · ${stop.lat?.toFixed(4)}, ${stop.lng?.toFixed(4)}` : ""}</p>
|
||||
</section>
|
||||
<div className="stop-detail__split">
|
||||
{designPhoto ? (
|
||||
<div className="stop-detail__gallery">
|
||||
<img className="stop-detail__hero-img" src={designPhoto} alt={stop.name_th} />
|
||||
|
||||
<div className="container">
|
||||
<p className="breadcrumb">
|
||||
<Link href="/">หน้าแรก</Link> / <Link href="/stops">ป้ายหยุดรถ</Link> /{" "}
|
||||
<span>{stop.name_th}</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="container">
|
||||
<section className="stop-hero">
|
||||
<div className="stop-hero__main">
|
||||
<h1 className="stop-hero__title">
|
||||
<Icon name="map-pin" size={24} className="icon" /> {stop.name_th}
|
||||
</h1>
|
||||
<p className="stop-hero__sub">
|
||||
<Icon name="map-pin" size={14} className="icon" /> {place}
|
||||
{hasMap ? ` · ${stop.lat?.toFixed(4)}, ${stop.lng?.toFixed(4)}` : ""}
|
||||
</p>
|
||||
<div className="stop-hero__meta">
|
||||
<span className="meta-pill purple">{typeLabel}</span>
|
||||
{stop.province_th && <span className="meta-pill sky">{stop.province_th}</span>}
|
||||
{hasMap && <span className="meta-pill mint">มีพิกัดบนแผนที่</span>}
|
||||
</div>
|
||||
<div className="stop-hero__metrics">
|
||||
<div className="stop-metric">
|
||||
<p className="stop-metric__label">สายที่ผ่าน</p>
|
||||
<p className="stop-metric__value">{routes.length}</p>
|
||||
</div>
|
||||
<div className="stop-metric">
|
||||
<p className="stop-metric__label">ประเภทป้าย</p>
|
||||
<p className="stop-metric__value">{typeLabel}</p>
|
||||
</div>
|
||||
<div className="stop-metric">
|
||||
<p className="stop-metric__label">จังหวัด</p>
|
||||
<p className="stop-metric__value">{stop.province_th ?? "—"}</p>
|
||||
</div>
|
||||
<div className="stop-metric">
|
||||
<p className="stop-metric__label">รอบเวลา</p>
|
||||
<p className="stop-metric__value">{allTimes.length}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : stop.images.length > 0 ? (
|
||||
<div className="stop-detail__gallery">
|
||||
<img
|
||||
className="stop-detail__hero-img"
|
||||
src={resolveFileUrl(stop.images[0].url_path)}
|
||||
alt={(stop.images[0].meta as { alt_th?: string } | undefined)?.alt_th ?? stop.name_th}
|
||||
/>
|
||||
{stop.images.length > 1 && (
|
||||
<div className="stop-detail__thumbs">
|
||||
{stop.images.slice(1, 5).map((img) => (
|
||||
<img key={img.id} src={resolveFileUrl(img.url_path)} alt={stop.name_th} />
|
||||
))}
|
||||
<div className="stop-hero__side">
|
||||
{designPhoto ? (
|
||||
<img className="stop-hero__photo" src={designPhoto} alt={stop.name_th} />
|
||||
) : (
|
||||
<div className="stop-hero__photo stop-hero__photo--empty">
|
||||
<Icon name="camera" size={28} className="icon" /> ยังไม่มีรูปป้ายนี้
|
||||
</div>
|
||||
)}
|
||||
<LiveClock times={allTimes} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="stop-detail__gallery stop-detail__gallery--empty">
|
||||
<div className="stop-detail__placeholder"><Icon name="camera" size={20} className="icon" /> ยังไม่มีรูปป้ายนี้</div>
|
||||
</section>
|
||||
|
||||
<div className="stop-layout">
|
||||
<div className="stop-panel">
|
||||
<h2 className="section-title">สายรถที่ผ่านจุดนี้</h2>
|
||||
{routes.length === 0 ? (
|
||||
<p className="muted">ยังไม่มีข้อมูลสายที่ผ่าน</p>
|
||||
) : (
|
||||
<ul className="route-expander-list">
|
||||
{routes.map((r) => {
|
||||
const times = timesByRoute.get(r.route_id) ?? [];
|
||||
const tone = GROUP_TONE[r.route_group_code] ?? "purple";
|
||||
return (
|
||||
<li key={r.route_id}>
|
||||
<details className="route-expander">
|
||||
<summary>
|
||||
<span className={`route-expander__id ${tone}`}>{r.route_id}</span>
|
||||
<span className="route-expander__name">{r.name_th}</span>
|
||||
<span className="route-expander__count">{times.length} รอบ</span>
|
||||
</summary>
|
||||
<div className="route-expander__body">
|
||||
<Link href={`/routes/${encodeURIComponent(r.route_id)}`} className="route-expander__link">
|
||||
ดูรายละเอียดสาย {r.route_id} →
|
||||
</Link>
|
||||
{times.length === 0 ? (
|
||||
<p className="muted">ยังไม่มีรอบเวลา</p>
|
||||
) : (
|
||||
<div className="route-expander__times">
|
||||
{times.map((t, j) => (
|
||||
<span key={j} className="time-chip"><Icon name="clock" size={12} className="icon" /> {t}</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</details>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{hasMap ? (
|
||||
<div className="stop-detail__map">
|
||||
<LazyMapView points={mapPoints} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="stop-detail__map stop-detail__map--empty">
|
||||
<div className="stop-detail__placeholder"><Icon name="map" size={20} className="icon" /> ยังไม่มีพิกัดของป้ายนี้</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<h2 className="section-title">ตารางเวลาที่จุดนี้</h2>
|
||||
{schedules.length === 0 ? (
|
||||
<p className="muted">ยังไม่มีข้อมูล</p>
|
||||
) : (
|
||||
<div className="schedule-list">
|
||||
{schedules.map((s, i) => {
|
||||
const tone = TONES[i % TONES.length];
|
||||
return (
|
||||
<article key={s.id} className={`schedule-card schedule-card--${tone}`}>
|
||||
<div className="schedule-card__rail" />
|
||||
<div className="schedule-card__head">
|
||||
<Link
|
||||
href={`/routes/${encodeURIComponent(s.route_id)}`}
|
||||
className={`schedule-card__route ${tone}`}
|
||||
>
|
||||
<span className="schedule-card__route-label">เส้นทาง</span>
|
||||
<span className="schedule-card__route-id">{s.route_id}</span>
|
||||
</Link>
|
||||
<div className="schedule-card__meta">
|
||||
<span className="schedule-card__direction">
|
||||
<Icon name="globe" size={13} className="icon" />
|
||||
{s.direction_note || "ไม่ระบุทิศทาง"}
|
||||
</span>
|
||||
{s.schedule_note && (
|
||||
<span className="schedule-card__note"><Icon name="message-circle" size={13} className="icon" /> {s.schedule_note}</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="schedule-card__times">
|
||||
{s.departure_times.length === 0 ? (
|
||||
<span className="schedule-card__empty">— ยังไม่มีรอบ —</span>
|
||||
) : (
|
||||
s.departure_times.map((t, j) => (
|
||||
<span key={j} className="schedule-card__time"><Icon name="clock" size={13} className="icon" /> {t}</span>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</article>
|
||||
);
|
||||
})}
|
||||
|
||||
<aside className="stop-panel">
|
||||
<h2 className="section-title">แผนที่และข้อมูลป้าย</h2>
|
||||
{hasMap ? (
|
||||
<div className="map-wrap map-wrap--soft">
|
||||
<LazyMapView points={mapPoints} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="stop-panel__empty"><Icon name="map" size={20} className="icon" /> ยังไม่มีพิกัดของป้ายนี้</div>
|
||||
)}
|
||||
<div className="stop-chips">
|
||||
{routes.map((r) => (
|
||||
<Link
|
||||
key={r.route_id}
|
||||
href={`/routes/${encodeURIComponent(r.route_id)}`}
|
||||
className={`chip-soft chip-soft--${GROUP_TONE[r.route_group_code] ?? "sky"}`}
|
||||
>
|
||||
{r.route_id} · {r.vehicle_type}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -6,40 +6,55 @@ import { Icon, type IconName } from "@/components/Icons";
|
||||
|
||||
const TONES = ["sky", "purple", "pink", "mint", "amber"] as const;
|
||||
const TYPE_TONE: Record<string, (typeof TONES)[number]> = {
|
||||
terminal: "purple",
|
||||
station: "sky",
|
||||
pickup: "amber",
|
||||
main_terminal: "purple",
|
||||
local_stop: "sky",
|
||||
market: "pink",
|
||||
landmark: "mint",
|
||||
private_stop: "amber",
|
||||
other: "mint",
|
||||
};
|
||||
const TYPE_ICON: Record<string, IconName> = {
|
||||
terminal: "bus-front",
|
||||
station: "map-pin",
|
||||
pickup: "bus",
|
||||
main_terminal: "bus-front",
|
||||
local_stop: "map-pin",
|
||||
market: "store",
|
||||
landmark: "map-pin",
|
||||
private_stop: "bus",
|
||||
other: "map-pin",
|
||||
};
|
||||
const TYPE_LABEL: Record<string, string> = {
|
||||
terminal: "สถานีขนส่ง",
|
||||
station: "ป้ายหลัก",
|
||||
pickup: "จุดรับส่ง",
|
||||
main_terminal: "สถานีขนส่ง",
|
||||
local_stop: "ป้ายหลัก",
|
||||
market: "ตลาด/ชุมชน",
|
||||
landmark: "จุดสังเกต",
|
||||
private_stop: "จุดรับส่ง",
|
||||
other: "อื่น ๆ",
|
||||
};
|
||||
|
||||
export default async function StopsPage() {
|
||||
const { items } = await api.stops().catch(() => ({ items: [] }));
|
||||
export default async function StopsPage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<{ q?: string }>;
|
||||
}) {
|
||||
const sp = await searchParams;
|
||||
const q = sp.q ?? "";
|
||||
const { items } = await api.stops(q ? { q } : {}).catch(() => ({ items: [] }));
|
||||
|
||||
const points = items
|
||||
.filter((s) => s.lat != null && s.lng != null)
|
||||
.map((s) => ({ id: s.id, lat: s.lat as number, lng: s.lng as number, label: s.name_th, code: s.code }));
|
||||
|
||||
const typeCounts = items.reduce<Record<string, number>>((acc, s) => {
|
||||
acc[s.station_type] = (acc[s.station_type] ?? 0) + 1;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
return (
|
||||
<main className="page">
|
||||
<VisitTracker path="/stops" />
|
||||
|
||||
<div className="container">
|
||||
<p className="breadcrumb">
|
||||
<Link href="/">หน้าแรก</Link> / <span>ป้ายหยุดรถ</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<section className="page-hero">
|
||||
<div className="page-hero__blob page-hero__blob--a" />
|
||||
<div className="page-hero__blob page-hero__blob--b" />
|
||||
@@ -60,80 +75,73 @@ export default async function StopsPage() {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{points.length > 0 && (
|
||||
<div className="map-wrap map-wrap--soft">
|
||||
<LazyMapView points={points} />
|
||||
</div>
|
||||
)}
|
||||
<div className="container">
|
||||
{points.length > 0 && !q && (
|
||||
<div className="map-wrap map-wrap--soft">
|
||||
<LazyMapView points={points} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="toolbar">
|
||||
<div className="toolbar__search">
|
||||
<Icon name="search" size={16} className="icon" />
|
||||
<input placeholder="ค้นหาชื่อป้าย หรือจังหวัด…" disabled />
|
||||
<div className="toolbar">
|
||||
<form className="toolbar__search" action="/stops" method="get" role="search">
|
||||
<Icon name="search" size={16} className="icon" />
|
||||
<input name="q" placeholder="ค้นหาชื่อป้าย หรือจังหวัด…" defaultValue={q} />
|
||||
{q && (
|
||||
<Link className="toolbar__clear" href="/stops" aria-label="ล้างคำค้นหา">✕</Link>
|
||||
)}
|
||||
<button type="submit" className="toolbar__submit">ค้นหา</button>
|
||||
</form>
|
||||
<div className="toolbar__chips">
|
||||
{Object.entries(typeCounts).map(([t, n]) => (
|
||||
<span key={t} className={`chip-soft chip-soft--${TYPE_TONE[t] ?? "sky"}`}>
|
||||
<Icon name={TYPE_ICON[t] ?? "map-pin"} size={13} className="icon" /> {TYPE_LABEL[t] ?? t} · {n}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="toolbar__chips">
|
||||
{Object.entries(typeCounts).map(([t, n]) => (
|
||||
<span key={t} className={`chip-soft chip-soft--${TYPE_TONE[t] ?? "sky"}`}>
|
||||
<Icon name={TYPE_ICON[t] ?? "map-pin"} size={13} className="icon" /> {TYPE_LABEL[t] ?? t} · {n}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="tile-grid">
|
||||
{items.map((s, i) => {
|
||||
const tone = TYPE_TONE[s.station_type] ?? TONES[i % TONES.length];
|
||||
const icon = TYPE_ICON[s.station_type] ?? "map-pin";
|
||||
const place = [s.city_th, s.province_th].filter(Boolean).join(" · ");
|
||||
const stopHref = s.code ? `/stops/${encodeURIComponent(s.code)}` : null;
|
||||
return (
|
||||
stopHref ? (
|
||||
<Link
|
||||
key={s.id}
|
||||
href={stopHref}
|
||||
className={`tile tile--${tone}`}
|
||||
>
|
||||
<div className={`tile__badge tile__badge--${tone}`}>
|
||||
<Icon name={icon} size={26} />
|
||||
</div>
|
||||
<div className="tile__body">
|
||||
<p className="tile__title">{s.name_th}</p>
|
||||
<p className="tile__meta">{place || "—"}</p>
|
||||
<div className="tile__chips">
|
||||
<span className={`chip-soft chip-soft--${tone}`}>
|
||||
{TYPE_LABEL[s.station_type] ?? s.station_type}
|
||||
</span>
|
||||
{s.lat != null && s.lng != null && (
|
||||
<span className="chip-soft chip-soft--mint"><Icon name="map-pin" size={13} className="icon" /> บนแผนที่</span>
|
||||
)}
|
||||
{items.length === 0 ? (
|
||||
<p className="muted">ไม่พบป้ายที่ตรงกับ “{q}”</p>
|
||||
) : (
|
||||
<div className="tile-grid">
|
||||
{items.map((s, i) => {
|
||||
const tone = TYPE_TONE[s.station_type] ?? TONES[i % TONES.length];
|
||||
const icon = TYPE_ICON[s.station_type] ?? "map-pin";
|
||||
const place = [s.city_th, s.province_th].filter(Boolean).join(" · ");
|
||||
const stopHref = s.code ? `/stops/${encodeURIComponent(s.code)}` : null;
|
||||
const body = (
|
||||
<>
|
||||
<div className={`tile__badge tile__badge--${tone}`}>
|
||||
<Icon name={icon} size={26} />
|
||||
</div>
|
||||
</div>
|
||||
<span className="tile__arrow" aria-hidden>→</span>
|
||||
</Link>
|
||||
) : (
|
||||
<div key={s.id} className={`tile tile--${tone} tile--disabled`}>
|
||||
<div className={`tile__badge tile__badge--${tone}`}>
|
||||
<Icon name={icon} size={26} />
|
||||
</div>
|
||||
<div className="tile__body">
|
||||
<p className="tile__title">{s.name_th}</p>
|
||||
<p className="tile__meta">{place || "—"}</p>
|
||||
<div className="tile__chips">
|
||||
<span className={`chip-soft chip-soft--${tone}`}>
|
||||
{TYPE_LABEL[s.station_type] ?? s.station_type}
|
||||
</span>
|
||||
{s.lat != null && s.lng != null && (
|
||||
<span className="chip-soft chip-soft--mint"><Icon name="map-pin" size={13} className="icon" /> บนแผนที่</span>
|
||||
)}
|
||||
<div className="tile__body">
|
||||
<p className="tile__title">{s.name_th}</p>
|
||||
<p className="tile__meta">{place || "—"}</p>
|
||||
<div className="tile__chips">
|
||||
<span className={`chip-soft chip-soft--${tone}`}>
|
||||
{TYPE_LABEL[s.station_type] ?? s.station_type}
|
||||
</span>
|
||||
{s.lat != null && s.lng != null && (
|
||||
<span className="chip-soft chip-soft--mint"><Icon name="map-pin" size={13} className="icon" /> บนแผนที่</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<span className="tile__arrow" aria-hidden>→</span>
|
||||
</>
|
||||
);
|
||||
return stopHref ? (
|
||||
<Link key={s.id} href={stopHref} className={`tile tile--${tone}`}>
|
||||
{body}
|
||||
</Link>
|
||||
) : (
|
||||
<div key={s.id} className={`tile tile--${tone} tile--disabled`}>
|
||||
{body}
|
||||
</div>
|
||||
<span className="tile__arrow" aria-hidden>→</span>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
})}
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ export function Header() {
|
||||
<span className="sep">/</span>
|
||||
<span className={lang === "en" ? "on" : ""}>EN</span>
|
||||
</button>
|
||||
<Link href="/routes" className="cta-pill">{t("cta")}</Link>
|
||||
<Link href="/check" className="cta-pill">{t("cta")}</Link>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
/** นาฬิกาสด ณ ป้าย + คำนวณเที่ยวถัดไปอัตโนมัติ (จาก design: live-clock-card) */
|
||||
export function LiveClock({ times }: { times: string[] }) {
|
||||
const [now, setNow] = useState("--:--");
|
||||
const [next, setNext] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const tick = () => {
|
||||
const d = new Date();
|
||||
setNow(`${String(d.getHours()).padStart(2, "0")}:${String(d.getMinutes()).padStart(2, "0")}`);
|
||||
const cur = d.getHours() * 60 + d.getMinutes();
|
||||
const n =
|
||||
[...times]
|
||||
.sort()
|
||||
.find((t) => {
|
||||
const [h, m] = t.split(":").map(Number);
|
||||
return h * 60 + m >= cur;
|
||||
}) ?? null;
|
||||
setNext(n);
|
||||
};
|
||||
tick();
|
||||
const id = setInterval(tick, 30_000);
|
||||
return () => clearInterval(id);
|
||||
}, [times]);
|
||||
|
||||
return (
|
||||
<div className="live-clock-card">
|
||||
<div>
|
||||
<p className="live-clock-title">เวลาปัจจุบัน ณ ป้ายนี้</p>
|
||||
<p className="live-clock-time">{now}</p>
|
||||
</div>
|
||||
<p className="live-clock-note">
|
||||
<span className="live-dot" aria-hidden />
|
||||
{next ? `เที่ยวถัดไป ${next}` : "กำลังคำนวณเที่ยวถัดไปอัตโนมัติ"}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Icon } from "@/components/Icons";
|
||||
|
||||
type Props = {
|
||||
routes: { route_id: string; name_th: string }[];
|
||||
current: string;
|
||||
/** คืน URL ปลายทางเมื่อเลือกสาย (default: /routes/:id) */
|
||||
to?: (routeId: string) => string;
|
||||
};
|
||||
|
||||
/** เลือกสายรถ — เปลี่ยนสายโดยไม่ต้องกลับหน้ารายการ (จาก design: route-select) */
|
||||
export function RouteSelect({ routes, current, to }: Props) {
|
||||
const router = useRouter();
|
||||
return (
|
||||
<div className="route-select-wrap">
|
||||
<label htmlFor="route-select" className="route-select-wrap__label">
|
||||
<Icon name="bus" size={14} className="icon" /> เลือกสายรถ
|
||||
</label>
|
||||
<div className="select-box select-box--toolbar">
|
||||
<Icon name="bus" size={18} className="select-box__icon" />
|
||||
<select
|
||||
id="route-select"
|
||||
value={current}
|
||||
onChange={(e) => {
|
||||
const v = e.target.value;
|
||||
router.push(to ? to(v) : `/routes/${encodeURIComponent(v)}`);
|
||||
}}
|
||||
>
|
||||
{routes.map((r) => (
|
||||
<option key={r.route_id} value={r.route_id}>
|
||||
{r.route_id} · {r.name_th}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<Icon name="arrow-right" size={18} className="select-box__chevron" />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
{
|
||||
"101": {
|
||||
"vehicle_title": "รถสองแถวประจำเส้นทาง",
|
||||
"vehicle_desc": "ประมาณ 30 ที่นั่ง · ให้บริการตลอดเส้นทางอ่างทอง–ป่าโมก–อยุธยา",
|
||||
"line_note": "ติดตามข่าวสาย 101 · รถออกก่อนเวลาบ่อยครั้ง · รถขาดช่วง",
|
||||
"qr": "/images/qrcode/101.png"
|
||||
},
|
||||
"1011": {
|
||||
"vehicle_title": "รถเมล์ประจำเส้นทาง",
|
||||
"vehicle_desc": "รถเมล์ ประมาณ 30 ที่นั่ง รถมีเที่ยว เช้า เที่บง เย็น",
|
||||
"line_note": "",
|
||||
"qr": ""
|
||||
},
|
||||
"15": {
|
||||
"vehicle_title": "รถมินิบัส 20 ที่นั่ง",
|
||||
"vehicle_desc": "ปัจจุบันส่วนใหญ่วิ่งแค่ป่าโมก หมอชิตใหม่ เหลือแค่รถ เบอร์ 20 ที่กลับถึงอ่างทอง บขส.อ่างทองมีรถออกแค่เช้ามืดถึงโมงเช้า",
|
||||
"line_note": "",
|
||||
"qr": "/images/qrcode/15.JPG"
|
||||
},
|
||||
"2194": {
|
||||
"vehicle_title": "รถสองแถวประจำเส้นทาง",
|
||||
"vehicle_desc": "รถสองแถวเช้ามืดและเย็น ผ่านอ่างทองแค่สามแยกข้ามสะพานโผงเผงและวัดถนน",
|
||||
"line_note": "",
|
||||
"qr": ""
|
||||
},
|
||||
"2231": {
|
||||
"vehicle_title": "รถสองแถวประจำเส้นทาง",
|
||||
"vehicle_desc": "มีเที่ยวเดียว เช้า-เย็น",
|
||||
"line_note": "",
|
||||
"qr": ""
|
||||
},
|
||||
"324": {
|
||||
"vehicle_title": "รถสองแถวประจำเส้นทาง",
|
||||
"vehicle_desc": "รถมีเที่ยว เช้า อย่างเดียว วิ่งสุดสายแค่วัดไชโย",
|
||||
"line_note": "",
|
||||
"qr": ""
|
||||
},
|
||||
"464": {
|
||||
"vehicle_title": "",
|
||||
"vehicle_desc": "",
|
||||
"line_note": "",
|
||||
"qr": "/images/qrcode/464.jpeg"
|
||||
},
|
||||
"641": {
|
||||
"vehicle_title": "",
|
||||
"vehicle_desc": "",
|
||||
"line_note": "",
|
||||
"qr": ""
|
||||
},
|
||||
"8": {
|
||||
"vehicle_title": "",
|
||||
"vehicle_desc": "",
|
||||
"line_note": "",
|
||||
"qr": ""
|
||||
},
|
||||
"902": {
|
||||
"vehicle_title": "",
|
||||
"vehicle_desc": "",
|
||||
"line_note": "",
|
||||
"qr": "/images/qrcode/902.png"
|
||||
},
|
||||
"951": {
|
||||
"vehicle_title": "",
|
||||
"vehicle_desc": "",
|
||||
"line_note": "",
|
||||
"qr": ""
|
||||
},
|
||||
"952": {
|
||||
"vehicle_title": "",
|
||||
"vehicle_desc": "",
|
||||
"line_note": "",
|
||||
"qr": ""
|
||||
},
|
||||
"954": {
|
||||
"vehicle_title": "",
|
||||
"vehicle_desc": "",
|
||||
"line_note": "",
|
||||
"qr": ""
|
||||
},
|
||||
"999": {
|
||||
"vehicle_title": "",
|
||||
"vehicle_desc": "",
|
||||
"line_note": "",
|
||||
"qr": ""
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"route_id": "101",
|
||||
"vehicle_image": "car.jpeg",
|
||||
"qr_image": "101.png",
|
||||
"vehicle_title": "รถสองแถวประจำเส้นทาง",
|
||||
"vehicle_desc": "ประมาณ 30 ที่นั่ง · ให้บริการตลอดเส้นทางอ่างทอง–ป่าโมก–อยุธยา",
|
||||
"line_note": "ติดตามข่าวสาย 101 · รถออกก่อนเวลาบ่อยครั้ง · รถขาดช่วง"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"route_id": "1011",
|
||||
"vehicle_image": "car.jpeg",
|
||||
"qr_image": "",
|
||||
"vehicle_title": "รถเมล์ประจำเส้นทาง",
|
||||
"vehicle_desc": "รถเมล์ ประมาณ 30 ที่นั่ง รถมีเที่ยว เช้า เที่บง เย็น",
|
||||
"line_note": ""
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"route_id": "15",
|
||||
"vehicle_image": "car.jpg",
|
||||
"qr_image": "15.JPG",
|
||||
"vehicle_title": "รถมินิบัส 20 ที่นั่ง",
|
||||
"vehicle_desc": "ปัจจุบันส่วนใหญ่วิ่งแค่ป่าโมก หมอชิตใหม่ เหลือแค่รถ เบอร์ 20 ที่กลับถึงอ่างทอง บขส.อ่างทองมีรถออกแค่เช้ามืดถึงโมงเช้า",
|
||||
"line_note": ""
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"route_id": "2194",
|
||||
"vehicle_image": "car.jpg",
|
||||
"qr_image": "",
|
||||
"vehicle_title": "รถสองแถวประจำเส้นทาง",
|
||||
"vehicle_desc": "รถสองแถวเช้ามืดและเย็น ผ่านอ่างทองแค่สามแยกข้ามสะพานโผงเผงและวัดถนน",
|
||||
"line_note": ""
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"route_id": "2231",
|
||||
"vehicle_image": "car.jpg",
|
||||
"qr_image": "",
|
||||
"vehicle_title": "รถสองแถวประจำเส้นทาง",
|
||||
"vehicle_desc": "มีเที่ยวเดียว เช้า-เย็น",
|
||||
"line_note": ""
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"route_id": "324",
|
||||
"vehicle_image": "car.jpg",
|
||||
"qr_image": "",
|
||||
"vehicle_title": "รถสองแถวประจำเส้นทาง",
|
||||
"vehicle_desc": "รถมีเที่ยว เช้า อย่างเดียว วิ่งสุดสายแค่วัดไชโย",
|
||||
"line_note": ""
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"route_id": "464",
|
||||
"vehicle_image": "car.jpeg",
|
||||
"qr_image": "464.jpeg",
|
||||
"vehicle_title": "",
|
||||
"vehicle_desc": "",
|
||||
"line_note": ""
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"route_id": "641",
|
||||
"vehicle_image": "car.jpeg",
|
||||
"qr_image": "",
|
||||
"vehicle_title": "",
|
||||
"vehicle_desc": "",
|
||||
"line_note": ""
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"route_id": "8",
|
||||
"vehicle_image": "",
|
||||
"qr_image": "",
|
||||
"vehicle_title": "",
|
||||
"vehicle_desc": "",
|
||||
"line_note": ""
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"route_id": "902",
|
||||
"vehicle_image": "car.jpg",
|
||||
"qr_image": "902.png",
|
||||
"vehicle_title": "",
|
||||
"vehicle_desc": "",
|
||||
"line_note": ""
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"route_id": "951",
|
||||
"vehicle_image": "car.jpg",
|
||||
"qr_image": "",
|
||||
"vehicle_title": "",
|
||||
"vehicle_desc": "",
|
||||
"line_note": ""
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"route_id": "952",
|
||||
"vehicle_image": "car.jpg",
|
||||
"qr_image": "",
|
||||
"vehicle_title": "",
|
||||
"vehicle_desc": "",
|
||||
"line_note": ""
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"route_id": "954",
|
||||
"vehicle_image": "",
|
||||
"qr_image": "",
|
||||
"vehicle_title": "",
|
||||
"vehicle_desc": "",
|
||||
"line_note": ""
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"route_id": "999",
|
||||
"vehicle_image": "",
|
||||
"qr_image": "",
|
||||
"vehicle_title": "",
|
||||
"vehicle_desc": "",
|
||||
"line_note": ""
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import captions from "@/data/captions-index.json";
|
||||
|
||||
export type RouteCaption = {
|
||||
vehicle_title: string;
|
||||
vehicle_desc: string;
|
||||
line_note: string;
|
||||
qr: string; // e.g. "/images/qrcode/101.png" ("" ถ้าไม่มี)
|
||||
};
|
||||
|
||||
/** caption รถ/QR จาก design (resource/data/captions + .image/qrcode) */
|
||||
export function captionFor(routeId: string): RouteCaption | undefined {
|
||||
const c = (captions as Record<string, RouteCaption>)[String(routeId)];
|
||||
if (!c) return undefined;
|
||||
return c.vehicle_title || c.vehicle_desc || c.line_note || c.qr ? c : undefined;
|
||||
}
|
||||
Reference in new issue
Block a user