50 lines
1.8 KiB
TypeScript
50 lines
1.8 KiB
TypeScript
import {
|
|
IconBus,
|
|
IconCar,
|
|
IconTrain,
|
|
type Icon as TablerIcon,
|
|
} from "@tabler/icons-react";
|
|
|
|
import { transportValue, type TransportMode } from "@/lib/cinemas";
|
|
import { useI18n } from "@/lib/i18n";
|
|
import { COLORS } from "@/lib/design-tokens";
|
|
|
|
const TRANSPORT_ICONS: Record<TransportMode["icon_name"], TablerIcon> = {
|
|
private_car: IconCar,
|
|
metro: IconTrain,
|
|
bus: IconBus,
|
|
};
|
|
|
|
/** วิธีเดินทางมาถึงโรงหนัง — ซ่อนทั้งบล็อกถ้ายังไม่มีข้อมูล */
|
|
export function TransportList({ transport }: { transport: TransportMode[] }) {
|
|
const { locale, messages } = useI18n();
|
|
// แถวที่ยังไม่ได้กรอกรายละเอียด (เพิ่มจากหลังบ้านแล้วเว้นว่าง) ไม่ต้องแสดง
|
|
const routes = transport.filter((route) => route.value.trim() !== "");
|
|
|
|
if (routes.length === 0) return null;
|
|
|
|
return (
|
|
<div className="flex flex-col">
|
|
{routes.map((route, index) => {
|
|
const Icon = TRANSPORT_ICONS[route.icon_name];
|
|
const isLast = index === routes.length - 1;
|
|
return (
|
|
<div
|
|
key={`${route.icon_name}-${index}`}
|
|
className="flex flex-col justify-between gap-1 py-2.5 sm:min-h-10 sm:flex-row sm:gap-4"
|
|
style={{
|
|
borderBottom: isLast ? undefined : `1px solid ${COLORS.border}`,
|
|
}}
|
|
>
|
|
<div className="flex items-center gap-2 font-medium">
|
|
<Icon size={20} />
|
|
{messages.transport[route.icon_name]}
|
|
</div>
|
|
<div className="sm:text-right">{transportValue(route, locale)}</div>
|
|
</div>
|
|
);
|
|
})}
|
|
</div>
|
|
);
|
|
}
|