- copy .image assets to frontend/public/images (logo, hero map, partner logos, route/stop photos, qrcode, landmarks) - add K2D fonts (offline local woff2) in frontend/public/fonts - add Lucide icon components (Icons.tsx); replace all emoji icons - add lib/images.ts static asset resolver (route/stop/partner/logo) - header/footer/home: minibus logo, hero map bg, partner marquee - route detail: design car/hero photo; stop detail: design stop photo - .gitignore: un-ignore frontend/public/images + app icons so the frontend Docker build ships the assets
140 lines
5.7 KiB
TypeScript
140 lines
5.7 KiB
TypeScript
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";
|
|
|
|
const TONES = ["sky", "purple", "pink", "mint", "amber"] as const;
|
|
const TYPE_TONE: Record<string, (typeof TONES)[number]> = {
|
|
terminal: "purple",
|
|
station: "sky",
|
|
pickup: "amber",
|
|
market: "pink",
|
|
landmark: "mint",
|
|
};
|
|
const TYPE_ICON: Record<string, IconName> = {
|
|
terminal: "bus-front",
|
|
station: "map-pin",
|
|
pickup: "bus",
|
|
market: "store",
|
|
landmark: "map-pin",
|
|
};
|
|
const TYPE_LABEL: Record<string, string> = {
|
|
terminal: "สถานีขนส่ง",
|
|
station: "ป้ายหลัก",
|
|
pickup: "จุดรับส่ง",
|
|
market: "ตลาด/ชุมชน",
|
|
landmark: "จุดสังเกต",
|
|
};
|
|
|
|
export default async function StopsPage() {
|
|
const { items } = await api.stops().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" />
|
|
|
|
<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>
|
|
|
|
{points.length > 0 && (
|
|
<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>
|
|
<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>
|
|
)}
|
|
</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>
|
|
</div>
|
|
<span className="tile__arrow" aria-hidden>→</span>
|
|
</div>
|
|
)
|
|
);
|
|
})}
|
|
</div>
|
|
</main>
|
|
);
|
|
}
|
|
|