Resolve merge conflicts: keep the mock-ported view architecture
The merge of origin/main left 13 conflict markers across 9 files under frontend/src/app, so 'next build' failed with 21 parse errors and the Docker frontend image never built. Resolution: - Keep the HEAD side (views + PageRuntime shell) for all 8 route pages. - Rebuild layout.tsx by hand: it mixed both sides outside the conflict blocks (Viewport/headers/langFromCookie were only imported on the merged-in side). Kept IconSprite/SiteHeader/SiteFooter/SiteBoot, the mock CSS order (shared -> map -> shell -> responsive), the vendored K2D and Leaflet links, and set lang="th" because i18n.ts sets document.documentElement.lang at runtime. Verified: tsc --noEmit clean, npm run build compiles and prerenders all 12 static + 5 dynamic routes.
This commit is contained in:
1 parent
9519fef02d
commit
3b474b1127
11 files changed
+14
-1075
No files matched your search
@@ -1,4 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
import AboutView from "@/components/views/AboutView";
|
||||
import PageRuntime from "@/components/PageRuntime";
|
||||
|
||||
@@ -8,88 +7,6 @@ export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<AboutView />
|
||||
<PageRuntime page="about" />
|
||||
=======
|
||||
import { HERO_MAP } from "@/lib/images";
|
||||
|
||||
const BLOCKS = [
|
||||
{
|
||||
title: "เราคือใคร? คิดอย่างไรถึงเริ่มทำเว็บนี้",
|
||||
pic: "/images/about/pic1.jpg",
|
||||
body: [
|
||||
"สวัสดีผู้อ่านทุกคน ขอบคุณที่เข้ามาดูเว็ปตั้งแต่แรกเริ่ม เปลี่ยนชื่อหลายรอบ สำหรับข้อมูลส่วนตัวว่าเราคือใครเราไม่อยากเปิดเผยตัวตน เก็บความเป็นส่วนตัว",
|
||||
"ส่วนที่ว่าคิดยังไงถึงเริ่มทำเว็บนี้ เรามีประสบการณ์รอ รถมินิบัส อ่างทอง-กรุงเทพ(สายใน) หน้าสำนักงานที่ดินจังหวัดอ่างทอง ตอน 4โมงเช้า-5โมงเช้า ถ้าคนทั่วไปอาจจะไม่รู้ แต่ถ้าคนที่ขึ้นสายนี้ประจำจะรู้ แต่เราไม่รู้ไง! และตอนนั้นเป็นวันเสาร์ก็ไม่มีสองแถวด้วย รู้สึกว่าอยากขึ้นทำอะไรซักอย่าง",
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "ไม่มีจิตรกรคนไหนนั่งวาดภาพจากอากาศ",
|
||||
pic: "/images/about/pic2.jpg",
|
||||
body: [
|
||||
"บางคนอาจจะสงสัยว่าวลีนี้เกี่ยวกับเว็ปเราอย่างไร อย่างที่สำนวนบอกไม่มีจิตรกรวาดรูปจากอากาศ เว็ปเราก็ไม่ได้มโนจากอากาศเหมือนกันจะสร้างอะไรได้มันต้องมีต้นแบบให้ดู ขอให้เครดิตและขอบคุณต้นแบบของเราทุกๆคน",
|
||||
"- Mayday กลุ่มคนรณรงค์เรื่องรถเมล์ในกรุงเทพ ปริมณฑล",
|
||||
"- AyuthayaBusMap เป็นธุรกิจในอยุธยาทำแผนที่รถประจำทางบริการนักท่องเที่ยว",
|
||||
"- กลุ่มไลน์รถตู้ กรุงเทพ-อ่างทอง (สายใน) เป็นต้นแบบว่าถึงเราไม่ใช่ผู้ประกอบการเราก็ลุกขึ้นมาทำอะไรซักอย่างได้",
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "ความตั้งใจในปัจจุบัน",
|
||||
pic: "/images/about/pic3.jpg",
|
||||
body: [
|
||||
"ความตั้งใจของเราคือ พยายามรวบรวมช่องทางการติดต่อถามเวลาเดินรถหรือติดตามข่าวสาร เช่น เบอร์โทร เพจFB กลุ่มFBหรือline หรือwww ที่รถประจำทางแต่ละสายประกาศไว้",
|
||||
"ส่วนเรื่องตารางเวลาเดินรถที่เวปเราบอกตรงๆว่า เราอยากทำเป็นไอเดีย ว่าถ้าอ่างทองมีตารางเดินรถออนไลน์คงจะดีแต่ไม่ต้องไปเชื่อมาก เราคาดสีสถานะใว้",
|
||||
"สีแดง คือตารางเวลาที่ไม่ได้อัปเดตเกิน 1 อาทิตย์ น่าจะเป็นสีที่เห็นได้บ่อยที่สุด",
|
||||
"สีเขียว คือตารางเวลาที่ได้อัปเดตไม่เกิน 1 วัน",
|
||||
"สีส้ม คือตารางเวลาที่ไม่ได้อัปเดตเกิน 1 วันแต่น้อยกว่า 1 อาทิตย์",
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "แผนพัฒนาในอนาคต",
|
||||
pic: "/images/about/pic4.jpg",
|
||||
body: [
|
||||
"ถ้ามีคนถามถึงแผนพัฒนาในอนาคตมั้ยก็ต้องบอกตรงๆว่าไม่มีการที่ใครเข้าเวปมาแล้วได้โทรถามเวลาเดินรถ หรือเข้ากลุ่มไลน์รถสองแถว รถมินิบัส ถือว่าเว็ปนี้ทำหน้าที่ครบแล้ว จริงๆเว็ปนี้ตอนแรกตั้งใจเป็นเว็บชั่วคราว เราอยากให้หน่วยงานราชการและเอกชนใช้กฎหมาย PPP ร่วมทุนระหว่างราชการและเอกชนเพื่อสร้างระบบขนส่งมวลชนของอ่างทอง มีเว็ปแบบเรา มีสถานีขนส่งผู้โดยสารประจำอำเภอ มีรถประจำทางเส้นเลือดฝอยที่ให้บริการได้ทั้งวัน มีเรือโดยสารแม่น้ำน้อย มีเรือข้ามฟากไชโย หรือใครมีไอเดียก็เมลล์มาบอกได้เผื่อจะนำไปปรับปรุงอนาคต",
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export default function AboutPage() {
|
||||
return (
|
||||
<>
|
||||
<section className="hero hero--short">
|
||||
<img className="hero__map" src={HERO_MAP} alt="" aria-hidden="true" />
|
||||
<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">เกี่ยวกับเรา</span>
|
||||
<h1>
|
||||
เกี่ยวกับเรา
|
||||
<br />
|
||||
<span className="hero__grad">เมื่อไหร่รถจะมา</span>
|
||||
</h1>
|
||||
<p className="hero__lead">เรื่องราวและที่มาของเว็บนี้ — อ่านเรียงตามบล็อกด้านล่างได้เลย</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<main className="main">
|
||||
<div className="container">
|
||||
<div className="about-wrap">
|
||||
{BLOCKS.map((b) => (
|
||||
<article className="about-block" key={b.title}>
|
||||
<div className="about-block__text">
|
||||
<h2>{b.title}</h2>
|
||||
{b.body.map((p, i) => (
|
||||
<p key={i}>{p}</p>
|
||||
))}
|
||||
</div>
|
||||
<div className="about-media">
|
||||
<img src={b.pic} alt={b.title} loading="lazy" decoding="async" />
|
||||
</div>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
>>>>>>> 1526c5b6d06989ba2d865f6df4d339d680dbd3f8
|
||||
</>
|
||||
<PageRuntime page="about" /> </>
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
import BlogView from "@/components/views/BlogView";
|
||||
import PageRuntime from "@/components/PageRuntime";
|
||||
|
||||
@@ -8,77 +7,6 @@ export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<BlogView />
|
||||
<PageRuntime page="blog" />
|
||||
=======
|
||||
import { HERO_MAP } from "@/lib/images";
|
||||
import t1 from "@/data/blog/text1.json";
|
||||
import t2 from "@/data/blog/text2.json";
|
||||
import t3 from "@/data/blog/text3.json";
|
||||
import t4 from "@/data/blog/text4.json";
|
||||
import t5 from "@/data/blog/text5.json";
|
||||
import t6 from "@/data/blog/text6.json";
|
||||
import t7 from "@/data/blog/text7.json";
|
||||
|
||||
type Post = { date: string; th: { title: string; tag?: string; body: string[] } };
|
||||
const POSTS: (Post & { pic: string })[] = [
|
||||
{ ...(t1 as Post), pic: "/images/blog/pic1.jpg" },
|
||||
{ ...(t2 as Post), pic: "/images/blog/pic2.jpg" },
|
||||
{ ...(t3 as Post), pic: "/images/blog/pic3.jpg" },
|
||||
{ ...(t4 as Post), pic: "/images/blog/pic4.jpg" },
|
||||
{ ...(t5 as Post), pic: "/images/blog/pic5.jpg" },
|
||||
{ ...(t6 as Post), pic: "/images/blog/pic6.jpg" },
|
||||
{ ...(t7 as Post), pic: "/images/blog/pic7.jpg" },
|
||||
].sort((a, b) => (a.date < b.date ? 1 : -1));
|
||||
|
||||
function fmtDate(d: string) {
|
||||
const [y, m, dd] = d.split("-");
|
||||
const months = ["ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค."];
|
||||
return `${Number(dd)} ${months[Number(m) - 1]} ${Number(y) + 543}`;
|
||||
}
|
||||
|
||||
export default function BlogPage() {
|
||||
return (
|
||||
<>
|
||||
<section className="hero hero--short">
|
||||
<img className="hero__map" src={HERO_MAP} alt="" aria-hidden="true" />
|
||||
<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">บ่นไปเรื่อย</span>
|
||||
<h1>
|
||||
บ่นไปเรื่อย
|
||||
<br />
|
||||
<span className="hero__grad">เรื่องเล่าระหว่างทาง</span>
|
||||
</h1>
|
||||
<p className="hero__lead">รวมข้อเขียน ความฝัน และความกังวลเกี่ยวกับรถโดยสารในจังหวัดอ่างทอง</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<main className="main">
|
||||
<div className="container">
|
||||
<div className="blog-wrap">
|
||||
{POSTS.map((p, i) => (
|
||||
<article className="blog-card" key={p.date + p.th.title}>
|
||||
<div className="blog-card__media">
|
||||
<img src={p.pic} alt={p.th.title} loading="lazy" decoding="async" />
|
||||
</div>
|
||||
<div className="blog-card__body">
|
||||
<div className="blog-card__meta">
|
||||
<time dateTime={p.date}>{fmtDate(p.date)}</time>
|
||||
{p.th.tag && <span className="blog-card__tag">{p.th.tag}</span>}
|
||||
</div>
|
||||
<h2>{p.th.title}</h2>
|
||||
{p.th.body.slice(0, 2).map((para, j) => (
|
||||
<p key={j}>{para}</p>
|
||||
))}
|
||||
</div>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
>>>>>>> 1526c5b6d06989ba2d865f6df4d339d680dbd3f8
|
||||
</>
|
||||
<PageRuntime page="blog" /> </>
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
import CheckView from "@/components/views/CheckView";
|
||||
import PageRuntime from "@/components/PageRuntime";
|
||||
|
||||
@@ -16,156 +15,5 @@ export default async function Page({
|
||||
<>
|
||||
<CheckView />
|
||||
<PageRuntime page="check" query={query} />
|
||||
</>
|
||||
=======
|
||||
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";
|
||||
import { headers } from "next/headers";
|
||||
import { t, langFromCookie } from "@/lib/i18n";
|
||||
|
||||
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 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 =
|
||||
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" /> {T("cta.check")}
|
||||
</span>
|
||||
<h1>
|
||||
{T("check.title")}
|
||||
<br />
|
||||
<span className="hero__grad">{route?.name_th ?? (lang === "en" ? "Select a route below" : "เลือกสายรถด้านล่าง")}</span>
|
||||
</h1>
|
||||
<p className="hero__lead">{T("check.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>{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">
|
||||
{T("check.scheduleAll")} {route ? `— ${lang === "en" ? "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>
|
||||
>>>>>>> 1526c5b6d06989ba2d865f6df4d339d680dbd3f8
|
||||
);
|
||||
</> );
|
||||
}
|
||||
@@ -1,89 +1,6 @@
|
||||
<<<<<<< HEAD
|
||||
import CreditsView from "@/components/views/CreditsView";
|
||||
|
||||
export const metadata = { title: "เครดิต" };
|
||||
|
||||
export default function Page() {
|
||||
return <CreditsView />;
|
||||
=======
|
||||
import { HERO_MAP } from "@/lib/images";
|
||||
|
||||
export default function CreditsPage() {
|
||||
return (
|
||||
<>
|
||||
<section className="hero hero--short">
|
||||
<img className="hero__map" src={HERO_MAP} alt="" aria-hidden="true" />
|
||||
<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">เครดิต</span>
|
||||
<h1>
|
||||
เครดิตและแหล่งที่มา
|
||||
<br />
|
||||
<span className="hero__grad">ขอบคุณทุกทรัพยากร</span>
|
||||
</h1>
|
||||
<p className="hero__lead">รายการทรัพยากรทั้งหมดที่ใช้ในเว็บนี้ พร้อมใบอนุญาตตามข้อกำหนดของเจ้าของแต่ละราย</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<main className="main">
|
||||
<div className="container credit-wrap">
|
||||
<section className="credit-section">
|
||||
<h2>ไอคอน — Lucide</h2>
|
||||
<p className="src">
|
||||
แหล่งที่มา: <a href="https://lucide.dev" rel="noopener">lucide.dev</a> · ใบอนุญาต:{" "}
|
||||
<a href="https://github.com/lucide-icons/lucide/blob/main/LICENSE" rel="noopener">MIT License</a>
|
||||
</p>
|
||||
<ul>
|
||||
<li>ไอคอนที่ใช้ทั้งหมด 15 รายการ: alarm-clock, arrow-right, bus, bus-front, check, clock, globe, hourglass, map, map-pin, message-circle, phone, refresh-cw, search, triangle-alert</li>
|
||||
</ul>
|
||||
<div className="license">
|
||||
<strong>MIT License (สรุป):</strong> อนุญาตให้ใช้ คัดลอก แก้ไข ผสาน เผยแพร่ แจกจ่าย ขาย และ/หรือให้สิทธิ์ใช้งานซอฟต์แวร์นี้ โดยมีเงื่อนไขให้ข้อความแสดงลิขสิทธิ์และข้อความอนุญาตข้างต้นปรากฏอยู่ในสำเนาทั้งหมด ซอฟต์แวร์นี้ให้บริการ "ตามสภาพ" โดยไม่มีการรับประกันใด ๆ
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="credit-section">
|
||||
<h2>ฟอนต์ — Google Fonts</h2>
|
||||
<p className="src">
|
||||
แหล่งที่มา: <a href="https://fonts.google.com" rel="noopener">fonts.google.com</a> · ใบอนุญาต:{" "}
|
||||
<a href="https://openfontlicense.org" rel="noopener">SIL Open Font License 1.1</a>
|
||||
</p>
|
||||
<ul>
|
||||
<li><strong>K2D</strong> — ฟอนต์หลักของเว็บ (เนื้อหา + หัวเรื่อง)</li>
|
||||
<li><strong>Noto Sans Thai</strong> — ตัวสำรองเนื้อหา</li>
|
||||
<li><strong>Prompt</strong> — ตัวสำรองหัวเรื่อง/ตัวหนา</li>
|
||||
<li><strong>IBM Plex Mono</strong> — เวลา · เลขสาย · ตัวเลข</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section className="credit-section">
|
||||
<h2>แผนที่</h2>
|
||||
<p className="src">
|
||||
ใบอนุญาต: Leaflet <a href="https://github.com/Leaflet/Leaflet/blob/main/LICENSE" rel="noopener">BSD-2-Clause</a> · ชุดแผนที่:{" "}
|
||||
<a href="https://www.openstreetmap.org/copyright" rel="noopener">OpenStreetMap © ผู้มีส่วนร่วม (ODbL)</a>
|
||||
</p>
|
||||
<ul>
|
||||
<li>Leaflet — ไลบรารีแผนที่แบบ open-source</li>
|
||||
<li>OpenStreetMap — ภาพ tiles และข้อมูลแผนที่</li>
|
||||
<li>เส้นทางเดินรถ จุดจอด และหมุดสถานี วาดจากข้อมูล GIS ของทีม (GeoJSON)</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section className="credit-section">
|
||||
<h2>ขอขอบคุณภาพรถประจำทาง</h2>
|
||||
<p className="src">ภาพรถโดยสารที่แสดงในหน้ารายละเอียดสาย มาจากแหล่งข้อมูลสาธารณะด้านล่างนี้</p>
|
||||
<ul>
|
||||
<li><strong>สาย 2194</strong> หัวเวียง-อยุธยา — จาก <a href="http://www.bangkokbusclub.com/cms/showthread.php?t=4968" rel="noopener">bangkokbusclub.com</a></li>
|
||||
<li><strong>สาย 8</strong> กรุงเทพ-สรรคบุรี-ชัยนาท — จากกลุ่ม Facebook (web.facebook.com)</li>
|
||||
<li><strong>สาย 954</strong> กรุงเทพ-ท่าช้าง — จาก <a href="https://gogo.town/route/bangkok-rangsit-angthong-thachang/" rel="noopener">gogo.town</a></li>
|
||||
<li><strong>รถไฟฟ้าสายสีแดง</strong> กรุงเทพ-ชุมทางบ้านภาชี — จาก <a href="https://thelist.group" rel="noopener">thelist.group</a></li>
|
||||
</ul>
|
||||
<div className="license">และสายอื่น ๆ ที่ไม่ได้ระบุ ขอขอบคุณมา ณ ที่นี้</div>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
</>
|
||||
);
|
||||
>>>>>>> 1526c5b6d06989ba2d865f6df4d339d680dbd3f8
|
||||
}
|
||||
return <CreditsView />;}
|
||||
@@ -1,11 +1,10 @@
|
||||
<<<<<<< HEAD
|
||||
import type { Metadata } from "next";
|
||||
import type { Metadata, Viewport } from "next";
|
||||
import IconSprite from "@/components/IconSprite";
|
||||
import SiteBoot from "@/components/SiteBoot";
|
||||
import SiteFooter from "@/components/SiteFooter";
|
||||
import SiteHeader from "@/components/SiteHeader";
|
||||
|
||||
// ลำดับ CSS ต้องตรงกับ mock: shared → map → shell → page → responsive
|
||||
// ลำดับ CSS ต้องตรงกับ mock: shared → map → shell → responsive
|
||||
import "@/styles/_shared.css";
|
||||
import "@/styles/map.css";
|
||||
import "@/styles/shell.css";
|
||||
@@ -22,45 +21,19 @@ export const metadata: Metadata = {
|
||||
"ศูนย์รวมข้อมูลตารางเดินรถ จุดจอด และเส้นทางในจังหวัดอ่างทองและจังหวัดใกล้เคียง",
|
||||
manifest: "/ui-manifest.json",
|
||||
icons: { icon: "/image/icons/minibus-512x512.png" },
|
||||
=======
|
||||
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 — สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง",
|
||||
description:
|
||||
"ค้นหาเส้นทาง ตารางเดินรถ และจุดจอดในจังหวัดอ่างทองและจังหวัดใกล้เคียง",
|
||||
icons: {
|
||||
icon: [{ url: "/images/icons/minibus-512x512.png", sizes: "512x512", type: "image/png" }],
|
||||
apple: [{ url: "/images/icons/minibus-192x192.png", sizes: "192x192", type: "image/png" }],
|
||||
},
|
||||
>>>>>>> 1526c5b6d06989ba2d865f6df4d339d680dbd3f8
|
||||
};
|
||||
|
||||
export const viewport: Viewport = {
|
||||
themeColor: "#7a4cc0",
|
||||
};
|
||||
|
||||
export default async function RootLayout({ children }: { children: React.ReactNode }) {
|
||||
const h = await headers();
|
||||
const lang = langFromCookie(h.get("cookie"));
|
||||
|
||||
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<html lang={lang}>
|
||||
<html lang="th">
|
||||
<head>
|
||||
<<<<<<< HEAD
|
||||
{/* ฟอนต์ K2D ฝังในโปรเจกต์ + Leaflet CSS (ไฟล์ static ใน public) */}
|
||||
<link rel="stylesheet" href="/vendor/fonts/k2d.css" />
|
||||
<link rel="stylesheet" href="/vendor/leaflet/leaflet.css" />
|
||||
=======
|
||||
{/* K2D (offline, local woff2 — ตรงกับ design) + Noto/Prompt fallback (CDN) */}
|
||||
<link rel="stylesheet" href="/fonts/k2d.css" />
|
||||
>>>>>>> 1526c5b6d06989ba2d865f6df4d339d680dbd3f8
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700;800&family=Prompt:wght@400;500;600;700&display=swap"
|
||||
@@ -71,21 +44,12 @@ export default async function RootLayout({ children }: { children: React.ReactNo
|
||||
<link rel="apple-touch-icon" href="/image/icons/minibus-192x192.png" />
|
||||
<script src="/vendor/leaflet/leaflet.js" defer />
|
||||
</head>
|
||||
<<<<<<< HEAD
|
||||
<body className="main-theme-page">
|
||||
<IconSprite />
|
||||
<SiteHeader />
|
||||
<div id="view">{children}</div>
|
||||
<SiteFooter />
|
||||
<SiteBoot />
|
||||
=======
|
||||
<body>
|
||||
<LangProvider initial={lang}>
|
||||
<Header />
|
||||
{children}
|
||||
<Footer />
|
||||
</LangProvider>
|
||||
>>>>>>> 1526c5b6d06989ba2d865f6df4d339d680dbd3f8
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
import HomeView from "@/components/views/HomeView";
|
||||
import PageRuntime from "@/components/PageRuntime";
|
||||
|
||||
@@ -19,65 +18,6 @@ export default async function Page({
|
||||
return (
|
||||
<>
|
||||
<HomeView />
|
||||
<PageRuntime page="home" query={query} />
|
||||
=======
|
||||
import { api, type RouteListItem, type Schedule } from "@/lib/api";
|
||||
import { VisitTracker } from "@/lib/visit-tracker";
|
||||
import HomeClient from "@/components/HomeClient";
|
||||
|
||||
export default async function HomePage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<{ p?: string; s?: string }>;
|
||||
}) {
|
||||
const sp = await searchParams;
|
||||
|
||||
const [groupsRes, routesRes, schedRes, provRes, stopsRes] = await Promise.allSettled([
|
||||
api.routeGroups(),
|
||||
api.routes(),
|
||||
api.schedules({}),
|
||||
api.provinces(),
|
||||
api.stops(),
|
||||
]);
|
||||
|
||||
const groups = groupsRes.status === "fulfilled" ? groupsRes.value.items : [];
|
||||
const routes: RouteListItem[] = routesRes.status === "fulfilled" ? routesRes.value.items : [];
|
||||
const schedules: Schedule[] = schedRes.status === "fulfilled" ? schedRes.value.items : [];
|
||||
const provinces = provRes.status === "fulfilled" ? provRes.value.items : [];
|
||||
const stops = stopsRes.status === "fulfilled" ? stopsRes.value.items : [];
|
||||
|
||||
// route_id -> all departure times
|
||||
const timesByRoute: Record<string, string[]> = {};
|
||||
for (const s of schedules) {
|
||||
(timesByRoute[s.route_id] ??= []).push(...s.departure_times);
|
||||
}
|
||||
|
||||
// route_id -> station ids (for station-level filtering)
|
||||
const routeStations: Record<string, number[]> = {};
|
||||
await Promise.all(
|
||||
routes.map(async (r) => {
|
||||
const { items } = await api.routeStops(r.route_id).catch(() => ({ items: [] }));
|
||||
routeStations[r.route_id] = items.map((x) => x.station_id);
|
||||
}),
|
||||
);
|
||||
|
||||
const initialProvinceId = sp.p ? Number(sp.p) || undefined : undefined;
|
||||
const initialStationCode = sp.s ?? undefined;
|
||||
|
||||
return (
|
||||
<>
|
||||
<VisitTracker path="/" />
|
||||
<HomeClient
|
||||
groups={groups}
|
||||
routes={routes}
|
||||
timesByRoute={timesByRoute}
|
||||
provinces={provinces}
|
||||
stops={stops}
|
||||
routeStations={routeStations}
|
||||
initialProvinceId={initialProvinceId}
|
||||
initialStationCode={initialStationCode}
|
||||
/>
|
||||
>>>>>>> 1526c5b6d06989ba2d865f6df4d339d680dbd3f8
|
||||
</>
|
||||
<PageRuntime page="home" query={query} /> </>
|
||||
);
|
||||
}
|
||||
@@ -1,357 +1,12 @@
|
||||
<<<<<<< HEAD
|
||||
import RouteView from "@/components/views/RouteView";
|
||||
import PageRuntime from "@/components/PageRuntime";
|
||||
=======
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
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 { kmFor } from "@/lib/stop-km";
|
||||
import { Icon } from "@/components/Icons";
|
||||
import { headers } from "next/headers";
|
||||
import { t, langFromCookie } from "@/lib/i18n";
|
||||
>>>>>>> 1526c5b6d06989ba2d865f6df4d339d680dbd3f8
|
||||
|
||||
export const metadata = { title: "รายละเอียดสายรถ" };
|
||||
|
||||
<<<<<<< HEAD
|
||||
export default async function Page({ params }: { params: Promise<{ routeId: string }> }) {
|
||||
const { routeId } = await params;
|
||||
return (
|
||||
<>
|
||||
<RouteView />
|
||||
<PageRuntime page="route" params={{ routeId: decodeURIComponent(routeId) }} />
|
||||
</>
|
||||
=======
|
||||
type RouteDetailPageProps = {
|
||||
params: Promise<{ routeId: string }>;
|
||||
};
|
||||
|
||||
/** เที่ยวถัดไป = รอบแรกที่ยังไม่ผ่านของสายนี้ */
|
||||
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;
|
||||
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[] = [];
|
||||
let schedules: Schedule[] = [];
|
||||
let allStops: StopListItem[] = [];
|
||||
let allRoutes: RouteListItem[] = [];
|
||||
|
||||
try {
|
||||
[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();
|
||||
}
|
||||
route = null;
|
||||
stops = [];
|
||||
schedules = [];
|
||||
allStops = [];
|
||||
allRoutes = [];
|
||||
}
|
||||
|
||||
if (!route) {
|
||||
return (
|
||||
<main className="page">
|
||||
<VisitTracker path={`/routes/${routeId}`} />
|
||||
<section className="hero">
|
||||
<h1>ไม่สามารถโหลดข้อมูลเส้นทางได้</h1>
|
||||
<p className="muted">ระบบยังเปิดอยู่ แต่ backend ตอบกลับไม่ได้ในตอนนี้</p>
|
||||
<Link href="/routes">กลับไปหน้าสายรถ</Link>
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
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 });
|
||||
}
|
||||
|
||||
const mapPoints = stops
|
||||
.map((s) => {
|
||||
const c = coordById.get(s.station_id);
|
||||
if (!c) return null;
|
||||
return {
|
||||
id: s.station_id,
|
||||
lat: c.lat,
|
||||
lng: c.lng,
|
||||
label: s.name_th,
|
||||
code: s.code,
|
||||
sequence: s.stop_sequence,
|
||||
};
|
||||
})
|
||||
.filter((x): x is NonNullable<typeof x> => x !== null);
|
||||
|
||||
const stopPath: [number, number][] = mapPoints.map((p) => [p.lat, p.lng]);
|
||||
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 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 />
|
||||
<span className="page-hero__blob page-hero__blob--c" aria-hidden />
|
||||
<div className="route-hero__top">
|
||||
<div className="route-hero__badge">{route.route_id}</div>
|
||||
<div className="route-hero__title-wrap">
|
||||
<div className="route-hero__chips">
|
||||
<span className="chip-soft chip-soft--purple">{route.route_group_label_th || route.route_group_code}</span>
|
||||
<span className="chip-soft chip-soft--sky">{route.vehicle_type}</span>
|
||||
{provinceSet.size > 0 && (
|
||||
<span className="chip-soft chip-soft--mint">{provinceSet.size} จังหวัด</span>
|
||||
)}
|
||||
</div>
|
||||
<h1 className="page-hero__title">
|
||||
<span className="page-hero__title-grad">{route.name_th}</span>
|
||||
</h1>
|
||||
<p className="page-hero__subtitle">
|
||||
เส้นทางหมายเลข {route.route_id} · ผ่าน {stops.length} จุดจอด · {schedules.length} รอบเวลา
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="page-hero__stats">
|
||||
<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>
|
||||
</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>
|
||||
|
||||
{/* รถประจำสาย + ติดต่อผู้ประกอบการ (การ์ดเดียว) */}
|
||||
{(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">{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 && (
|
||||
<p className="muted">สาย {route.route_id} · {route.vehicle_type}</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 className="route-map-section">
|
||||
<div className="route-map-section__head">
|
||||
<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>
|
||||
<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>
|
||||
)}
|
||||
|
||||
{stops.length > 0 && (
|
||||
<div className="km-wrap">
|
||||
<h3 className="km-wrap__title">{T("map.alongRoute")}</h3>
|
||||
<ol className="km-list">
|
||||
{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>
|
||||
)}
|
||||
</section>
|
||||
|
||||
{/* จุดจอดตามลำดับ (รายละเอียด) */}
|
||||
<section>
|
||||
<h2 className="section-title">{T("route.stopsTitle")} ({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>
|
||||
<h2 className="section-title">{T("route.scheduleTitle")} ({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>
|
||||
>>>>>>> 1526c5b6d06989ba2d865f6df4d339d680dbd3f8
|
||||
);
|
||||
</> );
|
||||
}
|
||||
@@ -1,88 +1,11 @@
|
||||
<<<<<<< HEAD
|
||||
import RouteView from "@/components/views/RouteView";
|
||||
import PageRuntime from "@/components/PageRuntime";
|
||||
=======
|
||||
import Link from "next/link";
|
||||
import { api } from "@/lib/api";
|
||||
import { VisitTracker } from "@/lib/visit-tracker";
|
||||
import { Icon } from "@/components/Icons";
|
||||
>>>>>>> 1526c5b6d06989ba2d865f6df4d339d680dbd3f8
|
||||
|
||||
export const metadata = { title: "รายละเอียดสายรถ" };
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<<<<<<< HEAD
|
||||
<>
|
||||
<RouteView />
|
||||
<PageRuntime page="route" />
|
||||
</>
|
||||
=======
|
||||
<main className="page">
|
||||
<VisitTracker path="/routes" />
|
||||
|
||||
<section className="page-hero page-hero--alt">
|
||||
<div className="page-hero__blob page-hero__blob--a" />
|
||||
<div className="page-hero__blob page-hero__blob--b" />
|
||||
<div className="page-hero__blob page-hero__blob--c" />
|
||||
<div className="page-hero__inner">
|
||||
<span className="page-hero__badge"><Icon name="bus" size={13} className="icon" /> ROUTE NETWORK</span>
|
||||
<h1 className="page-hero__title">
|
||||
เส้นทางเดินรถ<span className="page-hero__title-grad">ทั้งหมด</span>
|
||||
</h1>
|
||||
<p className="page-hero__subtitle">
|
||||
{group ? `กรองหมวด: ${group}` : "ครอบคลุมทุกหมวด"}
|
||||
{province ? ` · จังหวัด #${province}` : ""}
|
||||
</p>
|
||||
<div className="page-hero__stats">
|
||||
<span className="page-hero__stat"><b>{items.length}</b> เส้นทาง</span>
|
||||
<span className="page-hero__stat"><b>{Object.keys(groupCounts).length}</b> หมวด</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div className="toolbar">
|
||||
<div className="toolbar__search">
|
||||
<Icon name="search" size={16} className="icon" />
|
||||
<input placeholder="ค้นหาเลขสาย หรือชื่อเส้นทาง…" disabled />
|
||||
</div>
|
||||
<div className="toolbar__chips">
|
||||
{Object.entries(groupCounts).map(([code, { label, n }]) => (
|
||||
<span key={code} className={`chip-soft chip-soft--${GROUP_TONE[code] ?? "sky"}`}>
|
||||
{label} · {n}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="tile-grid">
|
||||
{items.map((r, i) => {
|
||||
const tone = GROUP_TONE[r.route_group_code] ?? TONES[i % TONES.length];
|
||||
return (
|
||||
<Link
|
||||
key={r.route_id}
|
||||
href={`/routes/${encodeURIComponent(r.route_id)}`}
|
||||
className={`tile tile--${tone}`}
|
||||
>
|
||||
<div className={`tile__badge tile__badge--${tone} tile__badge--num`}>
|
||||
<span>{r.route_id}</span>
|
||||
</div>
|
||||
<div className="tile__body">
|
||||
<p className="tile__title">{r.name_th}</p>
|
||||
<p className="tile__meta">{r.route_group_label_th || r.route_group_code}</p>
|
||||
<div className="tile__chips">
|
||||
<span className={`chip-soft chip-soft--${tone}`}>
|
||||
{r.route_group_label_th || r.route_group_code}
|
||||
</span>
|
||||
<span className="chip-soft chip-soft--mint"><Icon name="bus" size={13} className="icon" /> {r.vehicle_type}</span>
|
||||
</div>
|
||||
</div>
|
||||
<span className="tile__arrow" aria-hidden>→</span>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</main>
|
||||
>>>>>>> 1526c5b6d06989ba2d865f6df4d339d680dbd3f8
|
||||
);
|
||||
</> );
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
import StopsView from "@/components/views/StopsView";
|
||||
import PageRuntime from "@/components/PageRuntime";
|
||||
|
||||
@@ -9,157 +8,5 @@ export default function Page() {
|
||||
<>
|
||||
<StopsView />
|
||||
<PageRuntime page="stops" />
|
||||
</>
|
||||
=======
|
||||
import Link from "next/link";
|
||||
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]> = {
|
||||
main_terminal: "purple",
|
||||
local_stop: "sky",
|
||||
market: "pink",
|
||||
private_stop: "amber",
|
||||
other: "mint",
|
||||
};
|
||||
const TYPE_ICON: Record<string, IconName> = {
|
||||
main_terminal: "bus-front",
|
||||
local_stop: "map-pin",
|
||||
market: "store",
|
||||
private_stop: "bus",
|
||||
other: "map-pin",
|
||||
};
|
||||
const TYPE_LABEL: Record<string, string> = {
|
||||
main_terminal: "สถานีขนส่ง",
|
||||
local_stop: "ป้ายหลัก",
|
||||
market: "ตลาด/ชุมชน",
|
||||
private_stop: "จุดรับส่ง",
|
||||
other: "อื่น ๆ",
|
||||
};
|
||||
|
||||
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" />
|
||||
<div className="page-hero__blob page-hero__blob--c" />
|
||||
<div className="page-hero__inner">
|
||||
<span className="page-hero__badge"><Icon name="map-pin" size={13} className="icon" /> STOP DIRECTORY</span>
|
||||
<h1 className="page-hero__title">
|
||||
จุดจอด<span className="page-hero__title-grad">ทั่วประเทศ</span>
|
||||
</h1>
|
||||
<p className="page-hero__subtitle">
|
||||
ค้นหาป้าย / สถานีขนส่ง พร้อมแผนที่และเส้นทางที่ผ่าน
|
||||
</p>
|
||||
<div className="page-hero__stats">
|
||||
<span className="page-hero__stat"><b>{items.length}</b> จุดจอด</span>
|
||||
<span className="page-hero__stat"><b>{points.length}</b> มีพิกัด</span>
|
||||
<span className="page-hero__stat"><b>{Object.keys(typeCounts).length}</b> ประเภท</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div className="container">
|
||||
{points.length > 0 && !q && (
|
||||
<div className="map-wrap map-wrap--soft">
|
||||
<LazyMapView points={points} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ค้นหาป้ายทางหลวง: รหัส 5 หลัก + ชื่อสถานที่ + ป้ายใกล้ฉัน */}
|
||||
<StopSearch />
|
||||
|
||||
<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>
|
||||
|
||||
{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 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>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</main>
|
||||
>>>>>>> 1526c5b6d06989ba2d865f6df4d339d680dbd3f8
|
||||
);
|
||||
</> );
|
||||
}
|
||||
Reference in new issue
Block a user