sounds
This commit is contained in:
@@ -10,7 +10,7 @@ import { HPGnotificationToast } from "_components/customToasts/HPGnotification";
|
|||||||
import { useMapStore } from "_store/mapStore";
|
import { useMapStore } from "_store/mapStore";
|
||||||
import { AdminMessageToast } from "_components/customToasts/AdminMessage";
|
import { AdminMessageToast } from "_components/customToasts/AdminMessage";
|
||||||
import { pilotSocket } from "(app)/pilot/socket";
|
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 }) {
|
export function QueryProvider({ children }: { children: ReactNode }) {
|
||||||
const mapStore = useMapStore((s) => s);
|
const mapStore = useMapStore((s) => s);
|
||||||
@@ -76,7 +76,7 @@ export function QueryProvider({ children }: { children: ReactNode }) {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "station-status":
|
case "station-status":
|
||||||
if (notification.status !== "5") return;
|
if (!QUICK_RESPONSE[notification.status]) return;
|
||||||
toast.custom((e) => <StatusToast event={notification} t={e} />, {
|
toast.custom((e) => <StatusToast event={notification} t={e} />, {
|
||||||
duration: 60000,
|
duration: 60000,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,13 +6,25 @@ import { editConnectedAircraftAPI, getConnectedAircraftsAPI } from "_querys/airc
|
|||||||
import { getStationsAPI } from "_querys/stations";
|
import { getStationsAPI } from "_querys/stations";
|
||||||
import { useMapStore } from "_store/mapStore";
|
import { useMapStore } from "_store/mapStore";
|
||||||
import { X } from "lucide-react";
|
import { X } from "lucide-react";
|
||||||
|
import { useEffect, useRef } from "react";
|
||||||
import { Toast, toast } from "react-hot-toast";
|
import { Toast, toast } from "react-hot-toast";
|
||||||
|
|
||||||
const QUICK_RESPONSE: Record<string, string[]> = {
|
export const QUICK_RESPONSE: Record<string, string[]> = {
|
||||||
"5": ["J", "c"],
|
"5": ["J", "c"],
|
||||||
|
"0": ["J", "c"],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const StatusToast = ({ event, t }: { event: StationStatus; t: Toast }) => {
|
export const StatusToast = ({ event, t }: { event: StationStatus; t: Toast }) => {
|
||||||
|
const status0Sounds = useRef<HTMLAudioElement | null>(null);
|
||||||
|
const status5Sounds = useRef<HTMLAudioElement | null>(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 mapStore = useMapStore((s) => s);
|
||||||
|
|
||||||
const { data: connectedAircrafts } = useQuery({
|
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 connectedAircraft = connectedAircrafts?.find((a) => a.id === event.data?.aircraftId);
|
||||||
const station = stations?.find((s) => s.id === event.data?.stationId);
|
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;
|
if (!connectedAircraft || !station) return null;
|
||||||
return (
|
return (
|
||||||
<BaseNotification>
|
<BaseNotification>
|
||||||
|
|||||||
BIN
apps/dispatch/public/sounds/MRT-startup.wav
Normal file
BIN
apps/dispatch/public/sounds/MRT-startup.wav
Normal file
Binary file not shown.
BIN
apps/dispatch/public/sounds/status-0.mp3
Normal file
BIN
apps/dispatch/public/sounds/status-0.mp3
Normal file
Binary file not shown.
BIN
apps/dispatch/public/sounds/status-5.mp3
Normal file
BIN
apps/dispatch/public/sounds/status-5.mp3
Normal file
Binary file not shown.
Reference in New Issue
Block a user