refactor: better shortcut hook
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { Transaction } from "@rocicorp/zero";
|
||||
import type { AuthData } from "./auth";
|
||||
import { authDataSchema, type AuthData } from "./auth";
|
||||
import { type Schema } from "./zero-schema.gen";
|
||||
import { isLoggedIn } from "./zql";
|
||||
|
||||
@@ -39,6 +39,17 @@ export function createMutators(authData: AuthData | null) {
|
||||
}
|
||||
},
|
||||
},
|
||||
budget: {
|
||||
async create(tx: Tx, { id }: { id: string }) {
|
||||
isLoggedIn(authData);
|
||||
await tx.mutate.budget.insert({
|
||||
id,
|
||||
orgId: authData.user.id,
|
||||
label: "New Budget",
|
||||
createdBy: authData.user.id,
|
||||
});
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user