mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
feat: ensure to access dashboard user's subscription is active.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import React from 'react';
|
||||
import { includes } from 'lodash';
|
||||
|
||||
import { compose } from 'utils';
|
||||
import { Redirect } from 'react-router-dom';
|
||||
import withSubscriptions from '../../containers/Subscriptions/withSubscriptionss';
|
||||
|
||||
/**
|
||||
* Ensures the given subscription type is active or redirect to the given route.
|
||||
*/
|
||||
function EnsureSubscriptionsIsInactive({
|
||||
children,
|
||||
subscriptionType = 'main',
|
||||
redirectTo = '/billing',
|
||||
routePath,
|
||||
exclude,
|
||||
isSubscriptionsInactive,
|
||||
}) {
|
||||
return !isSubscriptionsInactive || includes(exclude, routePath) ? (
|
||||
children
|
||||
) : (
|
||||
<Redirect to={{ pathname: redirectTo }} />
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withSubscriptions(
|
||||
({ isSubscriptionsInactive }) => ({ isSubscriptionsInactive }),
|
||||
'main',
|
||||
),
|
||||
)(EnsureSubscriptionsIsInactive);
|
||||
Reference in New Issue
Block a user