mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-08 17:59:04 +08:00
fix: show upgrade plan option in grace period if not converted to trial (#6909)
This commit is contained in:
parent
42a5d71d81
commit
ea83a7e62d
@ -51,14 +51,12 @@ describe('BillingContainer', () => {
|
|||||||
expect(cost).toBeInTheDocument();
|
expect(cost).toBeInTheDocument();
|
||||||
|
|
||||||
const dayRemainingInBillingPeriod = await screen.findByText(
|
const dayRemainingInBillingPeriod = await screen.findByText(
|
||||||
/11 days_remaining/i,
|
/Please upgrade plan now to retain your data./i,
|
||||||
);
|
);
|
||||||
expect(dayRemainingInBillingPeriod).toBeInTheDocument();
|
expect(dayRemainingInBillingPeriod).toBeInTheDocument();
|
||||||
|
|
||||||
const manageBilling = screen.getByRole('button', {
|
const upgradePlanButton = screen.getByTestId('upgrade-plan-button');
|
||||||
name: 'manage_billing',
|
expect(upgradePlanButton).toBeInTheDocument();
|
||||||
});
|
|
||||||
expect(manageBilling).toBeInTheDocument();
|
|
||||||
|
|
||||||
const dollar = screen.getByText(/\$1,278.3/i);
|
const dollar = screen.getByText(/\$1,278.3/i);
|
||||||
await waitFor(() => expect(dollar).toBeInTheDocument());
|
await waitFor(() => expect(dollar).toBeInTheDocument());
|
||||||
|
@ -202,15 +202,16 @@ export default function BillingContainer(): JSX.Element {
|
|||||||
const isSubscriptionPastDue =
|
const isSubscriptionPastDue =
|
||||||
apiResponse.subscriptionStatus === SubscriptionStatus.PastDue;
|
apiResponse.subscriptionStatus === SubscriptionStatus.PastDue;
|
||||||
|
|
||||||
const { isLoading, isFetching: isFetchingBillingData } = useQuery(
|
const {
|
||||||
[REACT_QUERY_KEY.GET_BILLING_USAGE, user?.id],
|
isLoading,
|
||||||
{
|
isFetching: isFetchingBillingData,
|
||||||
|
data: billingData,
|
||||||
|
} = useQuery([REACT_QUERY_KEY.GET_BILLING_USAGE, user?.id], {
|
||||||
queryFn: () => getUsage(activeLicense?.key || ''),
|
queryFn: () => getUsage(activeLicense?.key || ''),
|
||||||
onError: handleError,
|
onError: handleError,
|
||||||
enabled: activeLicense !== null,
|
enabled: activeLicense !== null,
|
||||||
onSuccess: processUsageData,
|
onSuccess: processUsageData,
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const activeValidLicense =
|
const activeValidLicense =
|
||||||
@ -318,7 +319,7 @@ export default function BillingContainer(): JSX.Element {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleBilling = useCallback(async () => {
|
const handleBilling = useCallback(async () => {
|
||||||
if (isFreeTrial && !licenses?.trialConvertedToSubscription) {
|
if (!licenses?.trialConvertedToSubscription) {
|
||||||
logEvent('Billing : Upgrade Plan', {
|
logEvent('Billing : Upgrade Plan', {
|
||||||
user: pick(user, ['email', 'userId', 'name']),
|
user: pick(user, ['email', 'userId', 'name']),
|
||||||
org,
|
org,
|
||||||
@ -411,6 +412,12 @@ export default function BillingContainer(): JSX.Element {
|
|||||||
}
|
}
|
||||||
}, [apiResponse, notifications]);
|
}, [apiResponse, notifications]);
|
||||||
|
|
||||||
|
const showGracePeriodMessage =
|
||||||
|
!isLoading &&
|
||||||
|
!licenses?.trialConvertedToSubscription &&
|
||||||
|
!licenses?.onTrial &&
|
||||||
|
licenses?.gracePeriodEnd;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="billing-container">
|
<div className="billing-container">
|
||||||
<Flex vertical style={{ marginBottom: 16 }}>
|
<Flex vertical style={{ marginBottom: 16 }}>
|
||||||
@ -433,7 +440,8 @@ export default function BillingContainer(): JSX.Element {
|
|||||||
{isCloudUserVal ? t('teams_cloud') : t('teams')}{' '}
|
{isCloudUserVal ? t('teams_cloud') : t('teams')}{' '}
|
||||||
{isFreeTrial ? <Tag color="success"> Free Trial </Tag> : ''}
|
{isFreeTrial ? <Tag color="success"> Free Trial </Tag> : ''}
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
{!isLoading && !isFetchingBillingData ? (
|
|
||||||
|
{!isLoading && !isFetchingBillingData && !showGracePeriodMessage ? (
|
||||||
<Typography.Text style={{ fontSize: 12, color: Color.BG_VANILLA_400 }}>
|
<Typography.Text style={{ fontSize: 12, color: Color.BG_VANILLA_400 }}>
|
||||||
{daysRemaining} {daysRemainingStr}
|
{daysRemaining} {daysRemainingStr}
|
||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
@ -451,15 +459,16 @@ export default function BillingContainer(): JSX.Element {
|
|||||||
Download CSV
|
Download CSV
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
|
data-testid="header-billing-button"
|
||||||
type="primary"
|
type="primary"
|
||||||
size="middle"
|
size="middle"
|
||||||
loading={isLoadingBilling || isLoadingManageBilling}
|
loading={isLoadingBilling || isLoadingManageBilling}
|
||||||
disabled={isLoading}
|
disabled={isLoading}
|
||||||
onClick={handleBilling}
|
onClick={handleBilling}
|
||||||
>
|
>
|
||||||
{isFreeTrial && !licenses?.trialConvertedToSubscription
|
{licenses?.trialConvertedToSubscription
|
||||||
? t('upgrade_plan')
|
? t('manage_billing')
|
||||||
: t('manage_billing')}
|
: t('upgrade_plan')}
|
||||||
</Button>
|
</Button>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
@ -473,8 +482,8 @@ export default function BillingContainer(): JSX.Element {
|
|||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!isLoading && !isFetchingBillingData ? (
|
{!isLoading && !isFetchingBillingData && !showGracePeriodMessage
|
||||||
headerText && (
|
? headerText && (
|
||||||
<Alert
|
<Alert
|
||||||
message={headerText}
|
message={headerText}
|
||||||
type="info"
|
type="info"
|
||||||
@ -482,9 +491,26 @@ export default function BillingContainer(): JSX.Element {
|
|||||||
style={{ marginTop: 12 }}
|
style={{ marginTop: 12 }}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
) : (
|
: null}
|
||||||
|
|
||||||
|
{isLoading || isFetchingBillingData ? (
|
||||||
<Skeleton.Input active style={{ height: 20, marginTop: 20 }} />
|
<Skeleton.Input active style={{ height: 20, marginTop: 20 }} />
|
||||||
)}
|
) : null}
|
||||||
|
|
||||||
|
{!isLoading &&
|
||||||
|
!isFetchingBillingData &&
|
||||||
|
billingData &&
|
||||||
|
licenses?.gracePeriodEnd &&
|
||||||
|
showGracePeriodMessage ? (
|
||||||
|
<Alert
|
||||||
|
message={`Your data is safe with us until ${getFormattedDate(
|
||||||
|
licenses?.gracePeriodEnd || Date.now(),
|
||||||
|
)}. Please upgrade plan now to retain your data.`}
|
||||||
|
type="info"
|
||||||
|
showIcon
|
||||||
|
style={{ marginTop: 12 }}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
|
||||||
{isSubscriptionPastDue &&
|
{isSubscriptionPastDue &&
|
||||||
(!isLoading && !isFetchingBillingData ? (
|
(!isLoading && !isFetchingBillingData ? (
|
||||||
@ -514,7 +540,7 @@ export default function BillingContainer(): JSX.Element {
|
|||||||
{(isLoading || isFetchingBillingData) && renderTableSkeleton()}
|
{(isLoading || isFetchingBillingData) && renderTableSkeleton()}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{isFreeTrial && !licenses?.trialConvertedToSubscription && (
|
{!licenses?.trialConvertedToSubscription && (
|
||||||
<div className="upgrade-plan-benefits">
|
<div className="upgrade-plan-benefits">
|
||||||
<Row
|
<Row
|
||||||
justify="space-between"
|
justify="space-between"
|
||||||
@ -552,6 +578,7 @@ export default function BillingContainer(): JSX.Element {
|
|||||||
</Col>
|
</Col>
|
||||||
<Col span={4} style={{ display: 'flex', justifyContent: 'flex-end' }}>
|
<Col span={4} style={{ display: 'flex', justifyContent: 'flex-end' }}>
|
||||||
<Button
|
<Button
|
||||||
|
data-testid="upgrade-plan-button"
|
||||||
type="primary"
|
type="primary"
|
||||||
size="middle"
|
size="middle"
|
||||||
loading={isLoadingBilling || isLoadingManageBilling}
|
loading={isLoadingBilling || isLoadingManageBilling}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user