mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
Add a flag for stripe integration (#3181)
This commit is contained in:
parent
6bc1601507
commit
8b95eab7af
@ -9,12 +9,12 @@ import {
|
|||||||
InstanceState,
|
InstanceState,
|
||||||
InstancePlan,
|
InstancePlan,
|
||||||
} from 'interfaces/instance';
|
} from 'interfaces/instance';
|
||||||
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||||
import { trialHasExpired, isTrialInstance } from 'utils/instanceTrial';
|
import { trialHasExpired, isTrialInstance } from 'utils/instanceTrial';
|
||||||
import { GridRow } from 'component/common/GridRow/GridRow';
|
import { GridRow } from 'component/common/GridRow/GridRow';
|
||||||
import { GridCol } from 'component/common/GridCol/GridCol';
|
import { GridCol } from 'component/common/GridCol/GridCol';
|
||||||
import { GridColLink } from './GridColLink/GridColLink';
|
|
||||||
import { STRIPE } from 'component/admin/billing/flags';
|
|
||||||
import { Badge } from 'component/common/Badge/Badge';
|
import { Badge } from 'component/common/Badge/Badge';
|
||||||
|
import { GridColLink } from './GridColLink/GridColLink';
|
||||||
|
|
||||||
const StyledPlanBox = styled('aside')(({ theme }) => ({
|
const StyledPlanBox = styled('aside')(({ theme }) => ({
|
||||||
padding: theme.spacing(2.5),
|
padding: theme.spacing(2.5),
|
||||||
@ -74,6 +74,7 @@ interface IBillingPlanProps {
|
|||||||
export const BillingPlan: FC<IBillingPlanProps> = ({ instanceStatus }) => {
|
export const BillingPlan: FC<IBillingPlanProps> = ({ instanceStatus }) => {
|
||||||
const { users } = useUsers();
|
const { users } = useUsers();
|
||||||
const expired = trialHasExpired(instanceStatus);
|
const expired = trialHasExpired(instanceStatus);
|
||||||
|
const { uiConfig } = useUiConfig();
|
||||||
|
|
||||||
const price = {
|
const price = {
|
||||||
[InstancePlan.PRO]: 80,
|
[InstancePlan.PRO]: 80,
|
||||||
@ -147,9 +148,10 @@ export const BillingPlan: FC<IBillingPlanProps> = ({ instanceStatus }) => {
|
|||||||
</GridRow>
|
</GridRow>
|
||||||
</Grid>
|
</Grid>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={
|
condition={Boolean(
|
||||||
STRIPE && instanceStatus.plan === InstancePlan.PRO
|
uiConfig?.flags?.proPlanAutoCharge &&
|
||||||
}
|
instanceStatus.plan === InstancePlan.PRO
|
||||||
|
)}
|
||||||
show={
|
show={
|
||||||
<>
|
<>
|
||||||
<Grid container>
|
<Grid container>
|
||||||
|
@ -1 +0,0 @@
|
|||||||
export const STRIPE = false;
|
|
@ -1,8 +1,8 @@
|
|||||||
import { IUser } from 'interfaces/user';
|
import { IUser } from 'interfaces/user';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useInstanceStatus } from './api/getters/useInstanceStatus/useInstanceStatus';
|
import { useInstanceStatus } from './api/getters/useInstanceStatus/useInstanceStatus';
|
||||||
import { STRIPE } from 'component/admin/billing/flags';
|
|
||||||
import { InstancePlan } from 'interfaces/instance';
|
import { InstancePlan } from 'interfaces/instance';
|
||||||
|
import useUiConfig from './api/getters/useUiConfig/useUiConfig';
|
||||||
|
|
||||||
export interface IUsersPlanOutput {
|
export interface IUsersPlanOutput {
|
||||||
planUsers: IUser[];
|
planUsers: IUser[];
|
||||||
@ -11,8 +11,12 @@ export interface IUsersPlanOutput {
|
|||||||
|
|
||||||
export const useUsersPlan = (users: IUser[]): IUsersPlanOutput => {
|
export const useUsersPlan = (users: IUser[]): IUsersPlanOutput => {
|
||||||
const { instanceStatus } = useInstanceStatus();
|
const { instanceStatus } = useInstanceStatus();
|
||||||
|
const { uiConfig } = useUiConfig();
|
||||||
|
|
||||||
const isBillingUsers = STRIPE && instanceStatus?.plan === InstancePlan.PRO;
|
const isBillingUsers = Boolean(
|
||||||
|
uiConfig?.flags?.proPlanAutoCharge &&
|
||||||
|
instanceStatus?.plan === InstancePlan.PRO
|
||||||
|
);
|
||||||
const seats = instanceStatus?.seats ?? 5;
|
const seats = instanceStatus?.seats ?? 5;
|
||||||
|
|
||||||
const planUsers = useMemo(
|
const planUsers = useMemo(
|
||||||
|
@ -47,6 +47,7 @@ export interface IFlags {
|
|||||||
caseInsensitiveInOperators?: boolean;
|
caseInsensitiveInOperators?: boolean;
|
||||||
crOnVariants?: boolean;
|
crOnVariants?: boolean;
|
||||||
showProjectApiAccess?: boolean;
|
showProjectApiAccess?: boolean;
|
||||||
|
proPlanAutoCharge?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IVersionInfo {
|
export interface IVersionInfo {
|
||||||
|
@ -79,6 +79,7 @@ exports[`should create default config 1`] = `
|
|||||||
"messageBanner": false,
|
"messageBanner": false,
|
||||||
"newProjectOverview": false,
|
"newProjectOverview": false,
|
||||||
"notifications": false,
|
"notifications": false,
|
||||||
|
"proPlanAutoCharge": false,
|
||||||
"projectStatusApi": false,
|
"projectStatusApi": false,
|
||||||
"proxyReturnAllToggles": false,
|
"proxyReturnAllToggles": false,
|
||||||
"responseTimeWithAppNameKillSwitch": false,
|
"responseTimeWithAppNameKillSwitch": false,
|
||||||
@ -100,6 +101,7 @@ exports[`should create default config 1`] = `
|
|||||||
"messageBanner": false,
|
"messageBanner": false,
|
||||||
"newProjectOverview": false,
|
"newProjectOverview": false,
|
||||||
"notifications": false,
|
"notifications": false,
|
||||||
|
"proPlanAutoCharge": false,
|
||||||
"projectStatusApi": false,
|
"projectStatusApi": false,
|
||||||
"proxyReturnAllToggles": false,
|
"proxyReturnAllToggles": false,
|
||||||
"responseTimeWithAppNameKillSwitch": false,
|
"responseTimeWithAppNameKillSwitch": false,
|
||||||
|
@ -62,6 +62,10 @@ const flags = {
|
|||||||
process.env.UNLEASH_STRICT_SCHEMA_VALIDTION,
|
process.env.UNLEASH_STRICT_SCHEMA_VALIDTION,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
|
proPlanAutoCharge: parseEnvVarBoolean(
|
||||||
|
process.env.UNLEASH_PRO_PLAN_AUTO_CHARGE,
|
||||||
|
false,
|
||||||
|
),
|
||||||
notifications: parseEnvVarBoolean(process.env.NOTIFICATIONS, false),
|
notifications: parseEnvVarBoolean(process.env.NOTIFICATIONS, false),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user