From 420915e1082a90ee6ee19a8d3f2de6a025c7a920 Mon Sep 17 00:00:00 2001 From: vikrantgupta25 Date: Thu, 19 Dec 2024 19:38:43 +0530 Subject: [PATCH] fix: do not let users workaround workspace blocked screen --- frontend/src/AppRoutes/Private.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/frontend/src/AppRoutes/Private.tsx b/frontend/src/AppRoutes/Private.tsx index b46456150b7..77bacc67284 100644 --- a/frontend/src/AppRoutes/Private.tsx +++ b/frontend/src/AppRoutes/Private.tsx @@ -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 => { @@ -100,6 +100,7 @@ function PrivateRoute({ children }: PrivateRouteProps): JSX.Element { isFetchingOrgUsers, orgPreferences, orgUsers, + pathname, ]); const navigateToWorkSpaceBlocked = (route: any): void => { @@ -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; @@ -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) {