Skip to content

Commit

Permalink
fix: show org onboarding only to cloud customers (#6451)
Browse files Browse the repository at this point in the history
  • Loading branch information
YounixM authored Nov 15, 2024
1 parent 504bc0d commit 371224a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion frontend/src/AppRoutes/Private.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import AppActions from 'types/actions';
import { UPDATE_USER_IS_FETCH } from 'types/actions/app';
import { Organization } from 'types/api/user/getOrganization';
import AppReducer from 'types/reducer/app';
import { isCloudUser } from 'utils/app';
import { routePermission } from 'utils/permission';

import routes, {
Expand Down Expand Up @@ -76,6 +77,8 @@ function PrivateRoute({ children }: PrivateRouteProps): JSX.Element {

const { t } = useTranslation(['common']);

const isCloudUserVal = isCloudUser();

const localStorageUserAuthToken = getInitialUserTokenRefreshToken();

const dispatch = useDispatch<Dispatch<AppActions>>();
Expand Down Expand Up @@ -143,6 +146,7 @@ function PrivateRoute({ children }: PrivateRouteProps): JSX.Element {
const handleRedirectForOrgOnboarding = (key: string): void => {
if (
isLoggedInState &&
isCloudUserVal &&
!isFetchingOrgPreferences &&
!isLoadingOrgUsers &&
!isEmpty(orgUsers?.payload) &&
Expand All @@ -158,6 +162,10 @@ function PrivateRoute({ children }: PrivateRouteProps): JSX.Element {
history.push(ROUTES.ONBOARDING);
}
}

if (!isCloudUserVal && key === 'ONBOARDING') {
history.push(ROUTES.APPLICATION);
}
};

const handleUserLoginIfTokenPresent = async (
Expand Down Expand Up @@ -250,7 +258,7 @@ function PrivateRoute({ children }: PrivateRouteProps): JSX.Element {
const handleRouting = (): void => {
const showOrgOnboarding = shouldShowOnboarding();

if (showOrgOnboarding && !isOnboardingComplete) {
if (showOrgOnboarding && !isOnboardingComplete && isCloudUserVal) {
history.push(ROUTES.ONBOARDING);
} else {
history.push(ROUTES.APPLICATION);
Expand Down

0 comments on commit 371224a

Please sign in to comment.