Skip to content

Commit

Permalink
fix: do not let users workaround workspace blocked screen
Browse files Browse the repository at this point in the history
  • Loading branch information
vikrantgupta25 committed Dec 19, 2024
1 parent 24417c8 commit 420915e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions frontend/src/AppRoutes/Private.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function PrivateRoute({ children }: PrivateRouteProps): JSX.Element {
return undefined;
},
queryKey: ['getOrgUser'],
enabled: !isEmpty(orgData),
enabled: !isEmpty(orgData) && user.role === 'ADMIN',
});

const checkFirstTimeUser = useCallback((): boolean => {
Expand Down Expand Up @@ -100,6 +100,7 @@ function PrivateRoute({ children }: PrivateRouteProps): JSX.Element {
isFetchingOrgUsers,
orgPreferences,
orgUsers,
pathname,
]);

const navigateToWorkSpaceBlocked = (route: any): void => {
Expand All @@ -115,11 +116,11 @@ function PrivateRoute({ children }: PrivateRouteProps): JSX.Element {
const currentRoute = mapRoutes.get('current');
const shouldBlockWorkspace = licenses?.workSpaceBlock;

if (shouldBlockWorkspace) {
if (shouldBlockWorkspace && currentRoute) {
navigateToWorkSpaceBlocked(currentRoute);
}
}
}, [isFetchingLicenses, licenses?.workSpaceBlock, mapRoutes]);
}, [isFetchingLicenses, licenses?.workSpaceBlock, mapRoutes, pathname]);

const navigateToWorkSpaceSuspended = (route: any): void => {
const { path } = route;
Expand All @@ -136,11 +137,11 @@ function PrivateRoute({ children }: PrivateRouteProps): JSX.Element {
activeLicenseV3.status === LicenseStatus.SUSPENDED &&
activeLicenseV3.state === LicenseState.PAYMENT_FAILED;

if (shouldSuspendWorkspace) {
if (shouldSuspendWorkspace && currentRoute) {
navigateToWorkSpaceSuspended(currentRoute);
}
}
}, [isFetchingActiveLicenseV3, activeLicenseV3, mapRoutes]);
}, [isFetchingActiveLicenseV3, activeLicenseV3, mapRoutes, pathname]);

useEffect(() => {
if (org && org.length > 0 && org[0].id !== undefined) {
Expand Down

0 comments on commit 420915e

Please sign in to comment.