Skip to content

Commit a5f5b07

Browse files
authored
fix: ensure billing interval is passed when converting old pro (#8449)
1 parent 103603a commit a5f5b07

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

packages/app/src/app/components/WorkspaceSetup/steps/ChangePlan.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import track from '@codesandbox/common/lib/utils/analytics';
33
import { Stack, Button, Text, Icon } from '@codesandbox/components';
44
import * as dashboardUrls from '@codesandbox/common/lib/utils/url-generator/dashboard';
55

6+
import { SubscriptionInterval } from 'app/graphql/types';
67
import { useURLSearchParams } from 'app/hooks/useURLSearchParams';
78
import { useActions, useAppState } from 'app/overmind';
89
import { StepProps } from '../types';
@@ -59,7 +60,11 @@ export const ChangePlan: React.FC<StepProps> = ({
5960
<Text>{checkout.newSubscription.totalCredits} VM credits</Text>
6061
</Stack>
6162
<Text size={6} color="#e5e5e5">
62-
${checkout.newSubscription.totalPrice} / month
63+
${checkout.newSubscription.totalPrice} /{' '}
64+
{checkout.newSubscription.billingInterval ===
65+
SubscriptionInterval.Monthly
66+
? 'month'
67+
: 'year'}
6368
</Text>
6469
</Stack>
6570

packages/app/src/app/graphql/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,6 +2237,7 @@ export type RootMutationTypeChangeTeamMemberAuthorizationsArgs = {
22372237

22382238
export type RootMutationTypeConvertToUsageBillingArgs = {
22392239
addons: Array<Scalars['String']>;
2240+
billingInterval: InputMaybe<SubscriptionInterval>;
22402241
plan: Scalars['String'];
22412242
teamId: Scalars['UUID4'];
22422243
};
@@ -2473,6 +2474,7 @@ export type RootMutationTypePermanentlyDeleteSandboxesArgs = {
24732474

24742475
export type RootMutationTypePreviewConvertToUsageBillingArgs = {
24752476
addons: Array<Scalars['String']>;
2477+
billingInterval: InputMaybe<SubscriptionInterval>;
24762478
plan: Scalars['String'];
24772479
teamId: Scalars['UUID4'];
24782480
};
@@ -5684,6 +5686,7 @@ export type PreviewConvertToUsageBillingMutationVariables = Exact<{
56845686
teamId: Scalars['UUID4'];
56855687
addons: Array<Scalars['String']> | Scalars['String'];
56865688
plan: Scalars['String'];
5689+
billingInterval: InputMaybe<SubscriptionInterval>;
56875690
}>;
56885691

56895692
export type PreviewConvertToUsageBillingMutation = {
@@ -5699,6 +5702,7 @@ export type ConvertToUsageBillingMutationVariables = Exact<{
56995702
teamId: Scalars['UUID4'];
57005703
addons: Array<Scalars['String']> | Scalars['String'];
57015704
plan: Scalars['String'];
5705+
billingInterval: InputMaybe<SubscriptionInterval>;
57025706
}>;
57035707

57045708
export type ConvertToUsageBillingMutation = {

packages/app/src/app/overmind/effects/gql/dashboard/mutations.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,11 +436,13 @@ export const previewConvertToUsageBilling: Query<
436436
$teamId: UUID4!
437437
$addons: [String!]!
438438
$plan: String!
439+
$billingInterval: SubscriptionInterval
439440
) {
440441
previewConvertToUsageBilling(
441442
plan: $plan
442443
addons: $addons
443444
teamId: $teamId
445+
billingInterval: $billingInterval
444446
) {
445447
total
446448
totalExcludingTax
@@ -456,8 +458,14 @@ export const convertToUsageBilling: Query<
456458
$teamId: UUID4!
457459
$addons: [String!]!
458460
$plan: String!
461+
$billingInterval: SubscriptionInterval
459462
) {
460-
convertToUsageBilling(plan: $plan, addons: $addons, teamId: $teamId)
463+
convertToUsageBilling(
464+
plan: $plan
465+
addons: $addons
466+
teamId: $teamId
467+
billingInterval: $billingInterval
468+
)
461469
}
462470
`;
463471

packages/app/src/app/overmind/namespaces/checkout/actions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ export const calculateConversionCharge = async (
355355
teamId: workspaceId,
356356
plan: newSubscription.basePlan.id,
357357
addons: actions.checkout.getFlatAddonsList(),
358+
billingInterval: newSubscription.billingInterval,
358359
});
359360

360361
// Cap the values to a min of 0
@@ -391,6 +392,7 @@ export const convertToUsageBilling = async (
391392
teamId: workspaceId,
392393
plan: newSubscription.basePlan.id,
393394
addons: actions.checkout.getFlatAddonsList(),
395+
billingInterval: newSubscription.billingInterval,
394396
});
395397

396398
return { success: true };

0 commit comments

Comments
 (0)