mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
fix: hotbug in dashboard lazy loading resources.
This commit is contained in:
@@ -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>
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
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 EnsureOrganizationIsReady({
|
||||
// #ownProps
|
||||
children,
|
||||
redirectTo = '/setup',
|
||||
|
||||
// #withOrganizationByOrgId
|
||||
isOrganizationInitialized,
|
||||
}) {
|
||||
return (isOrganizationInitialized) ? children : (
|
||||
<Redirect
|
||||
to={{ pathname: redirectTo }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withAuthentication(),
|
||||
connect((state, props) => ({
|
||||
organizationId: props.currentOrganizationId,
|
||||
})),
|
||||
withOrganization(({ isOrganizationInitialized }) => ({ isOrganizationInitialized })),
|
||||
)(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>
|
||||
|
||||
Reference in New Issue
Block a user