first commit
This commit is contained in:
commit
2a1854ab08
120 files changed
+11300
No files matched your search
@@ -0,0 +1,115 @@
|
||||
import Link from "next/link";
|
||||
import Image from "next/image";
|
||||
import { api, resolveFileUrl } from "@/lib/api";
|
||||
|
||||
const popularRoutes = [
|
||||
{ id: "101", label: "สาย 101 · อ่างทอง-อยุธยา" },
|
||||
{ id: "902", label: "สาย 902 · กรุงเทพ-อ่างทอง" },
|
||||
{ id: "15", label: "สาย 15 · สายใน" },
|
||||
{ id: "464", label: "สาย 464 · สุพรรณ-สระบุรี" },
|
||||
];
|
||||
|
||||
const SPONSOR_LABELS: Record<string, string> = {
|
||||
"7-11": "7-Eleven",
|
||||
"shopee": "Shopee",
|
||||
"lazada": "Lazada",
|
||||
"airasia-move": "airasia MOVE",
|
||||
"busonlineticket": "busonlineticket",
|
||||
"trip": "Trip.com",
|
||||
"truck2hand": "truck2hand",
|
||||
"tcl999-angthong": "ทีซีแอล 999 อ่างทอง",
|
||||
"bus-pingraow": "รถบัสปิ่นเกล้า",
|
||||
};
|
||||
|
||||
function labelFor(entityId: string): string {
|
||||
return SPONSOR_LABELS[entityId] ?? entityId;
|
||||
}
|
||||
|
||||
export async function Footer() {
|
||||
let sponsors: { entity_id: string; url_path: string }[] = [];
|
||||
try {
|
||||
const res = await api.images({ entity_type: "sponsor" });
|
||||
sponsors = res.items.map((item) => ({
|
||||
entity_id: item.entity_id,
|
||||
url_path: item.url_path,
|
||||
}));
|
||||
} catch {
|
||||
sponsors = [];
|
||||
}
|
||||
|
||||
return (
|
||||
<footer className="footer">
|
||||
<div className="container">
|
||||
<div className="footer__grid">
|
||||
<div className="footer__brand">
|
||||
<div className="footer__brand-row">
|
||||
<Image src="/logo.svg" alt="AT Transit" width={48} height={48} />
|
||||
<div>
|
||||
<strong>AT Transit</strong>
|
||||
<span>สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง</span>
|
||||
</div>
|
||||
</div>
|
||||
<p>
|
||||
ศูนย์รวมข้อมูลตารางเดินรถ จุดจอด และเส้นทางในจังหวัดอ่างทองและจังหวัดใกล้เคียง
|
||||
อัปเดตข้อมูลล่าสุดจากผู้ประกอบการแต่ละสายโดยตรง
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="footer__col">
|
||||
<h4>เมนู</h4>
|
||||
<ul>
|
||||
<li><Link href="/">หน้าแรก</Link></li>
|
||||
<li><Link href="/stops">ค้นหาป้ายหยุดรถ</Link></li>
|
||||
<li><Link href="/routes">รายละเอียดสายรถ</Link></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div className="footer__col">
|
||||
<h4>สายยอดนิยม</h4>
|
||||
<ul>
|
||||
{popularRoutes.map((r) => (
|
||||
<li key={r.id}>
|
||||
<Link href={`/routes/${r.id}`}>{r.label}</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div className="footer__col footer__contact">
|
||||
<h4>ติดต่อ</h4>
|
||||
<div className="row"><a href="tel:+66649639025">📞 +66 64 963 9025</a></div>
|
||||
<div className="row"><span>📍 ถนนเทศบาล 1 อ.เมือง อ่างทอง</span></div>
|
||||
<div className="row"><span>🕒 บริการ 04:30 - 21:00 น.</span></div>
|
||||
<div className="row"><a href="#">💬 LINE Official: @attransit</a></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section className="footer__sponsors" aria-label="ผู้สนับสนุน">
|
||||
<h4>ผู้สนับสนุน & พาร์ทเนอร์</h4>
|
||||
<p className="lead">จองตั๋ว · สั่งของ · เช็กของฝาก ที่ร้านค้าและบริการพันธมิตรของเรา</p>
|
||||
<div className="sponsor-strip">
|
||||
{sponsors.length > 0 ? (
|
||||
sponsors.map((s) => (
|
||||
<a
|
||||
key={s.entity_id}
|
||||
className="sponsor-tile"
|
||||
href="#"
|
||||
aria-label={labelFor(s.entity_id)}
|
||||
title={labelFor(s.entity_id)}
|
||||
>
|
||||
<img src={resolveFileUrl(s.url_path)} alt={labelFor(s.entity_id)} loading="lazy" />
|
||||
</a>
|
||||
))
|
||||
) : (
|
||||
<span className="sponsor-tile sponsor-tile--empty">ยังไม่มีข้อมูลผู้สนับสนุน</span>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div className="footer__bottom">
|
||||
<p>© {new Date().getFullYear()} AT Transit <span className="pill">mockup template</span></p>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
"use client";
|
||||
import Link from "next/link";
|
||||
import Image from "next/image";
|
||||
import { usePathname } from "next/navigation";
|
||||
|
||||
const links = [
|
||||
{ href: "/", label: "หน้าแรก" },
|
||||
{ href: "/stops", label: "ป้ายหยุดรถ" },
|
||||
{ href: "/routes", label: "รายละเอียดสายรถ" },
|
||||
];
|
||||
|
||||
export function Header() {
|
||||
const pathname = usePathname();
|
||||
const isActive = (href: string) =>
|
||||
href === "/" ? pathname === "/" : pathname.startsWith(href);
|
||||
|
||||
return (
|
||||
<header className="topbar">
|
||||
<div className="topbar__inner">
|
||||
<Link href="/" className="brand">
|
||||
<Image
|
||||
src="/logo.svg"
|
||||
alt="AT Transit"
|
||||
width={44}
|
||||
height={44}
|
||||
className="brand__logo"
|
||||
priority
|
||||
/>
|
||||
<div>
|
||||
<p className="brand__title">AT Transit</p>
|
||||
<p className="brand__subtitle">สถานีขนส่งผู้โดยสารจังหวัดอ่างทอง</p>
|
||||
</div>
|
||||
</Link>
|
||||
<nav className="nav" aria-label="เมนูหลัก">
|
||||
{links.map((l) => (
|
||||
<Link key={l.href} href={l.href} className={isActive(l.href) ? "active" : ""}>
|
||||
{l.label}
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
<Link href="/routes" className="cta-pill">เช็กเวลาเดินรถ</Link>
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import dynamic from "next/dynamic";
|
||||
import type { MapViewProps } from "@/components/MapView";
|
||||
|
||||
const ClientMapView = dynamic(() => import("@/components/MapView"), { ssr: false });
|
||||
|
||||
export default function LazyMapView(props: MapViewProps) {
|
||||
return <ClientMapView {...props} />;
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
"use client";
|
||||
import "leaflet/dist/leaflet.css";
|
||||
import { MapContainer, TileLayer, Marker, Popup, Polyline, useMap } from "react-leaflet";
|
||||
import L from "leaflet";
|
||||
import { useEffect } from "react";
|
||||
|
||||
type LatLng = [number, number];
|
||||
type Point = { id: number; lat: number; lng: number; label: string; code: string; sequence?: number };
|
||||
|
||||
// Fix default marker icon paths for webpack/Next
|
||||
const icon = new L.Icon({
|
||||
iconUrl: "https://unpkg.com/[email protected]/dist/images/marker-icon.png",
|
||||
iconRetinaUrl: "https://unpkg.com/[email protected]/dist/images/marker-icon-2x.png",
|
||||
shadowUrl: "https://unpkg.com/[email protected]/dist/images/marker-shadow.png",
|
||||
iconSize: [25, 41],
|
||||
iconAnchor: [12, 41],
|
||||
});
|
||||
|
||||
function numberedIcon(n: number, tone: "start" | "mid" | "end") {
|
||||
const colors: Record<string, string> = {
|
||||
start: "linear-gradient(135deg,#34d399,#10b981)",
|
||||
end: "linear-gradient(135deg,#fb7185,#e11d48)",
|
||||
mid: "linear-gradient(135deg,#a78bfa,#7c3aed)",
|
||||
};
|
||||
const html =
|
||||
'<div style="' +
|
||||
'width:32px;height:32px;border-radius:50%;' +
|
||||
'background:' + colors[tone] + ';' +
|
||||
'color:#fff;font-weight:800;font-size:13px;font-family:system-ui;' +
|
||||
'display:flex;align-items:center;justify-content:center;' +
|
||||
'border:3px solid #fff;' +
|
||||
'box-shadow:0 4px 10px rgba(31,28,68,.28), 0 0 0 1px rgba(124,58,237,.18);' +
|
||||
'">' + String(n) + '</div>';
|
||||
return L.divIcon({
|
||||
html,
|
||||
className: "route-marker",
|
||||
iconSize: [32, 32],
|
||||
iconAnchor: [16, 16],
|
||||
popupAnchor: [0, -14],
|
||||
});
|
||||
}
|
||||
|
||||
function FitBounds({ positions }: { positions: LatLng[] }) {
|
||||
const map = useMap();
|
||||
useEffect(() => {
|
||||
if (positions.length === 0) return;
|
||||
if (positions.length === 1) {
|
||||
map.setView(positions[0], 12);
|
||||
return;
|
||||
}
|
||||
const bounds = L.latLngBounds(positions.map((p) => L.latLng(p[0], p[1])));
|
||||
map.fitBounds(bounds, { padding: [36, 36] });
|
||||
}, [map, positions]);
|
||||
return null;
|
||||
}
|
||||
|
||||
type Props = {
|
||||
points: Point[];
|
||||
path?: LatLng[];
|
||||
};
|
||||
|
||||
export type MapViewProps = Props;
|
||||
|
||||
export default function MapView({ points, path }: Props) {
|
||||
const fallback: LatLng[] = points.map((p) => [p.lat, p.lng]);
|
||||
const positions: LatLng[] = path && path.length > 0 ? path : fallback;
|
||||
const center: LatLng = positions.length > 0 ? positions[0] : [9.1, 99.3];
|
||||
const isRoute = !!path && path.length > 0;
|
||||
return (
|
||||
<MapContainer center={center} zoom={9} style={{ height: "100%", width: "100%" }}>
|
||||
<TileLayer
|
||||
attribution='© OpenStreetMap'
|
||||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||
/>
|
||||
{isRoute && path ? (
|
||||
<Polyline
|
||||
positions={path}
|
||||
pathOptions={{ color: "#7c3aed", weight: 5, opacity: 0.85, lineCap: "round" }}
|
||||
/>
|
||||
) : null}
|
||||
{points.map((p, idx) => {
|
||||
let tone: "start" | "mid" | "end" = "mid";
|
||||
if (isRoute) {
|
||||
if (idx === 0) tone = "start";
|
||||
else if (idx === points.length - 1) tone = "end";
|
||||
}
|
||||
const markerIcon = isRoute ? numberedIcon(p.sequence ?? idx + 1, tone) : icon;
|
||||
const stopHref = p.code ? `/stops/${encodeURIComponent(p.code)}` : null;
|
||||
return (
|
||||
<Marker key={String(p.id) + "-" + String(idx)} position={[p.lat, p.lng]} icon={markerIcon}>
|
||||
<Popup>
|
||||
<strong>{p.label}</strong>
|
||||
<br />
|
||||
{stopHref ? <a href={stopHref}>รายละเอียด →</a> : <span>ไม่มีรหัสป้าย</span>}
|
||||
</Popup>
|
||||
</Marker>
|
||||
);
|
||||
})}
|
||||
<FitBounds positions={positions} />
|
||||
</MapContainer>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user