mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-04-29 12:10:24 +00:00
30 lines
1,003 B
JavaScript
30 lines
1,003 B
JavaScript
// src/lib/hooks.tsx
|
|
import { useContext } from "react";
|
|
import { StackContext } from "../providers/stack-provider-client";
|
|
function useUser(options = {}) {
|
|
const stackApp = useStackApp(options);
|
|
if (options.projectIdMustMatch && stackApp.projectId !== options.projectIdMustMatch) {
|
|
throw new Error("Unexpected project ID in useStackApp: " + stackApp.projectId);
|
|
}
|
|
if (options.projectIdMustMatch === "internal") {
|
|
return stackApp.useUser(options);
|
|
} else {
|
|
return stackApp.useUser(options);
|
|
}
|
|
}
|
|
function useStackApp(options = {}) {
|
|
const context = useContext(StackContext);
|
|
if (context === null) {
|
|
throw new Error("useStackApp must be used within a StackProvider");
|
|
}
|
|
const stackApp = context.app;
|
|
if (options.projectIdMustMatch && stackApp.projectId !== options.projectIdMustMatch) {
|
|
throw new Error("Unexpected project ID in useStackApp: " + stackApp.projectId);
|
|
}
|
|
return stackApp;
|
|
}
|
|
export {
|
|
useStackApp,
|
|
useUser
|
|
};
|
|
//# sourceMappingURL=hooks.js.map
|