mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
31 lines
798 B
JavaScript
31 lines
798 B
JavaScript
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
|
|
isOrganizationBuilt,
|
|
}) {
|
|
return (isOrganizationBuilt) ? children : (
|
|
<Redirect
|
|
to={{ pathname: redirectTo }}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export default compose(
|
|
withAuthentication(),
|
|
connect((state, props) => ({
|
|
organizationId: props.currentOrganizationId,
|
|
})),
|
|
withOrganization(({ isOrganizationBuilt }) => ({ isOrganizationBuilt })),
|
|
)(EnsureOrganizationIsReady); |