diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2025-11-06 15:44:58 +0100 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2025-11-06 15:44:58 +0100 |
| commit | 093ee906eae5361bbf47ae2fdc4003f95696656a (patch) | |
| tree | 055c656f69e91d6f503a4e11b9808e825e012feb /src/frontend | |
| parent | d95cfa74c5fcb9e58af1f85f8d76d859f155fce3 (diff) | |
Rename schedules table
Diffstat (limited to 'src/frontend')
| -rw-r--r-- | src/frontend/app/components/SchedulesTable.css (renamed from src/frontend/app/components/TimetableTable.css) | 0 | ||||
| -rw-r--r-- | src/frontend/app/components/SchedulesTable.tsx (renamed from src/frontend/app/components/TimetableTable.tsx) | 12 | ||||
| -rw-r--r-- | src/frontend/app/components/SchedulesTableSkeleton.tsx (renamed from src/frontend/app/components/EstimatesTableSkeleton.tsx) | 2 | ||||
| -rw-r--r-- | src/frontend/app/routes/estimates-$id.tsx | 26 | ||||
| -rw-r--r-- | src/frontend/app/routes/timetable-$id.tsx | 18 |
5 files changed, 29 insertions, 29 deletions
diff --git a/src/frontend/app/components/TimetableTable.css b/src/frontend/app/components/SchedulesTable.css index 8980fb4..8980fb4 100644 --- a/src/frontend/app/components/TimetableTable.css +++ b/src/frontend/app/components/SchedulesTable.css diff --git a/src/frontend/app/components/TimetableTable.tsx b/src/frontend/app/components/SchedulesTable.tsx index 8215141..afa6f8e 100644 --- a/src/frontend/app/components/TimetableTable.tsx +++ b/src/frontend/app/components/SchedulesTable.tsx @@ -1,9 +1,9 @@ import { useTranslation } from "react-i18next"; import LineIcon from "./LineIcon"; -import "./TimetableTable.css"; -import { useApp } from "../AppContext"; +import "./SchedulesTable.css"; +import { useApp } from "~/AppContext"; -export interface TimetableEntry { +export interface ScheduledTable { line: { name: string; colour: string; @@ -23,7 +23,7 @@ export interface TimetableEntry { } interface TimetableTableProps { - data: TimetableEntry[]; + data: ScheduledTable[]; showAll?: boolean; currentTime?: string; // HH:MM:SS format } @@ -69,7 +69,7 @@ const timeToMinutes = (time: string): number => { }; // Utility function to find nearby entries -const findNearbyEntries = (entries: TimetableEntry[], currentTime: string, before: number = 4, after: number = 4): TimetableEntry[] => { +const findNearbyEntries = (entries: ScheduledTable[], currentTime: string, before: number = 4, after: number = 4): ScheduledTable[] => { if (!currentTime) return entries.slice(0, before + after); const currentMinutes = timeToMinutes(currentTime); @@ -92,7 +92,7 @@ const findNearbyEntries = (entries: TimetableEntry[], currentTime: string, befor return sortedEntries.slice(startIndex, endIndex); }; -export const TimetableTable: React.FC<TimetableTableProps> = ({ +export const SchedulesTable: React.FC<TimetableTableProps> = ({ data, showAll = false, currentTime diff --git a/src/frontend/app/components/EstimatesTableSkeleton.tsx b/src/frontend/app/components/SchedulesTableSkeleton.tsx index 2ef770b..50ba94d 100644 --- a/src/frontend/app/components/EstimatesTableSkeleton.tsx +++ b/src/frontend/app/components/SchedulesTableSkeleton.tsx @@ -7,7 +7,7 @@ interface EstimatesTableSkeletonProps { rows?: number; } -export const EstimatesTableSkeleton: React.FC<EstimatesTableSkeletonProps> = ({ +export const SchedulesTableSkeleton: React.FC<EstimatesTableSkeletonProps> = ({ rows = 3 }) => { const { t } = useTranslation(); diff --git a/src/frontend/app/routes/estimates-$id.tsx b/src/frontend/app/routes/estimates-$id.tsx index 60d533a..f213105 100644 --- a/src/frontend/app/routes/estimates-$id.tsx +++ b/src/frontend/app/routes/estimates-$id.tsx @@ -7,13 +7,13 @@ import { RegularTable } from "../components/RegularTable"; import { useApp } from "../AppContext"; import { GroupedTable } from "../components/GroupedTable"; import { useTranslation } from "react-i18next"; -import { TimetableTable, type TimetableEntry } from "../components/TimetableTable"; -import { EstimatesTableSkeleton, EstimatesGroupedSkeleton } from "../components/EstimatesTableSkeleton"; -import { TimetableSkeleton } from "../components/TimetableSkeleton"; -import { ErrorDisplay } from "../components/ErrorDisplay"; -import { PullToRefresh } from "../components/PullToRefresh"; -import { useAutoRefresh } from "../hooks/useAutoRefresh"; -import { type RegionId, getRegionConfig } from "../data/RegionConfig"; +import { SchedulesTable, type ScheduledTable } from "~/components/SchedulesTable"; +import { SchedulesTableSkeleton, EstimatesGroupedSkeleton } from "~/components/SchedulesTableSkeleton"; +import { TimetableSkeleton } from "~/components/TimetableSkeleton"; +import { ErrorDisplay } from "~/components/ErrorDisplay"; +import { PullToRefresh } from "~/components/PullToRefresh"; +import { useAutoRefresh } from "~/hooks/useAutoRefresh"; +import { type RegionId, getRegionConfig } from "~/data/RegionConfig"; export interface Estimate { line: string; @@ -43,7 +43,7 @@ const loadData = async (region: RegionId, stopId: string): Promise<Estimate[]> = return await resp.json(); }; -const loadTimetableData = async (region: RegionId, stopId: string): Promise<TimetableEntry[]> => { +const loadTimetableData = async (region: RegionId, stopId: string): Promise<ScheduledTable[]> => { const regionConfig = getRegionConfig(region); // Check if timetable is available for this region @@ -79,7 +79,7 @@ export default function Estimates() { const [estimatesError, setEstimatesError] = useState<ErrorInfo | null>(null); // Timetable data state - const [timetableData, setTimetableData] = useState<TimetableEntry[]>([]); + const [timetableData, setTimetableData] = useState<ScheduledTable[]>([]); const [timetableLoading, setTimetableLoading] = useState(true); const [timetableError, setTimetableError] = useState<ErrorInfo | null>(null); @@ -114,7 +114,7 @@ export default function Estimates() { const body = await loadData(region, params.id!); setData(body); setDataDate(new Date()); - + // Load stop data from StopDataProvider const stop = await StopDataProvider.getStopById(region, stopIdNum); setStopData(stop); @@ -237,7 +237,7 @@ export default function Estimates() { {tableStyle === "grouped" ? ( <EstimatesGroupedSkeleton /> ) : ( - <EstimatesTableSkeleton /> + <SchedulesTableSkeleton /> )} </div> @@ -281,7 +281,7 @@ export default function Estimates() { tableStyle === "grouped" ? ( <EstimatesGroupedSkeleton /> ) : ( - <EstimatesTableSkeleton /> + <SchedulesTableSkeleton /> ) ) : estimatesError ? ( <ErrorDisplay @@ -310,7 +310,7 @@ export default function Estimates() { /> ) : timetableData.length > 0 ? ( <> - <TimetableTable + <SchedulesTable data={timetableData} currentTime={new Date().toTimeString().slice(0, 8)} // HH:MM:SS /> diff --git a/src/frontend/app/routes/timetable-$id.tsx b/src/frontend/app/routes/timetable-$id.tsx index 1942ce8..702989a 100644 --- a/src/frontend/app/routes/timetable-$id.tsx +++ b/src/frontend/app/routes/timetable-$id.tsx @@ -2,13 +2,13 @@ import { useEffect, useState, useRef } from "react"; import { useParams, Link } from "react-router"; import StopDataProvider from "../data/StopDataProvider"; import { ArrowLeft, Eye, EyeOff } from "lucide-react"; -import { TimetableTable, type TimetableEntry } from "../components/TimetableTable"; -import { TimetableSkeleton } from "../components/TimetableSkeleton"; -import { ErrorDisplay } from "../components/ErrorDisplay"; +import { type ScheduledTable } from "~/components/SchedulesTable"; +import { TimetableSkeleton } from "~/components/TimetableSkeleton"; +import { ErrorDisplay } from "~/components/ErrorDisplay"; import LineIcon from "../components/LineIcon"; import { useTranslation } from "react-i18next"; -import { type RegionId, getRegionConfig } from "../data/RegionConfig"; -import { useApp } from "../AppContext"; +import { type RegionId, getRegionConfig } from "~/data/RegionConfig"; +import { useApp } from "~/AppContext"; import "./timetable-$id.css"; interface ErrorInfo { @@ -17,7 +17,7 @@ interface ErrorInfo { message?: string; } -const loadTimetableData = async (region: RegionId, stopId: string): Promise<TimetableEntry[]> => { +const loadTimetableData = async (region: RegionId, stopId: string): Promise<ScheduledTable[]> => { const regionConfig = getRegionConfig(region); // Check if timetable is available for this region @@ -49,7 +49,7 @@ const timeToMinutes = (time: string): number => { }; // Filter past entries (keep only a few recent past ones) -const filterTimetableData = (data: TimetableEntry[], currentTime: string, showPast: boolean = false): TimetableEntry[] => { +const filterTimetableData = (data: ScheduledTable[], currentTime: string, showPast: boolean = false): ScheduledTable[] => { if (showPast) return data; const currentMinutes = timeToMinutes(currentTime); @@ -111,7 +111,7 @@ export default function Timetable() { const { region } = useApp(); const params = useParams(); const stopIdNum = parseInt(params.id ?? ""); - const [timetableData, setTimetableData] = useState<TimetableEntry[]>([]); + const [timetableData, setTimetableData] = useState<ScheduledTable[]>([]); const [customName, setCustomName] = useState<string | undefined>(undefined); const [loading, setLoading] = useState(true); const [error, setError] = useState<ErrorInfo | null>(null); @@ -282,7 +282,7 @@ export default function Timetable() { // Custom component for the full timetable with scroll reference const TimetableTableWithScroll: React.FC<{ - data: TimetableEntry[]; + data: ScheduledTable[]; showAll: boolean; currentTime: string; nextEntryRef: React.RefObject<HTMLDivElement | null>; |
