perf: add enabled flag to TPA query hook to skip unnecessary fetches

In ProgressiveProfiling, the TPA query fired even when
registrationEmbedded was false and the result was ignored. Added an
enabled option to useThirdPartyAuthHook and set it to
registrationEmbedded in ProgressiveProfiling.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Adolfo R. Brandes
2026-03-06 19:31:28 -03:00
committed by Adolfo R. Brandes
parent 8dcf55254e
commit 86b4ea79de
2 changed files with 3 additions and 2 deletions

View File

@@ -6,11 +6,12 @@ import { ThirdPartyAuthQueryKeys } from './queryKeys';
// Error constants
export const THIRD_PARTY_AUTH_ERROR = 'third-party-auth-error';
const useThirdPartyAuthHook = (pageId, payload) => useQuery({
const useThirdPartyAuthHook = (pageId, payload, { enabled = true } = {}) => useQuery({
queryKey: ThirdPartyAuthQueryKeys.byPage(pageId, payload),
queryFn: () => getThirdPartyAuthContext(payload),
retry: false,
staleTime: 5 * 60 * 1000, // 5 minutes — TPA context is effectively static per session
enabled,
});
export {

View File

@@ -77,7 +77,7 @@ const ProgressiveProfilingInner = () => {
const [showModal, setShowModal] = useState(false);
const { data, isSuccess, error } = useThirdPartyAuthHook(AUTHN_PROGRESSIVE_PROFILING,
{ is_welcome_page: true, next: queryParams?.next });
{ is_welcome_page: true, next: queryParams?.next }, { enabled: registrationEmbedded });
useEffect(() => {
if (registrationEmbedded) {