refactor: move hooks and stores from packages/features to apps/web/modules (#27221)
* refactor: move booking-audit client components from packages/features to apps/web/modules This is part of the larger effort to move tRPC-dependent UI components from packages/features to apps/web/modules to eliminate circular dependencies. Changes: - Move BookingHistory.tsx and BookingHistoryPage.tsx to apps/web/modules/booking-audit/components/ - Update imports in apps/web to use the new location Co-Authored-By: [email protected] <[email protected]> * refactor: move formbricks client from packages/features to apps/web/modules Co-Authored-By: [email protected] <[email protected]> * refactor: move hooks and stores from packages/features to apps/web/modules - Move useAppsData hook from packages/features/apps/hooks to apps/web/modules/apps/hooks - Move onboardingStore from packages/features/ee/organizations/lib to apps/web/modules/ee/organizations/lib - Move useWelcomeModal hook from packages/features/ee/organizations/hooks to apps/web/modules/ee/organizations/hooks - Move useAgentsData hook from packages/features/ee/workflows/hooks to apps/web/modules/ee/workflows/hooks - Update all import paths in consuming files Co-Authored-By: [email protected] <[email protected]> * refactor: move onboardingStore test file to apps/web/modules Co-Authored-By: [email protected] <[email protected]> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
d93306e32c
commit
0774a41119
30 files changed
+31
-29
No files matched your search
@@ -0,0 +1,50 @@
|
||||
import formbricks from "@formbricks/js/app";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useEffect } from "react";
|
||||
|
||||
import useMeQuery from "@calcom/trpc/react/hooks/useMeQuery";
|
||||
|
||||
const initFormbricks = ({
|
||||
userId,
|
||||
attributes,
|
||||
}: {
|
||||
userId: string;
|
||||
attributes: { [key: string]: string | null | undefined };
|
||||
}) => {
|
||||
const filteredAttributes: Record<string, string | number> = {};
|
||||
Object.entries(attributes).forEach(([key, value]) => {
|
||||
if (value !== null && value !== undefined) {
|
||||
filteredAttributes[key] = value;
|
||||
}
|
||||
});
|
||||
|
||||
if (process.env.NEXT_PUBLIC_FORMBRICKS_HOST_URL && process.env.NEXT_PUBLIC_FORMBRICKS_ENVIRONMENT_ID) {
|
||||
formbricks.init({
|
||||
environmentId: process.env.NEXT_PUBLIC_FORMBRICKS_ENVIRONMENT_ID,
|
||||
apiHost: process.env.NEXT_PUBLIC_FORMBRICKS_HOST_URL,
|
||||
debug: process.env.NODE_ENV === "development",
|
||||
userId,
|
||||
attributes: filteredAttributes,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const useFormbricks = () => {
|
||||
const { data: user, isLoading } = useMeQuery();
|
||||
const { data: session, status } = useSession();
|
||||
|
||||
useEffect(() => {
|
||||
if (!isLoading && user && session) {
|
||||
initFormbricks({
|
||||
userId: user.id.toString(),
|
||||
attributes: {
|
||||
name: user?.name,
|
||||
email: user.email,
|
||||
username: user?.username,
|
||||
belongsToActiveTeam: session.user.belongsToActiveTeam?.toString(),
|
||||
isOrganizationAdmin: user.organization?.isOrgAdmin?.toString(),
|
||||
},
|
||||
});
|
||||
}
|
||||
}, [isLoading, user, status, session]);
|
||||
};
|
||||
Reference in new issue
Block a user