File tree 1 file changed +16
-2
lines changed
src/routes/(console)/apply-credit
1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 12
12
WizardSecondaryContent ,
13
13
WizardSecondaryFooter
14
14
} from ' $lib/layout' ;
15
- import { type PaymentList } from ' $lib/sdk/billing' ;
15
+ import { type PaymentList , type Plan } from ' $lib/sdk/billing' ;
16
16
import { app } from ' $lib/stores/app' ;
17
17
import { isOrganization } from ' $lib/stores/billing.js' ;
18
18
import { addNotification } from ' $lib/stores/notifications' ;
72
72
let couponData = data ?.couponData ;
73
73
let campaign = data ?.campaign ;
74
74
let billingPlan = BillingPlan .PRO ;
75
+ let currentPlan: Plan ;
76
+
77
+ function isUpgrade() {
78
+ const newPlan = $page .data .plansInfo .get (billingPlan );
79
+ return currentPlan && newPlan && currentPlan .order < newPlan .order ;
80
+ }
75
81
76
82
onMount (async () => {
77
83
await loadPaymentMethods ();
132
138
}
133
139
134
140
// Upgrade existing org
135
- else if (selectedOrg ?.billingPlan !== billingPlan ) {
141
+ else if (selectedOrg ?.billingPlan !== billingPlan && isUpgrade () ) {
136
142
org = await sdk .forConsole .billing .updatePlan (
137
143
selectedOrg .$id ,
138
144
billingPlan ,
216
222
selectedOrg ?.billingPlan === BillingPlan .SCALE
217
223
? BillingPlan .SCALE
218
224
: (campaign ?.plan ?? BillingPlan .PRO );
225
+
226
+ $ : {
227
+ if (selectedOrgId ) {
228
+ (async () => {
229
+ currentPlan = await sdk .forConsole .billing .getOrganizationPlan (selectedOrgId );
230
+ })();
231
+ }
232
+ }
219
233
</script >
220
234
221
235
<svelte:head >
You can’t perform that action at this time.
0 commit comments