feat: budget crud actions

This commit is contained in:
Max Koon
2025-12-06 23:02:28 -05:00
parent 76f2a43bd0
commit 27f6e627d4
20 changed files with 445 additions and 113 deletions

View File

@@ -1,14 +1,18 @@
import { useEffect, useRef } from "react";
import { keysStore } from "./store";
import type { Key } from "./types";
import { enforceKeyOptions } from "./util";
export const useShortcut = (key: string, handler: () => void) => {
export const useShortcut = (key: Key, handler: () => void) => {
const keyOptions = enforceKeyOptions(key);
const keyName = keyOptions.name;
const ref = useRef(handler);
ref.current = handler;
useEffect(() => {
keysStore.register(key, ref);
keysStore.register(keyName, ref);
return () => {
keysStore.deregister(key);
keysStore.deregister(keyName);
};
}, []);
};