diff options
| -rw-r--r-- | .gitignore | 4 | ||||
| -rw-r--r-- | eslint.config.ts (renamed from eslint.config.js) | 0 | ||||
| -rw-r--r-- | package-lock.json | 37 | ||||
| -rw-r--r-- | package.json | 4 | ||||
| -rw-r--r-- | src/pages/Estimates.tsx | 24 | ||||
| -rw-r--r-- | src/pages/Map.tsx | 10 | ||||
| -rw-r--r-- | tsconfig.app.tsbuildinfo | 1 | ||||
| -rw-r--r-- | tsconfig.node.tsbuildinfo | 1 |
8 files changed, 59 insertions, 22 deletions
@@ -1,3 +1,7 @@ +# Typescript incremental build +.tsbuildinfo +*.tsbuildinfo + # Logs logs *.log diff --git a/eslint.config.js b/eslint.config.ts index 092408a..092408a 100644 --- a/eslint.config.js +++ b/eslint.config.ts diff --git a/package-lock.json b/package-lock.json index 81fe11b..50040cc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,8 @@ }, "devDependencies": { "@eslint/js": "^9.9.0", - "@types/node": "^22.13.8", + "@types/leaflet": "^1.9.16", + "@types/node": "^22.13.9", "@types/react": "^19.0.0", "@types/react-dom": "^19.0.0", "@vitejs/plugin-react-swc": "^3.8.0", @@ -27,6 +28,7 @@ "eslint-plugin-react-hooks": "^5.2.0", "eslint-plugin-react-refresh": "^0.4.19", "globals": "^15.15.0", + "jiti": "^2.4.2", "typescript": "^5.7.3", "typescript-eslint": "^8.25.0", "vite": "^6.2.0" @@ -1220,6 +1222,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/geojson": { + "version": "7946.0.16", + "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.16.tgz", + "integrity": "sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", @@ -1227,10 +1236,20 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/leaflet": { + "version": "1.9.16", + "resolved": "https://registry.npmjs.org/@types/leaflet/-/leaflet-1.9.16.tgz", + "integrity": "sha512-wzZoyySUxkgMZ0ihJ7IaUIblG8Rdc8AbbZKLneyn+QjYsj5q1QU7TEKYqwTr10BGSzY5LI7tJk9Ifo+mEjdFRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/geojson": "*" + } + }, "node_modules/@types/node": { - "version": "22.13.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.8.tgz", - "integrity": "sha512-G3EfaZS+iOGYWLLRCEAXdWK9my08oHNZ+FHluRiggIYJPOXzhOiDgpVCUHaUvyIC5/fj7C/p637jdzC666AOKQ==", + "version": "22.13.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.9.tgz", + "integrity": "sha512-acBjXdRJ3A6Pb3tqnw9HZmyR3Fiol3aGxRCK1x3d+6CDAMjl7I649wpSd+yNURCjbOUGu9tqtLKnTGxmK6CyGw==", "dev": true, "license": "MIT", "dependencies": { @@ -2180,6 +2199,16 @@ "dev": true, "license": "ISC" }, + "node_modules/jiti": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.4.2.tgz", + "integrity": "sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==", + "dev": true, + "license": "MIT", + "bin": { + "jiti": "lib/jiti-cli.mjs" + } + }, "node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", diff --git a/package.json b/package.json index 37765a7..8f7258f 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ }, "devDependencies": { "@eslint/js": "^9.9.0", - "@types/node": "^22.13.8", + "@types/leaflet": "^1.9.16", + "@types/node": "^22.13.9", "@types/react": "^19.0.0", "@types/react-dom": "^19.0.0", "@vitejs/plugin-react-swc": "^3.8.0", @@ -32,6 +33,7 @@ "eslint-plugin-react-hooks": "^5.2.0", "eslint-plugin-react-refresh": "^0.4.19", "globals": "^15.15.0", + "jiti": "^2.4.2", "typescript": "^5.7.3", "typescript-eslint": "^8.25.0", "vite": "^6.2.0" diff --git a/src/pages/Estimates.tsx b/src/pages/Estimates.tsx index 3f002be..a445300 100644 --- a/src/pages/Estimates.tsx +++ b/src/pages/Estimates.tsx @@ -1,5 +1,5 @@ -import { useEffect, useState } from "react"; -import { Link, useParams } from "react-router"; +import { JSX, useEffect, useState } from "react"; +import { useParams } from "react-router"; import { StopDataProvider } from "../data/StopDataProvider"; import LineIcon from "../components/LineIcon"; import { Star } from 'lucide-react'; @@ -20,31 +20,33 @@ interface StopDetails { }[] } +const sdp = new StopDataProvider(); + +const loadData = async (stopId: string) => { + const resp = await fetch(`/api/GetStopEstimates?id=${stopId}`); + return await resp.json(); +}; + export function Estimates(): JSX.Element { - const sdp = new StopDataProvider(); const [data, setData] = useState<StopDetails | null>(null); const [dataDate, setDataDate] = useState<Date | null>(null); const [favourited, setFavourited] = useState(false); const params = useParams(); - const loadData = () => { - fetch(`/api/GetStopEstimates?id=${params.stopId}`) - .then(r => r.json()) + useEffect(() => { + loadData(params.stopId!) .then((body: StopDetails) => { setData(body); setDataDate(new Date()); - }); - }; + }) - useEffect(() => { - loadData(); sdp.pushRecent(parseInt(params.stopId ?? "")); setFavourited( sdp.isFavourite(parseInt(params.stopId ?? "")) ); - }, []); + }, [params.stopId]); const absoluteArrivalTime = (minutes: number) => { const now = new Date() diff --git a/src/pages/Map.tsx b/src/pages/Map.tsx index 4d89ae0..9b960be 100644 --- a/src/pages/Map.tsx +++ b/src/pages/Map.tsx @@ -6,17 +6,15 @@ import 'react-leaflet-markercluster/styles' import { useEffect, useState } from 'react'; import LineIcon from '../components/LineIcon'; import { Link } from 'react-router'; -import { MapContainer } from "react-leaflet/MapContainer"; -import { TileLayer } from "react-leaflet/TileLayer"; -import { Marker } from "react-leaflet/Marker"; -import { Popup } from "react-leaflet/Popup"; +import { MapContainer, TileLayer, Marker, Popup } from "react-leaflet"; import MarkerClusterGroup from "react-leaflet-markercluster"; +import { LatLngTuple } from "leaflet"; const sdp = new StopDataProvider(); export function StopMap() { const [stops, setStops] = useState<Stop[]>([]); - const position = [42.229188855975046, -8.72246955783102] + const position: LatLngTuple = [42.229188855975046, -8.72246955783102] useEffect(() => { sdp.getStops().then((stops) => { setStops(stops); }); @@ -30,7 +28,7 @@ export function StopMap() { /> <MarkerClusterGroup> {stops.map((stop) => ( - <Marker key={stop.stopId} position={[stop.latitude, stop.longitude]}> + <Marker key={stop.stopId} position={[stop.latitude, stop.longitude] as LatLngTuple}> <Popup> <Link to={`/estimates/${stop.stopId}`}>{stop.name}</Link> <br /> diff --git a/tsconfig.app.tsbuildinfo b/tsconfig.app.tsbuildinfo new file mode 100644 index 0000000..e324880 --- /dev/null +++ b/tsconfig.app.tsbuildinfo @@ -0,0 +1 @@ +{"root":["./src/layout.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/components/lineicon.tsx","./src/components/stopitem.tsx","./src/data/stopdataprovider.ts","./src/pages/about.tsx","./src/pages/estimates.tsx","./src/pages/map.tsx","./src/pages/stoplist.tsx"],"version":"5.7.3"}
\ No newline at end of file diff --git a/tsconfig.node.tsbuildinfo b/tsconfig.node.tsbuildinfo new file mode 100644 index 0000000..0440098 --- /dev/null +++ b/tsconfig.node.tsbuildinfo @@ -0,0 +1 @@ +{"root":["./vite.config.ts"],"version":"5.7.3"}
\ No newline at end of file |
