5509 remove flash on intermediate verify step when sign in with sso (#5526)
- remove flash on /verify - remove flash on signInUp - remove useless redirections and hooks - Remove DefaultHomePage component - Move redirections to /objects/companies in PageChangeEffect - add useShowAuthModal hooks and tests - add usePageChangeEffectNaviteLocation hooks and tests - fix refresh token expired produces blank screen
This commit is contained in:
@ -0,0 +1,96 @@
|
||||
import { useOnboardingStatus } from '@/auth/hooks/useOnboardingStatus';
|
||||
import { OnboardingStatus } from '@/auth/utils/getOnboardingStatus';
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { SettingsPath } from '@/types/SettingsPath';
|
||||
import { useDefaultHomePagePath } from '~/hooks/useDefaultHomePagePath';
|
||||
import { useIsMatchingLocation } from '~/hooks/useIsMatchingLocation';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
export const usePageChangeEffectNavigateLocation = () => {
|
||||
const isMatchingLocation = useIsMatchingLocation();
|
||||
const onboardingStatus = useOnboardingStatus();
|
||||
const { defaultHomePagePath } = useDefaultHomePagePath();
|
||||
|
||||
const isMatchingOpenRoute =
|
||||
isMatchingLocation(AppPath.Invite) ||
|
||||
isMatchingLocation(AppPath.ResetPassword);
|
||||
|
||||
const isMatchingOngoingUserCreationRoute =
|
||||
isMatchingOpenRoute ||
|
||||
isMatchingLocation(AppPath.SignInUp) ||
|
||||
isMatchingLocation(AppPath.Verify);
|
||||
|
||||
const isMatchingOnboardingRoute =
|
||||
isMatchingOngoingUserCreationRoute ||
|
||||
isMatchingLocation(AppPath.CreateWorkspace) ||
|
||||
isMatchingLocation(AppPath.CreateProfile) ||
|
||||
isMatchingLocation(AppPath.PlanRequired) ||
|
||||
isMatchingLocation(AppPath.PlanRequiredSuccess);
|
||||
|
||||
if (
|
||||
onboardingStatus === OnboardingStatus.OngoingUserCreation &&
|
||||
!isMatchingOngoingUserCreationRoute
|
||||
) {
|
||||
return AppPath.SignInUp;
|
||||
}
|
||||
|
||||
if (
|
||||
onboardingStatus === OnboardingStatus.Incomplete &&
|
||||
!isMatchingLocation(AppPath.PlanRequired)
|
||||
) {
|
||||
return AppPath.PlanRequired;
|
||||
}
|
||||
|
||||
if (
|
||||
isDefined(onboardingStatus) &&
|
||||
[OnboardingStatus.Unpaid, OnboardingStatus.Canceled].includes(
|
||||
onboardingStatus,
|
||||
) &&
|
||||
!(
|
||||
isMatchingLocation(AppPath.SettingsCatchAll) ||
|
||||
isMatchingLocation(AppPath.PlanRequired)
|
||||
)
|
||||
) {
|
||||
return `${AppPath.SettingsCatchAll.replace('/*', '')}/${
|
||||
SettingsPath.Billing
|
||||
}`;
|
||||
}
|
||||
|
||||
if (
|
||||
onboardingStatus === OnboardingStatus.OngoingWorkspaceActivation &&
|
||||
!isMatchingLocation(AppPath.CreateWorkspace) &&
|
||||
!isMatchingLocation(AppPath.PlanRequiredSuccess)
|
||||
) {
|
||||
return AppPath.CreateWorkspace;
|
||||
}
|
||||
|
||||
if (
|
||||
onboardingStatus === OnboardingStatus.OngoingProfileCreation &&
|
||||
!isMatchingLocation(AppPath.CreateProfile)
|
||||
) {
|
||||
return AppPath.CreateProfile;
|
||||
}
|
||||
|
||||
if (
|
||||
onboardingStatus === OnboardingStatus.Completed &&
|
||||
isMatchingOnboardingRoute &&
|
||||
!isMatchingOpenRoute
|
||||
) {
|
||||
return defaultHomePagePath;
|
||||
}
|
||||
|
||||
if (
|
||||
onboardingStatus === OnboardingStatus.CompletedWithoutSubscription &&
|
||||
isMatchingOnboardingRoute &&
|
||||
!isMatchingOpenRoute &&
|
||||
!isMatchingLocation(AppPath.PlanRequired)
|
||||
) {
|
||||
return defaultHomePagePath;
|
||||
}
|
||||
|
||||
if (isMatchingLocation(AppPath.Index)) {
|
||||
return defaultHomePagePath;
|
||||
}
|
||||
|
||||
return;
|
||||
};
|
||||
Reference in New Issue
Block a user