mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
fix: hotbug in dashboard lazy loading resources.
This commit is contained in:
@@ -5,7 +5,7 @@ import { createBrowserHistory } from 'history';
|
||||
import { ReactQueryConfigProvider } from 'react-query';
|
||||
import { ReactQueryDevtools } from 'react-query-devtools';
|
||||
|
||||
import PrivateRoute from 'components/PrivateRoute';
|
||||
import PrivateRoute from 'components/Guards/PrivateRoute';
|
||||
import Authentication from 'components/Authentication';
|
||||
import DashboardPrivatePages from 'components/Dashboard/PrivatePages';
|
||||
import GlobalErrors from 'containers/GlobalErrors/GlobalErrors';
|
||||
|
||||
@@ -7,15 +7,10 @@ import { FormattedMessage as T } from 'react-intl';
|
||||
import withAuthentication from 'containers/Authentication/withAuthentication';
|
||||
import { compose } from 'utils';
|
||||
import Icon from 'components/Icon';
|
||||
import AuthCopyright from 'containers/Authentication/AuthCopyright';
|
||||
|
||||
function PageFade(props) {
|
||||
return (
|
||||
<CSSTransition
|
||||
{...props}
|
||||
classNames="authTransition"
|
||||
timeout={500}
|
||||
/>
|
||||
<CSSTransition {...props} classNames="authTransition" timeout={500} />
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import PreferencesContent from 'components/Preferences/PreferencesContent';
|
||||
import PreferencesSidebar from 'components/Preferences/PreferencesSidebar';
|
||||
import Search from 'containers/GeneralSearch/Search';
|
||||
import DashboardSplitPane from 'components/Dashboard/DashboardSplitePane';
|
||||
import EnsureOrganizationIsReady from './EnsureOrganizationIsReady';
|
||||
|
||||
|
||||
import withSettingsActions from 'containers/Settings/withSettingsActions';
|
||||
|
||||
@@ -27,7 +27,7 @@ function Dashboard({
|
||||
);
|
||||
|
||||
return (
|
||||
<EnsureOrganizationIsReady>
|
||||
|
||||
<DashboardLoadingIndicator isLoading={fetchOptions.isFetching}>
|
||||
<Switch>
|
||||
<Route path="/preferences">
|
||||
@@ -49,7 +49,7 @@ function Dashboard({
|
||||
<Search />
|
||||
<DialogsContainer />
|
||||
</DashboardLoadingIndicator>
|
||||
</EnsureOrganizationIsReady>
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ import DashboardLoadingIndicator from 'components/Dashboard/DashboardLoadingIndi
|
||||
import withOrganizationActions from 'containers/Organization/withOrganizationActions';
|
||||
import withSubscriptionsActions from 'containers/Subscriptions/withSubscriptionsActions';
|
||||
|
||||
import EnsureOrganizationIsReady from 'components/Guards/EnsureOrganizationIsReady';
|
||||
import EnsureOrganizationIsNotReady from 'components/Guards/EnsureOrganizationIsNotReady';
|
||||
import { compose } from 'utils';
|
||||
|
||||
/**
|
||||
@@ -40,11 +42,15 @@ function DashboardPrivatePages({
|
||||
}>
|
||||
<Switch>
|
||||
<Route path={'/setup'}>
|
||||
<SetupWizardPage />
|
||||
<EnsureOrganizationIsNotReady>
|
||||
<SetupWizardPage />
|
||||
</EnsureOrganizationIsNotReady>
|
||||
</Route>
|
||||
|
||||
<Route path='/'>
|
||||
<Dashboard />
|
||||
<EnsureOrganizationIsReady>
|
||||
<Dashboard />
|
||||
</EnsureOrganizationIsReady>
|
||||
</Route>
|
||||
</Switch>
|
||||
</DashboardLoadingIndicator>
|
||||
|
||||
34
client/src/components/Guards/EnsureOrganizationIsNotReady.js
Normal file
34
client/src/components/Guards/EnsureOrganizationIsNotReady.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { Redirect } from 'react-router-dom';
|
||||
import { compose } from 'utils';
|
||||
import withAuthentication from 'containers/Authentication/withAuthentication';
|
||||
import withOrganization from 'containers/Organization/withOrganization';
|
||||
|
||||
function EnsureOrganizationIsNotReady({
|
||||
children,
|
||||
|
||||
// #withOrganization
|
||||
isOrganizationReady,
|
||||
isOrganizationSetupCompleted
|
||||
}) {
|
||||
return (isOrganizationReady && !isOrganizationSetupCompleted) ? (
|
||||
<Redirect to={{ pathname: '/' }} />
|
||||
) : children;
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withAuthentication(({ currentOrganizationId }) => ({
|
||||
currentOrganizationId,
|
||||
})),
|
||||
connect((state, props) => ({
|
||||
organizationId: props.currentOrganizationId,
|
||||
})),
|
||||
withOrganization(({
|
||||
isOrganizationReady,
|
||||
isOrganizationSetupCompleted
|
||||
}) => ({
|
||||
isOrganizationReady,
|
||||
isOrganizationSetupCompleted
|
||||
})),
|
||||
)(EnsureOrganizationIsNotReady);
|
||||
Reference in New Issue
Block a user