diff --git a/apps/dispatch/app/_components/QueryProvider.tsx b/apps/dispatch/app/_components/QueryProvider.tsx index eb39371f..f9e2b384 100644 --- a/apps/dispatch/app/_components/QueryProvider.tsx +++ b/apps/dispatch/app/_components/QueryProvider.tsx @@ -10,7 +10,7 @@ import { HPGnotificationToast } from "_components/customToasts/HPGnotification"; import { useMapStore } from "_store/mapStore"; import { AdminMessageToast } from "_components/customToasts/AdminMessage"; import { pilotSocket } from "(app)/pilot/socket"; -import { StatusToast } from "_components/customToasts/StationStatusToast"; +import { QUICK_RESPONSE, StatusToast } from "_components/customToasts/StationStatusToast"; export function QueryProvider({ children }: { children: ReactNode }) { const mapStore = useMapStore((s) => s); @@ -76,7 +76,7 @@ export function QueryProvider({ children }: { children: ReactNode }) { }); break; case "station-status": - if (notification.status !== "5") return; + if (!QUICK_RESPONSE[notification.status]) return; toast.custom((e) => , { duration: 60000, }); diff --git a/apps/dispatch/app/_components/customToasts/StationStatusToast.tsx b/apps/dispatch/app/_components/customToasts/StationStatusToast.tsx index 80ae3fe6..a6891d25 100644 --- a/apps/dispatch/app/_components/customToasts/StationStatusToast.tsx +++ b/apps/dispatch/app/_components/customToasts/StationStatusToast.tsx @@ -6,13 +6,25 @@ import { editConnectedAircraftAPI, getConnectedAircraftsAPI } from "_querys/airc import { getStationsAPI } from "_querys/stations"; import { useMapStore } from "_store/mapStore"; import { X } from "lucide-react"; +import { useEffect, useRef } from "react"; import { Toast, toast } from "react-hot-toast"; -const QUICK_RESPONSE: Record = { +export const QUICK_RESPONSE: Record = { "5": ["J", "c"], + "0": ["J", "c"], }; export const StatusToast = ({ event, t }: { event: StationStatus; t: Toast }) => { + const status0Sounds = useRef(null); + const status5Sounds = useRef(null); + + useEffect(() => { + if (typeof window !== "undefined") { + status0Sounds.current = new Audio("/sounds/status-0.mp3"); + status5Sounds.current = new Audio("/sounds/status-5.mp3"); + } + }, []); + const mapStore = useMapStore((s) => s); const { data: connectedAircrafts } = useQuery({ @@ -44,6 +56,18 @@ export const StatusToast = ({ event, t }: { event: StationStatus; t: Toast }) => const connectedAircraft = connectedAircrafts?.find((a) => a.id === event.data?.aircraftId); const station = stations?.find((s) => s.id === event.data?.stationId); + useEffect(() => { + if (connectedAircraft?.fmsStatus === "0" && status0Sounds.current) { + status0Sounds.current.currentTime = 0; + status0Sounds.current.volume = 0.7; + status0Sounds.current.play(); + } else if (connectedAircraft?.fmsStatus === "5" && status5Sounds.current) { + status5Sounds.current.currentTime = 0; + status5Sounds.current.volume = 0.7; + status5Sounds.current.play(); + } + }, [connectedAircraft?.fmsStatus]); + if (!connectedAircraft || !station) return null; return ( diff --git a/apps/dispatch/public/sounds/MRT-startup.wav b/apps/dispatch/public/sounds/MRT-startup.wav new file mode 100644 index 00000000..e9a49789 Binary files /dev/null and b/apps/dispatch/public/sounds/MRT-startup.wav differ diff --git a/apps/dispatch/public/sounds/status-0.mp3 b/apps/dispatch/public/sounds/status-0.mp3 new file mode 100644 index 00000000..1ce6f45b Binary files /dev/null and b/apps/dispatch/public/sounds/status-0.mp3 differ diff --git a/apps/dispatch/public/sounds/status-5.mp3 b/apps/dispatch/public/sounds/status-5.mp3 new file mode 100644 index 00000000..c6b5c208 Binary files /dev/null and b/apps/dispatch/public/sounds/status-5.mp3 differ