Skip to content

Commit 009daba

Browse files
authored
fix: plan redirect from pricing page (supabase#37231)
1 parent 41a5c39 commit 009daba

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

apps/studio/components/interfaces/Organization/NewOrg/NewOrgForm.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@ interface NewOrgFormProps {
6868
onPlanSelected: (plan: string) => void
6969
}
7070

71+
const plans = ['FREE', 'PRO', 'TEAM'] as const
72+
7173
const formSchema = z.object({
7274
plan: z
7375
.string()
7476
.transform((val) => val.toUpperCase())
75-
.pipe(z.enum(['FREE', 'PRO', 'TEAM', 'ENTERPRISE'] as const)),
77+
.pipe(z.enum(plans)),
7678
name: z.string().min(1),
7779
kind: z
7880
.string()
@@ -149,9 +151,10 @@ const NewOrgForm = ({ onPaymentMethodReset, setupIntent, onPlanSelected }: NewOr
149151

150152
if (typeof name === 'string') updateForm('name', name)
151153
if (typeof kind === 'string') updateForm('kind', kind)
152-
if (typeof plan === 'string') {
153-
updateForm('plan', plan)
154-
onPlanSelected(plan)
154+
if (typeof plan === 'string' && plans.includes(plan.toUpperCase() as (typeof plans)[number])) {
155+
const uppercasedPlan = plan.toUpperCase() as (typeof plans)[number]
156+
updateForm('plan', uppercasedPlan)
157+
onPlanSelected(uppercasedPlan)
155158
}
156159
if (typeof size === 'string') updateForm('size', size)
157160
if (typeof spend_cap === 'string') updateForm('spend_cap', spend_cap === 'true')
@@ -251,8 +254,7 @@ const NewOrgForm = ({ onPaymentMethodReset, setupIntent, onPlanSelected }: NewOr
251254
| 'tier_payg'
252255
| 'tier_pro'
253256
| 'tier_free'
254-
| 'tier_team'
255-
| 'tier_enterprise',
257+
| 'tier_team',
256258
...(formState.kind == 'COMPANY' ? { size: formState.size } : {}),
257259
payment_method: paymentMethodId,
258260
billing_name: dbTier === 'FREE' ? undefined : customerData?.billing_name,

apps/www/components/Pricing/PricingComparisonTable.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ const MobileHeader = ({
6666
})
6767
}
6868
size="medium"
69+
planId={selectedPlan.planId}
6970
/>
7071
) : (
7172
<Button asChild size="medium" type={plan === 'Enterprise' ? 'default' : 'primary'} block>
@@ -415,6 +416,7 @@ const PricingComparisonTable = ({
415416
})
416417
}
417418
size="tiny"
419+
planId={plan.planId}
418420
/>
419421
) : (
420422
<Button

apps/www/components/Pricing/PricingPlans.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ const PricingPlans = ({ organizations, hasExistingOrganizations }: PricingPlansP
7373
{plan.description}
7474
</p>
7575
{isUpgradablePlan && hasExistingOrganizations ? (
76-
<UpgradePlan organizations={organizations} onClick={sendPricingEvent} />
76+
<UpgradePlan
77+
planId={plan.planId}
78+
organizations={organizations}
79+
onClick={sendPricingEvent}
80+
/>
7781
) : (
7882
<Button
7983
block

apps/www/components/Pricing/UpgradePlan.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Check, ChevronsUpDown, Plus } from 'lucide-react'
22
import Link from 'next/link'
33
import { useState } from 'react'
4+
import { PlanId } from 'shared-data/plans'
45

56
import {
67
Button,
@@ -32,9 +33,10 @@ interface UpgradePlanProps {
3233
organizations?: Organization[]
3334
onClick?: () => void
3435
size?: ButtonProps['size']
36+
planId: PlanId
3537
}
3638

37-
const UpgradePlan = ({ organizations = [], onClick, size = 'large' }: UpgradePlanProps) => {
39+
const UpgradePlan = ({ organizations = [], onClick, size = 'large', planId }: UpgradePlanProps) => {
3840
const [open, setOpen] = useState(false)
3941
const [value, setValue] = useState('')
4042

@@ -142,7 +144,7 @@ const UpgradePlan = ({ organizations = [], onClick, size = 'large' }: UpgradePla
142144
<Link
143145
href={
144146
value === 'new-organization'
145-
? `/dashboard/new`
147+
? `/dashboard/new?plan=${planId}`
146148
: `/dashboard/org/${value}/billing?panel=subscriptionPlan`
147149
}
148150
>

0 commit comments

Comments
 (0)