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,10 +1,23 @@
import type { ReactNode } from "react";
import { keysStore } from "./store";
import type { KeyName } from "./types";
const KEY_MAP: { [k: string]: KeyName } = {
Escape: "escape",
ArrowUp: "up",
ArrowDown: "down",
ArrowLeft: "left",
ArrowRight: "right",
};
if (typeof window !== "undefined") {
window.addEventListener("keydown", (e) => {
const fn = keysStore.getHandler(e.key);
fn?.();
const key = Object.hasOwn(KEY_MAP, e.key) ? KEY_MAP[e.key]! : e.key;
const fn = keysStore.getHandler(key);
// console.log(e.key);
if (!fn) return;
e.preventDefault();
fn();
});
}