Remove onboarding flashes + close all dropdowns on CommandMenu close (#11483)
## Remove onboarding flashes Tested: - sign in with credentials - sign in with social oAuth - sign up with credentials - multidomain - single domain - reset password No more flashes, and code logic simplified! ## Close all dropdowns on CommandMenu close Before: https://github.com/user-attachments/assets/244ff935-3d40-47d5-a097-12d4cc3810dd After: https://github.com/user-attachments/assets/1de692f8-5032-404a-be74-025ebca67138 --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@@ -1,40 +1,28 @@
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { useIsLogged } from '@/auth/hooks/useIsLogged';
|
||||
import { useOnboardingStatus } from '@/onboarding/hooks/useOnboardingStatus';
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { OnboardingStatus } from '~/generated/graphql';
|
||||
import { useIsMatchingLocation } from '~/hooks/useIsMatchingLocation';
|
||||
|
||||
export const useShowAuthModal = () => {
|
||||
const { isMatchingLocation } = useIsMatchingLocation();
|
||||
const isLoggedIn = useIsLogged();
|
||||
const onboardingStatus = useOnboardingStatus();
|
||||
|
||||
return useMemo(() => {
|
||||
if (
|
||||
isMatchingLocation(AppPath.Invite) ||
|
||||
isMatchingLocation(AppPath.InviteTeam) ||
|
||||
isMatchingLocation(AppPath.CreateProfile) ||
|
||||
isMatchingLocation(AppPath.SyncEmails) ||
|
||||
isMatchingLocation(AppPath.ResetPassword) ||
|
||||
isMatchingLocation(AppPath.VerifyEmail) ||
|
||||
isMatchingLocation(AppPath.Verify) ||
|
||||
isMatchingLocation(AppPath.SignInUp) ||
|
||||
isMatchingLocation(AppPath.CreateWorkspace) ||
|
||||
isMatchingLocation(AppPath.PlanRequired)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
!isLoggedIn ||
|
||||
onboardingStatus === OnboardingStatus.PLAN_REQUIRED ||
|
||||
onboardingStatus === OnboardingStatus.PROFILE_CREATION ||
|
||||
onboardingStatus === OnboardingStatus.WORKSPACE_ACTIVATION ||
|
||||
onboardingStatus === OnboardingStatus.SYNC_EMAIL ||
|
||||
onboardingStatus === OnboardingStatus.INVITE_TEAM
|
||||
isMatchingLocation(AppPath.PlanRequired) ||
|
||||
isMatchingLocation(AppPath.PlanRequiredSuccess)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}, [isLoggedIn, isMatchingLocation, onboardingStatus]);
|
||||
}, [isMatchingLocation]);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user