import { RefreshCw } from "lucide-react"; import React from "react"; import { useTranslation } from "react-i18next"; import { Sheet } from "react-modal-sheet"; import { Link } from "react-router"; import { ArrivalList } from "~/components/arrivals/ArrivalList"; import { useStopArrivals } from "../../hooks/useArrivals"; import { ErrorDisplay } from "../ErrorDisplay"; import LineIcon from "../LineIcon"; import "./StopSummarySheet.css"; import { StopSummarySheetSkeleton } from "./StopSummarySheetSkeleton"; export interface StopSheetProps { isOpen: boolean; onClose: () => void; stop: { stopId: string; stopCode?: string; stopFeed?: string; name: string; lines: { line: string; colour?: string; textColour?: string; }[]; }; } export const StopSummarySheet: React.FC = ({ isOpen, onClose, stop, }) => { const { t } = useTranslation(); const { data, isLoading: loading, error, refetch: loadData, dataUpdatedAt, } = useStopArrivals(stop.stopId, true, isOpen); const lastUpdated = dataUpdatedAt ? new Date(dataUpdatedAt) : null; // Show only the next 4 arrivals const limitedEstimates = data?.arrivals.slice(0, 4) ?? []; return (

{stop.name}

({stop.stopCode})
{stop.lines.map((lineObj) => ( ))}
{/* TODO: Enable stop alerts when available */} {/**/} {loading ? ( ) : error ? ( loadData()} title={t( "errors.estimates_title", "Error al cargar estimaciones" )} className="compact" /> ) : data ? ( <>

{t("estimates.next_arrivals", "Next arrivals")}

{limitedEstimates.length === 0 ? (
{t("estimates.none", "No hay estimaciones disponibles")}
) : ( )}
) : null}
{lastUpdated && (
{t("estimates.last_updated", "Actualizado a las")}{" "} {lastUpdated.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit", second: "2-digit", })}
)}
{t("map.view_all_estimates", "Ver todas las estimaciones")}
); };