feat: initial commit

This commit is contained in:
2026-06-29 23:07:14 +00:00
commit 3b9a6bc85c
152 changed files with 12558 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
import { use, useCallback } from "react";
import { DbContext } from "../contexts/Db.js";
import type { DbInterface } from "../../db/types/DbInterface.js";
import type { Store } from "../store/store.js";
import { useStore } from "../store/react.js";
export function useAction<P extends any[], R>(
action: (...params: [...P, { db: DbInterface; store: Store }]) => Promise<R>
): (...args: P) => Promise<R> {
const db = use(DbContext);
const store = useStore();
return useCallback(
async (...params: P) => {
if (!db) throw new Error("DB not present");
return action(...params, { db, store });
},
[action, db]
);
}