removed navigate function from components and moved to route wrapper

This commit is contained in:
Muhsin Shah 2024-02-24 17:21:21 +05:30
parent 1d5c37fa66
commit 40a48d00a7
3 changed files with 3 additions and 14 deletions

View file

@ -254,9 +254,9 @@ class AppComponent extends React.Component {
exact
path="/:workspaceId/workspace-settings"
element={
<PrivateRoute>
<AdminRoute {...this.props}>
<OrganizationSettings switchDarkMode={this.switchDarkMode} darkMode={darkMode} />
</PrivateRoute>
</AdminRoute>
}
/>
<Route
@ -294,7 +294,7 @@ class AppComponent extends React.Component {
exact
path="/integrations"
element={
<AdminRoute>
<AdminRoute {...this.props}>
<MarketplacePage switchDarkMode={this.switchDarkMode} darkMode={darkMode} />
</AdminRoute>
}

View file

@ -4,7 +4,6 @@ import { InstalledPlugins } from './InstalledPlugins';
import { MarketplacePlugins } from './MarketplacePlugins';
import { marketplaceService, pluginsService, authenticationService } from '@/_services';
import { toast } from 'react-hot-toast';
import { useNavigate } from 'react-router-dom';
import config from 'config';
import { BreadCrumbContext } from '@/App/App';
import FolderList from '@/_ui/FolderList/FolderList';
@ -19,14 +18,8 @@ const MarketplacePage = ({ darkMode, switchDarkMode }) => {
const { admin } = authenticationService.currentSessionValue;
const ENABLE_MARKETPLACE_DEV_MODE = config.ENABLE_MARKETPLACE_DEV_MODE == 'true';
const navigate = useNavigate();
React.useEffect(() => {
updateSidebarNAV('');
if (!admin) {
navigate('/');
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [admin]);

View file

@ -35,10 +35,6 @@ export function OrganizationSettings(props) {
}
};
if (!admin) {
navigate('/');
}
useEffect(() => {
const subscription = authenticationService.currentSession.subscribe((newOrd) => {
setAdmin(newOrd?.admin);