mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
chrone: sperate client and server to different repos.
This commit is contained in:
31
src/components/Guards/EnsureSubscriptionIsActive.js
Normal file
31
src/components/Guards/EnsureSubscriptionIsActive.js
Normal file
@@ -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/withSubscriptions';
|
||||
|
||||
/**
|
||||
* Ensures the given subscription type is active or redirect to the given route.
|
||||
*/
|
||||
function EnsureSubscriptionIsActive({
|
||||
children,
|
||||
subscriptionType = 'main',
|
||||
redirectTo = '/billing',
|
||||
routePath,
|
||||
exclude,
|
||||
isSubscriptionActive,
|
||||
}) {
|
||||
return isSubscriptionActive || includes(exclude, routePath) ? (
|
||||
children
|
||||
) : (
|
||||
<Redirect to={{ pathname: redirectTo }} />
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withSubscriptions(
|
||||
({ isSubscriptionActive }) => ({ isSubscriptionActive }),
|
||||
'main',
|
||||
),
|
||||
)(EnsureSubscriptionIsActive);
|
||||
Reference in New Issue
Block a user