diff --git a/apps/dashboard/src/App.tsx b/apps/dashboard/src/App.tsx
index 488b7cf..4c98295 100644
--- a/apps/dashboard/src/App.tsx
+++ b/apps/dashboard/src/App.tsx
@@ -1,6 +1,7 @@
import { useQuery } from "@tanstack/react-query"
import { useEffect, useState } from "react"
import cn from "./components/lib/cn"
+import { StatusSeverity, getLineColor, getStatusBorderColor, tflDisruptionsQuery } from "./tfl"
import {
DEFAULT_LATITUDE,
DEFAULT_LONGITUDE,
@@ -15,17 +16,26 @@ function App() {
+
)
}
-function Tile({ children, className }: { children: React.ReactNode; className?: string }) {
+function Tile({
+ decorations = true,
+ children,
+ className,
+}: { decorations?: boolean; children: React.ReactNode; className?: string }) {
return (
-
-
-
-
+ {decorations && (
+ <>
+
+
+
+
+ >
+ )}
{children}
)
@@ -195,4 +205,90 @@ function WeatherTile() {
)
}
+function TFLTile() {
+ const {
+ data: tflData,
+ isLoading: isLoadingTFL,
+ error: errorTFL,
+ } = useQuery({
+ ...tflDisruptionsQuery(),
+ select: (data) => {
+ data.disruptions.sort((a, b) => {
+ if (a.lineName.match(/northern/i)) return -1
+ return a.statusSeverity - b.statusSeverity
+ })
+ return data
+ },
+ refetchInterval: 5 * 60 * 1000, // 5 minutes
+ refetchIntervalInBackground: true,
+ })
+
+ if (isLoadingTFL) {
+ return (
+
+ Loading TfL
+
+ )
+ }
+
+ return (
+
+ {tflData?.goodService.includes("Northern") && (
+
+ )}
+ {tflData?.disruptions.map((disruption) => (
+ <>
+
+
+ >
+ ))}
+
+ )
+}
+
+function TFLDistruptionItem({
+ lineId,
+ lineName,
+ reason,
+ severity,
+}: { lineId: string; lineName: string; reason: string; severity: number }) {
+ return (
+ <>
+
+
+ {reason}
+
+ >
+ )
+}
+
export default App