* 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: benny@cal.com <sldisek783@gmail.com> * refactor: move formbricks client from packages/features to apps/web/modules Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * 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: benny@cal.com <sldisek783@gmail.com> * refactor: move onboardingStore test file to apps/web/modules Co-Authored-By: benny@cal.com <sldisek783@gmail.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import { parseAsBoolean, useQueryState } from "nuqs";
|
|
import { useEffect, useState } from "react";
|
|
|
|
const STORAGE_KEY = "showNewOrgModal";
|
|
|
|
export function useWelcomeModal() {
|
|
const [newOrganizationModal, setNewOrganizationModal] = useQueryState(
|
|
"newOrganizationModal",
|
|
parseAsBoolean.withDefault(false)
|
|
);
|
|
|
|
const [isOpen, setIsOpen] = useState(false);
|
|
|
|
useEffect(() => {
|
|
// Check query param first
|
|
if (newOrganizationModal) {
|
|
setIsOpen(true);
|
|
return;
|
|
}
|
|
|
|
// Check sessionStorage as fallback (for cases where we redirect through personal onboarding)
|
|
if (typeof window !== "undefined" && sessionStorage.getItem(STORAGE_KEY) === "true") {
|
|
setIsOpen(true);
|
|
}
|
|
}, [newOrganizationModal]);
|
|
|
|
const closeModal = () => {
|
|
setIsOpen(false);
|
|
// Remove the query param from URL
|
|
setNewOrganizationModal(null);
|
|
// Also clear sessionStorage
|
|
if (typeof window !== "undefined") {
|
|
sessionStorage.removeItem(STORAGE_KEY);
|
|
}
|
|
};
|
|
|
|
return {
|
|
isOpen,
|
|
closeModal,
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Helper function to set the flag that triggers the welcome modal.
|
|
* Use this before redirecting to ensure the modal shows after navigation.
|
|
*/
|
|
export function setShowNewOrgModalFlag() {
|
|
if (typeof window !== "undefined") {
|
|
sessionStorage.setItem(STORAGE_KEY, "true");
|
|
}
|
|
}
|