securityos/components/system/Taskbar/Clock/useClockContextMenu.ts

33 lines
894 B
TypeScript
Raw Normal View History

2024-09-06 15:32:35 +00:00
import { useMenu } from "contexts/menu";
import type { ContextMenuCapture } from "contexts/menu/useMenuContextState";
import { useSession } from "contexts/session";
import { useMemo } from "react";
const useClockContextMenu = (): ContextMenuCapture => {
const { contextMenu } = useMenu();
const { clockSource, setClockSource } = useSession();
return useMemo(
() =>
contextMenu?.(() => {
const isLocal = clockSource === "local";
return [
{
action: () => setClockSource("local"),
label: "Horário Local",
toggle: isLocal,
},
{
action: () => setClockSource("ntp"),
label: "Servidor",
toggle: !isLocal,
},
];
}),
[clockSource, contextMenu, setClockSource]
);
};
export default useClockContextMenu;