added DME, fixed sync and bugs. Rewrote setDisplay logic
This commit is contained in:
33
apps/dispatch/app/pilot/_components/dme/useButtons.ts
Normal file
33
apps/dispatch/app/pilot/_components/dme/useButtons.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { usePilotConnectionStore } from "_store/pilot/connectionStore";
|
||||
import { useDmeStore } from "_store/pilot/dmeStore";
|
||||
|
||||
import { useSession } from "next-auth/react";
|
||||
export const useButtons = () => {
|
||||
const { page, setPage } = useDmeStore((state) => state);
|
||||
const user = useSession().data?.user;
|
||||
const station = usePilotConnectionStore((state) => state.selectedStation);
|
||||
|
||||
const handleButton = (button: "main" | "menu" | "left" | "right") => () => {
|
||||
switch (button) {
|
||||
case "main":
|
||||
if (page === "mission") {
|
||||
setPage({ page: "acknowledge" });
|
||||
}
|
||||
break;
|
||||
case "menu":
|
||||
console.log("home", page, { station, user });
|
||||
if (station && user) {
|
||||
setPage({ page: "home", station, user });
|
||||
} else {
|
||||
setPage({ page: "error", error: "No station or user found" });
|
||||
}
|
||||
break;
|
||||
default:
|
||||
setPage({ page: "error", error: "Button now allowed" });
|
||||
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
return { handleButton };
|
||||
};
|
||||
Reference in New Issue
Block a user